-
Notifications
You must be signed in to change notification settings - Fork 715
[portchannel] Added ACL/PBH binding checks to the port before getting added to portchannel #2151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
68ffca0
Added ACl/PBH binding checks to portchannel member cli
vivekrnv d74d47b
Update match_infra.py
vivekrnv db95441
Remove ununsed imports
vivekrnv c07fe36
Missing fixes
vivekrnv d716427
Comments handled
vivekrnv 72ad4fa
Using the same ns as iface
vivekrnv 0b896c6
Update main.py
vivekrnv 6d5017a
Merge branch 'master' into acl_port_issue
vivekrnv c36f15d
Update db.py
vivekrnv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
from dump.match_infra import MatchEngine, MatchRequest, ConnectionPool | ||
from dump.match_helper import get_matched_keys | ||
from .db import Db | ||
|
||
def get_port_acl_binding(db_wrap, port, ns): | ||
""" | ||
Verify if the port is not bound to any ACL Table | ||
|
||
Args: | ||
db_wrap: utilities_common.Db() object | ||
port: Iface name | ||
ns: namespace | ||
|
||
Returns: | ||
list: ACL_TABLE names if found, | ||
otherwise empty | ||
""" | ||
ACL = "ACL_TABLE" # Table to look for port bindings | ||
if not isinstance(db_wrap, Db): | ||
raise Exception("db_wrap object is not of type utilities_common.Db") | ||
|
||
conn_pool = ConnectionPool() | ||
conn_pool.fill(ns, db_wrap.db_clients[ns], db_wrap.db_list) | ||
m_engine = MatchEngine(conn_pool) | ||
req = MatchRequest(db="CONFIG_DB", | ||
table=ACL, | ||
key_pattern="*", | ||
field="ports@", | ||
value=port, | ||
ns=ns, | ||
match_entire_list=False) | ||
ret = m_engine.fetch(req) | ||
acl_tables, _ = get_matched_keys(ret) | ||
return acl_tables | ||
|
||
|
||
def get_port_pbh_binding(db_wrap, port, ns): | ||
""" | ||
Verify if the port is not bound to any PBH Table | ||
|
||
Args: | ||
db_wrap: Db() object | ||
port: Iface name | ||
ns: namespace | ||
|
||
Returns: | ||
list: PBH_TABLE names if found, | ||
otherwise empty | ||
""" | ||
PBH = "PBH_TABLE" # Table to look for port bindings | ||
if not isinstance(db_wrap, Db): | ||
raise Exception("db_wrap object is not of type utilities_common.Db") | ||
|
||
conn_pool = ConnectionPool() | ||
conn_pool.fill(ns, db_wrap.db_clients[ns], db_wrap.db_list) | ||
m_engine = MatchEngine(conn_pool) | ||
req = MatchRequest(db="CONFIG_DB", | ||
table=PBH, | ||
key_pattern="*", | ||
field="interface_list@", | ||
value=port, | ||
ns=ns, | ||
match_entire_list=False) | ||
ret = m_engine.fetch(req) | ||
pbh_tables, _ = get_matched_keys(ret) | ||
return pbh_tables |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.