Skip to content
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

Merged
merged 24 commits into from
Aug 14, 2020

Conversation

arlakshm
Copy link
Contributor

@arlakshm arlakshm commented Jul 15, 2020

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

  • 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.

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
@lgtm-com

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]
Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

@smaheshm smaheshm Jul 16, 2020

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])

Copy link
Contributor Author

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]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validate namespace.

Copy link
Contributor Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else:
return False?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in latest commit

Copy link
Contributor

@smaheshm smaheshm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments.

arlakshm added 2 commits July 16, 2020 14:46
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
@arlakshm
Copy link
Contributor Author

retest vsimage please

# name lanes alias asic_port_name role
Ethernet0 33,34,35,36 Ethernet1/1 Eth0-ASIC0 E
Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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
....

Copy link
Contributor Author

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 ?

Copy link
Contributor

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 ?

Copy link
Contributor Author

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

@jleveque
Copy link
Contributor

@arlakshm: Would it be possible to wait until #5003 merges, then add this functionality to that package instead?

@arlakshm
Copy link
Contributor Author

arlakshm commented Jul 22, 2020

@arlakshm: Would it be possible to wait until #5003 merges, then add this functionality to that package instead?

@jleveque : Sure, I will add them to sonic-py-common

@arlakshm arlakshm requested a review from jleveque July 30, 2020 19:14
@arlakshm
Copy link
Contributor Author

@arlakshm: Would it be possible to wait until #5003 merges, then add this functionality to that package instead?

@jleveque : Sure, I will add them to sonic-py-common

@jleveque: I moved the common functions to sonic-py-common. Please review and provide feedback

@lgtm-com

This comment has been minimized.

Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
@lgtm-com

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':
Copy link
Contributor

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 ?

Copy link
Contributor Author

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>
judyjoseph
judyjoseph previously approved these changes Aug 11, 2020
@arlakshm
Copy link
Contributor Author

@abdosi, @lguohan , @jleveque . All review comments are addressed. Please approve if there are no other comments

abdosi
abdosi previously approved these changes Aug 11, 2020
src/sonic-config-engine/tests/test_multinpu_cfggen.py Outdated Show resolved Hide resolved
src/sonic-py-common/sonic_py_common/multi_asic.py Outdated Show resolved Hide resolved
src/sonic-py-common/sonic_py_common/multi_asic.py Outdated Show resolved Hide resolved
@arlakshm arlakshm dismissed stale reviews from abdosi and judyjoseph via 789a548 August 12, 2020 17:25
@arlakshm arlakshm requested review from jleveque and abdosi August 13, 2020 20:32
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
@arlakshm
Copy link
Contributor Author

retest vsimage please

@arlakshm arlakshm merged commit 6c89551 into sonic-net:master Aug 14, 2020
santhosh-kt pushed a commit to santhosh-kt/sonic-buildimage that referenced this pull request Feb 25, 2021
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants