-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Common functions for Multi ASIC CLIs #4973
Conversation
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
if namespace is None: | ||
ns_list = get_namespaces() | ||
else: | ||
ns_list = [namespace] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check of valid namepsace it not already checked. Raise exception if invalid namespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, the namespace validation should be done by the caller ( CLI handler)
members = port_channels[port_channel]['members'] | ||
for member in members: | ||
if is_port_internal(member): | ||
return True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic will be intensive for 'external' ports. It'll call 'get_port_config_from_all_asics()' for all member ports. Any reason why you are checking all members for 'external' role and only one member for 'internal' role.
will this work:
return is_port_internal(members[0])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in the latest commit
if namespace is None: | ||
ns_list = get_namespaces() | ||
else: | ||
ns_list = [namespace] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validate namespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, the namespace validation should be done by the caller ( CLI handler)
bgp_neigh_name = bgp_sessions[bgp_neigh_ip]['name'] | ||
neighbor_metadata = config_db.get_table(NEIGH_DEVICE_METADATA_CFG_DB_TABLE) | ||
if neighbor_metadata[bgp_neigh_name]['type'].lower() == 'asic': | ||
return True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else:
return False?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in latest commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments.
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
retest vsimage please |
# name lanes alias asic_port_name role | ||
Ethernet0 33,34,35,36 Ethernet1/1 Eth0-ASIC0 E |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I talked to Joe, as per him it would be good to add the "index" field also in port_config.ini files. There could be API's which use that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the usage or significance of index here? There is a way an index is computed based on interface name, which is used in SNMP mainly.
https://github.com/Azure/sonic-py-swsssdk/blob/master/src/swsssdk/port_util.py#L26
Is the interface index compute in port_util same as index here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@judyjoseph, @SuvarnaMeenakshi.
I have added port_index in the port_config.ini in the latest commit. The port index is a running number, there is no significance to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks ! To mention the significance of "index" .. there are some places where the code check for presence of "index" in the port_config.ini eg: https://github.com/Azure/sonic-platform-common/blob/be1cc2475e65b764f7aab44785a779cc3d011ee9/sonic_platform_base/sonic_sfp/sfputilbase.py#L458
So it would be safer to have the index field.... as there are logic below which checks for len(line.split()) >= 4: etc. This will change for us as we add more columns now.
Also we would need to have separate index numbering for front-panel and back panel interfaces ...
Ethernet0 33,34,35,36 Ethernet1/1 0 Eth0-ASIC0 E
Ethernet4 29,30,31,32 Ethernet1/2 1 Eth1-ASIC0 E
...
Ethernet-BP0 13,14,15,16 Ethernet-BP0 0 Eth4-ASIC0 I
Ethernet-BP4 17,18,19,20 Ethernet-BP4 1 Eth5-ASIC0 I
....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also we would need to have separate index numbering for front-panel and back panel interfaces ...
@judyjoseph, can you elaborate why we need separate index numbering for front-panel and back panel interface ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the platform code ( could be other places as well ) we are making a logical list of all the interfaces, and we are looking for only front panel interfaces which is significant. Currently when there is no "index" field in port_config.ini, the way it calculates the index is from the name "Ethernet0"(here it is 0/4 ==> 0), "Ethernet4" (here it is 4/4 ==> 1) etc.
So It would be ok to start the index from 0 separately per interface type and it will follow the interface naming/numbering convention also. Do you think there could be an issue ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@judyjoseph, Changed the port_config.ini in the latest commit
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
This comment has been minimized.
This comment has been minimized.
neighbor_metadata = config_db.get_table( | ||
NEIGH_DEVICE_METADATA_CFG_DB_TABLE) | ||
|
||
if neighbor_metadata[bgp_neigh_name]['type'].lower() == 'asic': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to check if neighbor_metadata exist ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a check in latest commit
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
signoff
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
signoff
retest vsimage please |
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan arlakshm@microsoft.com The following common APIs are added for multi ASIC - an API to check if a given port is a internal or external port - an API to check if a given port-channel is internal or external - an API to check if a bgp-session is internal or external - an API to connect to the config and other dbs in the a given namespace - added common APIs to the sonic_py_common library. - update the sample port-config.ini with role column and add corresponding test to verify the ports configuration is - generated properly.
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan arlakshm@microsoft.com
- Why I did it
The PR implements few common functions needed for CLI and other modules.
- How I did it
The following common APIs are added for multi ASIC
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)