Common functions for Multi ASIC CLIs#4973
Conversation
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <[email protected]>
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <[email protected]>
| if namespace is None: | ||
| ns_list = get_namespaces() | ||
| else: | ||
| ns_list = [namespace] |
There was a problem hiding this comment.
check of valid namepsace it not already checked. Raise exception if invalid namespace.
There was a problem hiding this comment.
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.
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.
Fixed in the latest commit
| if namespace is None: | ||
| ns_list = get_namespaces() | ||
| else: | ||
| ns_list = [namespace] |
There was a problem hiding this comment.
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.
Fixed in latest commit
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <[email protected]>
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <[email protected]>
|
retest vsimage please |
| Ethernet-BP8 21,22,23,24 Ethernet-BP8 Eth6-ASIC0 | ||
| Ethernet-BP12 25,26,27,28 Ethernet-BP12 Eth7-ASIC0 No newline at end of file | ||
| # name lanes alias asic_port_name role | ||
| Ethernet0 33,34,35,36 Ethernet1/1 Eth0-ASIC0 E |
There was a problem hiding this comment.
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.
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.
@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.
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.
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.
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.
@judyjoseph, Changed the port_config.ini in the latest commit
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <[email protected]>
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <[email protected]>
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.
do we need to check if neighbor_metadata exist ?
There was a problem hiding this comment.
added a check in latest commit
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <[email protected]>
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <[email protected]>
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <[email protected]>
signoff
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <[email protected]>
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <[email protected]>
signoff
|
retest vsimage please |
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan [email protected] 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 [email protected]
- 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)