-
Notifications
You must be signed in to change notification settings - Fork 816
[debug dump util] Portchannel module added #1853
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 all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
be7dbe5
LAG module added
vivekrnv 38fa157
Comments Addressed
vivekrnv d2ebee8
Changed the UT to use the default mock
vivekrnv 3700e20
Unused import removed
vivekrnv 2b91725
Merge branch 'master' of https://github.com/Azure/sonic-utilities int…
vivekrnv a84a74b
Lag and members separated into different modules
vivekrnv 179a092
Merge branch 'dump_module_lag' of https://github.com/vivekreddynv/son…
vivekrnv 7bd57ca
unused method removed
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| from dump.match_infra import MatchRequest | ||
| from dump.helper import create_template_dict | ||
| from .executor import Executor | ||
|
|
||
|
|
||
| class Portchannel(Executor): | ||
| """ | ||
| Debug Dump Plugin for PortChannel/LAG Module | ||
| """ | ||
| ARG_NAME = "portchannel_name" | ||
|
|
||
| def __init__(self, match_engine=None): | ||
| super().__init__(match_engine) | ||
| self.ret_temp = {} | ||
| self.ns = '' | ||
| self.lag_members = set() | ||
|
|
||
| def get_all_args(self, ns=""): | ||
| req = MatchRequest(db="CONFIG_DB", table="PORTCHANNEL", key_pattern="*", ns=ns) | ||
| ret = self.match_engine.fetch(req) | ||
| all_lags = ret["keys"] | ||
| return [key.split("|")[-1] for key in all_lags] | ||
|
|
||
| def execute(self, params_dict): | ||
| self.ret_temp = create_template_dict(dbs=["CONFIG_DB", "APPL_DB", "ASIC_DB", "STATE_DB"]) | ||
| self.lag_name = params_dict[Portchannel.ARG_NAME] | ||
| self.ns = params_dict["namespace"] | ||
| # CONFIG_DB | ||
| lag_found = self.init_lag_config_info() | ||
| if lag_found: | ||
| self.init_lag_member_config_info() | ||
| # APPL_DB | ||
| self.init_lag_appl_info() | ||
| # STATE_DB | ||
| self.init_lag_state_info() | ||
| # ASIC_DB | ||
| lag_type_objs_asic = self.init_lag_member_type_obj_asic_info() | ||
| self.init_lag_asic_info(lag_type_objs_asic) | ||
| return self.ret_temp | ||
|
|
||
| def add_to_ret_template(self, table, db, keys, err): | ||
| if not err and keys: | ||
| self.ret_temp[db]["keys"].extend(keys) | ||
| return True | ||
| else: | ||
| self.ret_temp[db]["tables_not_found"].extend([table]) | ||
| return False | ||
|
|
||
| def init_lag_config_info(self): | ||
| req = MatchRequest(db="CONFIG_DB", table="PORTCHANNEL", key_pattern=self.lag_name, ns=self.ns) | ||
| ret = self.match_engine.fetch(req) | ||
| return self.add_to_ret_template(req.table, req.db, ret["keys"], ret["error"]) | ||
|
|
||
| def init_lag_member_config_info(self): | ||
| req = MatchRequest(db="CONFIG_DB", table="PORTCHANNEL_MEMBER", key_pattern=self.lag_name + "|*", ns=self.ns) | ||
| ret = self.match_engine.fetch(req) | ||
| for key in ret["keys"]: | ||
| self.lag_members.add(key.split("|")[-1]) | ||
|
|
||
| def init_lag_appl_info(self): | ||
| req = MatchRequest(db="APPL_DB", table="LAG_TABLE", key_pattern=self.lag_name, ns=self.ns) | ||
| ret = self.match_engine.fetch(req) | ||
| return self.add_to_ret_template(req.table, req.db, ret["keys"], ret["error"]) | ||
|
|
||
| def init_lag_state_info(self): | ||
| req = MatchRequest(db="STATE_DB", table="LAG_TABLE", key_pattern=self.lag_name, ns=self.ns) | ||
| ret = self.match_engine.fetch(req) | ||
| return self.add_to_ret_template(req.table, req.db, ret["keys"], ret["error"]) | ||
|
|
||
| def init_lag_asic_info(self, lag_type_objs_asic): | ||
| if len(lag_type_objs_asic) == 0: | ||
| self.ret_temp["ASIC_DB"]["tables_not_found"].extend(["ASIC_STATE:SAI_OBJECT_TYPE_LAG"]) | ||
| return | ||
| for lag_asic_obj in lag_type_objs_asic: | ||
| req = MatchRequest(db="ASIC_DB", table="ASIC_STATE:SAI_OBJECT_TYPE_LAG", key_pattern=lag_asic_obj, ns=self.ns) | ||
| ret = self.match_engine.fetch(req) | ||
| self.add_to_ret_template(req.table, req.db, ret["keys"], ret["error"]) | ||
|
|
||
| def init_lag_member_type_obj_asic_info(self): | ||
| """ | ||
| Finding the relevant SAI_OBJECT_TYPE_LAG key directly from the ASIC is not possible given a LAG name | ||
| Thus, using the members to find SAI_LAG_MEMBER_ATTR_LAG_ID | ||
| """ | ||
| lag_type_objs_asic = set() | ||
| for port_name in self.lag_members: | ||
| port_asic_obj = self.get_port_asic_obj(port_name) | ||
| if port_asic_obj: | ||
| lag_member_key, lag_oid = self.get_lag_and_member_obj(port_asic_obj) | ||
| lag_type_objs_asic.add(lag_oid) | ||
| return lag_type_objs_asic | ||
|
|
||
| def get_port_asic_obj(self, port_name): | ||
| req = MatchRequest(db="ASIC_DB", table="ASIC_STATE:SAI_OBJECT_TYPE_HOSTIF", key_pattern="*", field="SAI_HOSTIF_ATTR_NAME", | ||
| value=port_name, return_fields=["SAI_HOSTIF_ATTR_OBJ_ID"], ns=self.ns) | ||
| ret = self.match_engine.fetch(req) | ||
| asic_port_obj_id = "" | ||
| if not ret["error"] and ret["keys"]: | ||
| sai_hostif_obj_key = ret["keys"][-1] | ||
| if sai_hostif_obj_key in ret["return_values"] and "SAI_HOSTIF_ATTR_OBJ_ID" in ret["return_values"][sai_hostif_obj_key]: | ||
| asic_port_obj_id = ret["return_values"][sai_hostif_obj_key]["SAI_HOSTIF_ATTR_OBJ_ID"] | ||
| return asic_port_obj_id | ||
|
|
||
| def get_lag_and_member_obj(self, port_asic_obj): | ||
| req = MatchRequest(db="ASIC_DB", table="ASIC_STATE:SAI_OBJECT_TYPE_LAG_MEMBER", key_pattern="*", field="SAI_LAG_MEMBER_ATTR_PORT_ID", | ||
| value=port_asic_obj, return_fields=["SAI_LAG_MEMBER_ATTR_LAG_ID"], ns=self.ns) | ||
| ret = self.match_engine.fetch(req) | ||
| lag_member_key = "" | ||
| lag_oid = "" | ||
| if not ret["error"] and ret["keys"]: | ||
| lag_member_key = ret["keys"][-1] | ||
| if lag_member_key in ret["return_values"] and "SAI_LAG_MEMBER_ATTR_LAG_ID" in ret["return_values"][lag_member_key]: | ||
| lag_oid = ret["return_values"][lag_member_key]["SAI_LAG_MEMBER_ATTR_LAG_ID"] | ||
| return lag_member_key, lag_oid | ||
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,84 @@ | ||
| from dump.match_infra import MatchRequest | ||
| from dump.helper import create_template_dict | ||
| from .executor import Executor | ||
|
|
||
| class Portchannel_Member(Executor): | ||
| """ | ||
| Debug Dump Plugin for PortChannel/LAG Module | ||
| """ | ||
| ARG_NAME = "portchannel_member" | ||
|
|
||
| def __init__(self, match_engine=None): | ||
| super().__init__(match_engine) | ||
| self.ret_temp = {} | ||
| self.ns = '' | ||
| self.lag_member_key = '' | ||
| self.lag = '' | ||
| self.port_name = '' | ||
|
|
||
| def get_all_args(self, ns=""): | ||
| req = MatchRequest(db="CONFIG_DB", table="PORTCHANNEL_MEMBER", key_pattern="*", ns=ns) | ||
| ret = self.match_engine.fetch(req) | ||
| all_lag_members = ret["keys"] | ||
| return [key.split("|", 1)[-1] for key in all_lag_members] | ||
|
|
||
| def execute(self, params_dict): | ||
| self.ret_temp = create_template_dict(dbs=["CONFIG_DB", "APPL_DB", "ASIC_DB", "STATE_DB"]) | ||
| self.lag_member_key = params_dict[Portchannel_Member.ARG_NAME] | ||
| if "|" not in self.lag_member_key: | ||
| return self.ret_temp | ||
| self.lag, self.port_name = self.lag_member_key.split("|", 1) | ||
| self.ns = params_dict["namespace"] | ||
| # CONFIG_DB | ||
| self.init_lag_member_config_info() | ||
| # APPL_DB | ||
| self.init_lag_member_appl_info() | ||
| # STATE_DB | ||
| self.init_lag_member_state_info() | ||
| # ASIC_DB | ||
| self.init_lag_member_type_obj_asic_info() | ||
| return self.ret_temp | ||
|
|
||
| def add_to_ret_template(self, table, db, keys, err): | ||
| if not err and keys: | ||
| self.ret_temp[db]["keys"].extend(keys) | ||
| return True | ||
| else: | ||
| self.ret_temp[db]["tables_not_found"].extend([table]) | ||
| return False | ||
|
|
||
| def init_lag_member_config_info(self): | ||
| req = MatchRequest(db="CONFIG_DB", table="PORTCHANNEL_MEMBER", key_pattern=self.lag_member_key, ns=self.ns) | ||
| ret = self.match_engine.fetch(req) | ||
| return self.add_to_ret_template(req.table, req.db, ret["keys"], ret["error"]) | ||
|
|
||
| def init_lag_member_appl_info(self): | ||
| req = MatchRequest(db="APPL_DB", table="LAG_MEMBER_TABLE", key_pattern=self.lag + ":" + self.port_name, ns=self.ns) | ||
| ret = self.match_engine.fetch(req) | ||
| return self.add_to_ret_template(req.table, req.db, ret["keys"], ret["error"]) | ||
|
|
||
| def init_lag_member_state_info(self): | ||
| req = MatchRequest(db="STATE_DB", table="LAG_MEMBER_TABLE", key_pattern=self.lag_member_key, ns=self.ns) | ||
| ret = self.match_engine.fetch(req) | ||
| return self.add_to_ret_template(req.table, req.db, ret["keys"], ret["error"]) | ||
|
|
||
| def init_lag_member_type_obj_asic_info(self): | ||
| port_asic_obj = self.get_port_asic_obj(self.port_name) | ||
| if not port_asic_obj: | ||
| self.ret_temp["ASIC_DB"]["tables_not_found"].extend(["ASIC_STATE:SAI_OBJECT_TYPE_LAG_MEMBER"]) | ||
| return False | ||
| req = MatchRequest(db="ASIC_DB", table="ASIC_STATE:SAI_OBJECT_TYPE_LAG_MEMBER", key_pattern="*", field="SAI_LAG_MEMBER_ATTR_PORT_ID", | ||
| value=port_asic_obj, ns=self.ns) | ||
| ret = self.match_engine.fetch(req) | ||
| return self.add_to_ret_template(req.table, req.db, ret["keys"], ret["error"]) | ||
|
|
||
| def get_port_asic_obj(self, port_name): | ||
| req = MatchRequest(db="ASIC_DB", table="ASIC_STATE:SAI_OBJECT_TYPE_HOSTIF", key_pattern="*", field="SAI_HOSTIF_ATTR_NAME", | ||
| value=port_name, return_fields=["SAI_HOSTIF_ATTR_OBJ_ID"], ns=self.ns) | ||
| ret = self.match_engine.fetch(req) | ||
| asic_port_obj_id = "" | ||
| if not ret["error"] and ret["keys"]: | ||
| sai_hostif_obj_key = ret["keys"][-1] | ||
| if sai_hostif_obj_key in ret["return_values"] and "SAI_HOSTIF_ATTR_OBJ_ID" in ret["return_values"][sai_hostif_obj_key]: | ||
| asic_port_obj_id = ret["return_values"][sai_hostif_obj_key]["SAI_HOSTIF_ATTR_OBJ_ID"] | ||
| return asic_port_obj_id |
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,18 @@ | ||
| { | ||
| "LAG_TABLE:PortChannel002": { | ||
| "oper_status": "up", | ||
| "mtu": "9100", | ||
| "admin_status": "up" | ||
| }, | ||
| "LAG_TABLE:PortChannel001": { | ||
| "oper_status": "up", | ||
| "mtu": "9100", | ||
| "admin_status": "up" | ||
| }, | ||
| "LAG_MEMBER_TABLE:PortChannel001:Ethernet4": { | ||
| "status": "enabled" | ||
| }, | ||
| "LAG_MEMBER_TABLE:PortChannel001:Ethernet0": { | ||
| "status": "enabled" | ||
| } | ||
| } |
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,34 @@ | ||
| { | ||
| "ASIC_STATE:SAI_OBJECT_TYPE_LAG:oid:0x2000000000d17":{ | ||
| "SAI_LAG_ATTR_PORT_VLAN_ID": "1" | ||
| }, | ||
| "ASIC_STATE:SAI_OBJECT_TYPE_LAG:oid:0x20000000004d3": { | ||
| "NULL": "NULL" | ||
| }, | ||
| "ASIC_STATE:SAI_OBJECT_TYPE_LAG_MEMBER:oid:0x1b000000000d18": { | ||
| "SAI_LAG_MEMBER_ATTR_EGRESS_DISABLE": "false", | ||
| "SAI_LAG_MEMBER_ATTR_INGRESS_DISABLE": "false", | ||
| "SAI_LAG_MEMBER_ATTR_LAG_ID": "oid:0x2000000000d17", | ||
| "SAI_LAG_MEMBER_ATTR_PORT_ID": "oid:0x10000000002cc" | ||
| }, | ||
| "ASIC_STATE:SAI_OBJECT_TYPE_LAG_MEMBER:oid:0x1b000000000d1a": { | ||
| "SAI_LAG_MEMBER_ATTR_EGRESS_DISABLE": "false", | ||
| "SAI_LAG_MEMBER_ATTR_INGRESS_DISABLE": "false", | ||
| "SAI_LAG_MEMBER_ATTR_LAG_ID": "oid:0x2000000000d17", | ||
| "SAI_LAG_MEMBER_ATTR_PORT_ID": "oid:0x100000000093e" | ||
| }, | ||
| "ASIC_STATE:SAI_OBJECT_TYPE_HOSTIF:oid:0xd000000000cdf": { | ||
| "SAI_HOSTIF_ATTR_NAME": "Ethernet0", | ||
| "SAI_HOSTIF_ATTR_OBJ_ID": "oid:0x10000000002cc", | ||
| "SAI_HOSTIF_ATTR_OPER_STATUS": "true", | ||
| "SAI_HOSTIF_ATTR_TYPE": "SAI_HOSTIF_TYPE_NETDEV", | ||
| "SAI_HOSTIF_ATTR_VLAN_TAG": "SAI_HOSTIF_VLAN_TAG_STRIP" | ||
| }, | ||
| "ASIC_STATE:SAI_OBJECT_TYPE_HOSTIF:oid:0xd000000000acd": { | ||
| "SAI_HOSTIF_ATTR_NAME": "Ethernet4", | ||
| "SAI_HOSTIF_ATTR_OBJ_ID": "oid:0x100000000093e", | ||
| "SAI_HOSTIF_ATTR_OPER_STATUS": "true", | ||
| "SAI_HOSTIF_ATTR_TYPE": "SAI_HOSTIF_TYPE_NETDEV", | ||
| "SAI_HOSTIF_ATTR_VLAN_TAG": "SAI_HOSTIF_VLAN_TAG_STRIP" | ||
| } | ||
| } |
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,29 @@ | ||
| { | ||
| "PORTCHANNEL|PortChannel001": { | ||
| "admin_status": "up", | ||
| "lacp_key": "auto", | ||
| "min_links": "1", | ||
| "mtu": "9100" | ||
| }, | ||
| "PORTCHANNEL|PortChannel002": { | ||
| "admin_status": "up", | ||
| "lacp_key": "auto", | ||
| "min_links": "1", | ||
| "mtu": "9100" | ||
| }, | ||
| "PORTCHANNEL|PortChannel003": { | ||
| "admin_status": "up", | ||
| "lacp_key": "auto", | ||
| "min_links": "1", | ||
| "mtu": "9100" | ||
| }, | ||
| "PORTCHANNEL_MEMBER|PortChannel001|Ethernet0": { | ||
| "NULL" : "NULL" | ||
| }, | ||
| "PORTCHANNEL_MEMBER|PortChannel001|Ethernet4": { | ||
| "NULL" : "NULL" | ||
| }, | ||
| "PORTCHANNEL_MEMBER|PortChannel001|Ethernet8": { | ||
| "NULL" : "NULL" | ||
| } | ||
| } |
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,54 @@ | ||
| { | ||
| "LAG_TABLE|PortChannel001":{ | ||
| "runner.active": "true", | ||
| "runner.fallback": "false", | ||
| "runner.fast_rate": "false", | ||
| "setup.kernel_team_mode_name": "loadbalance", | ||
| "setup.pid": "27", | ||
| "state": "ok", | ||
| "team_device.ifinfo.dev_addr": "1c:34:da:1c:9f:00", | ||
| "team_device.ifinfo.ifindex": "137" | ||
| }, | ||
| "LAG_TABLE|PortChannel002":{ | ||
| "runner.active": "true", | ||
| "runner.fallback": "false", | ||
| "runner.fast_rate": "false", | ||
| "setup.kernel_team_mode_name": "loadbalance", | ||
| "setup.pid": "35", | ||
| "state": "ok", | ||
| "team_device.ifinfo.dev_addr": "1c:34:da:1c:9f:00", | ||
| "team_device.ifinfo.ifindex": "138" | ||
| }, | ||
| "LAG_MEMBER_TABLE|PortChannel001|Ethernet4":{ | ||
| "ifinfo.dev_addr": "1c:34:da:1c:9f:00", | ||
| "ifinfo.ifindex": "203", | ||
| "link.up": "true", | ||
| "link_watches.list.link_watch_0.up": "true", | ||
| "runner.actor_lacpdu_info.port": "5", | ||
| "runner.actor_lacpdu_info.state": "69", | ||
| "runner.actor_lacpdu_info.system": "1c:34:da:1c:9f:00", | ||
| "runner.aggregator.id": "0", | ||
| "runner.aggregator.selected": "false", | ||
| "runner.partner_lacpdu_info.port": "0", | ||
| "runner.partner_lacpdu_info.state": "2", | ||
| "runner.partner_lacpdu_info.system": "00:00:00:00:00:00", | ||
| "runner.selected": "false", | ||
| "runner.state": "defaulted" | ||
| }, | ||
| "LAG_MEMBER_TABLE|PortChannel001|Ethernet0":{ | ||
| "ifinfo.dev_addr": "1c:34:da:1c:9f:00", | ||
| "ifinfo.ifindex": "202", | ||
| "link.up": "true", | ||
| "link_watches.list.link_watch_0.up": "true", | ||
| "runner.actor_lacpdu_info.port": "0", | ||
| "runner.actor_lacpdu_info.state": "69", | ||
| "runner.actor_lacpdu_info.system": "1c:34:da:1c:9f:00", | ||
| "runner.aggregator.id": "0", | ||
| "runner.aggregator.selected": "false", | ||
| "runner.partner_lacpdu_info.port": "0", | ||
| "runner.partner_lacpdu_info.state": "2", | ||
| "runner.partner_lacpdu_info.system": "00:00:00:00:00:00", | ||
| "runner.selected": "false", | ||
| "runner.state": "defaulted" | ||
| } | ||
| } |
Oops, something went wrong.
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.