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

Parser changes to support parsing of multi-asic device minigraph #4222

Merged
merged 27 commits into from
May 4, 2020

Conversation

SuvarnaMeenakshi
Copy link
Contributor

- What I did
In case of multiasic platform, a single minigraph.xml will be present for the device. This minigraph.xml will include device specific data and internal asic specific data. The current parser assumes that the minigraph will have data specific to a single device. In a multiple asic minigraph.xml, each asic data will be modelled as a separate device. With this change, expectation is to be able to parse and generate configuration for all asics of the device.
Apart from this, port_config.ini will have a new column to provide "asic_port_name". This name be a combination of "port name in asic" and "asic name".

- How I did it

  1. Made changes to portconfig.py to parse the new column if it exists and create a new mapping to map alias to asic_port_name which will be used in minigraph.py
  2. minigraph.py updated to accept a new parameter "hostname" which will define the name of specific host/ASIC that is of interest and configuration will be generated for this host. If "hostname" is not provided, this will be the same as what is defined in minigraph.xml.

- How to verify it
Generated config_db.json before and after the parser changes for a single asic device. No change observed.
- Description for the changelog

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

to support multi-asic platforms.
portconfig.py updated to parse additional column "asic_name" in
port_config.ini
minigraph.py updated to parse minigraph.xml of a multi-asic device
which includes multiple asic data.
@SuvarnaMeenakshi SuvarnaMeenakshi changed the title Parser changes to support parsing of mutli-asic device minigraph Parser changes to support parsing of multi-asic device minigraph Mar 4, 2020
SuvarnaMeenakshi and others added 2 commits March 13, 2020 11:56
added in port table only if it is present in port_config.ini.
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
@lguohan
Copy link
Collaborator

lguohan commented Apr 5, 2020

need unit test on the sonic-cfggen part to parse multi-asic minigraph.

num_npus = token[1].strip()
return num_npus

def get_namespaces():
Copy link
Collaborator

Choose a reason for hiding this comment

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

i do not see this function used anywhere else in you code, in the multi npu system, why not use asic.conf to derive the namepsace you have on the system? why use ip netns list to query?

Copy link
Contributor

Choose a reason for hiding this comment

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

The plan is use this function by CLI commands.
Today the namespace are names as "asicX" , it could change in the future so didn't want to generate the name from asic.conf here.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
@lgtm-com
Copy link

lgtm-com bot commented Apr 7, 2020

This pull request introduces 1 alert when merging d4fe8e0 into 2a59551 - view on LGTM.com

new alerts:

  • 1 for Unused local variable

Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
@arlakshm
Copy link
Contributor

need unit test on the sonic-cfggen part to parse multi-asic minigraph.

Added Unit test for parsing multi-npu minigraph.

@rlhui
Copy link
Contributor

rlhui commented Apr 15, 2020

retest this please

asic_id = None
if asic_name is not None:
asic_id = asic_name[-1]
asic_role = parse_asic_sub_role(args.minigraph if args.minigraph else '/etc/sonic/minigraph.xml', asic_name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do you need specify /etc/sonic/minigraph.xml, it is in line 196.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is needed when the sonic-cfggen command is executed without -m option.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we show error in this case?

Copy link
Contributor

Choose a reason for hiding this comment

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

There are a few platform related methods which execute 'sonic-cfggen -H' to get the platform data and other information from device_metadata.
To support these cases for multi-npu platforms, the miigraph from the default location will be used if no minigraph is provided.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think In this case you need to use option --minigraph= and provide the required minigraph

Copy link
Contributor

@arlakshm arlakshm May 3, 2020

Choose a reason for hiding this comment

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

Changed to use the minigraph only when --minigraph option is provided.

@lguohan
Copy link
Collaborator

lguohan commented Apr 16, 2020

can you resolve conflict?

arlakshm and others added 2 commits April 16, 2020 08:13
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
…_changes

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
@SuvarnaMeenakshi
Copy link
Contributor Author

can you resolve conflict?

resolved conflicts.

@lgtm-com
Copy link

lgtm-com bot commented Apr 16, 2020

This pull request fixes 1 alert when merging 9c9f8c2 into 695652c - view on LGTM.com

fixed alerts:

  • 1 for Unused import

Copy link
Contributor

@pavel-shirshov pavel-shirshov left a comment

Choose a reason for hiding this comment

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

As comments. I'll check minigraph part later

src/sonic-config-engine/tests/test_multinpu_cfggen.py Outdated Show resolved Hide resolved
def test_read_yaml(self):
argument = '-v yml_item -y ' + os.path.join(self.test_dir, 'test.yml')
output = self.run_script(argument)
self.assertEqual(output.strip(), '[\'value1\', \'value2\']')
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

changed in latest commit

src/sonic-config-engine/tests/test_multinpu_cfggen.py Outdated Show resolved Hide resolved
def test_metadata_tacacs(self):
argument = '-m "' + self.sample_graph + '" -v "TACPLUS_SERVER"'
output = self.run_script(argument)
self.assertEqual(output.strip(),"{'123.46.98.21': {'priority': '1', 'tcp_port': '49'}}")
Copy link
Contributor

Choose a reason for hiding this comment

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

assertDictEqual

Copy link
Contributor

Choose a reason for hiding this comment

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

changed in latest commit

src/sonic-config-engine/tests/test_multinpu_cfggen.py Outdated Show resolved Hide resolved
src/sonic-config-engine/tests/test_multinpu_cfggen.py Outdated Show resolved Hide resolved
src/sonic-config-engine/sonic_device_util.py Outdated Show resolved Hide resolved
src/sonic-config-engine/sonic_device_util.py Outdated Show resolved Hide resolved
src/sonic-config-engine/sonic_device_util.py Outdated Show resolved Hide resolved
asic_id = None
if asic_name is not None:
asic_id = asic_name[-1]
asic_role = parse_asic_sub_role(args.minigraph if args.minigraph else '/etc/sonic/minigraph.xml', asic_name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we show error in this case?

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

lgtm-com bot commented Apr 17, 2020

This pull request introduces 1 alert and fixes 1 when merging 5b6892e into 744d33d - view on LGTM.com

new alerts:

  • 1 for Variable defined multiple times

fixed alerts:

  • 1 for Unused import

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

lgtm-com bot commented Apr 19, 2020

This pull request introduces 1 alert and fixes 1 when merging 78a2bf7 into d8b7166 - view on LGTM.com

new alerts:

  • 1 for Variable defined multiple times

fixed alerts:

  • 1 for Unused import

concise and readable.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
@lgtm-com
Copy link

lgtm-com bot commented May 2, 2020

This pull request fixes 1 alert when merging 110d1b8 into c55603f - view on LGTM.com

fixed alerts:

  • 1 for Unused import

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
@lgtm-com
Copy link

lgtm-com bot commented May 2, 2020

This pull request fixes 1 alert when merging 247370b into c55603f - view on LGTM.com

fixed alerts:

  • 1 for Unused import

elif child.tag == str(QName(ns, "CpgDec")):
(bgp_sessions, bgp_asn, bgp_peers_with_range, bgp_monitors) = parse_cpg(child, asic_name)
elif child.tag == str(QName(ns, "UngDec")):
(u_neighbors, u_devices, _, _) = parse_asic_png(child, asic_name, hostname)
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove

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 as per comment

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
@rlhui
Copy link
Contributor

rlhui commented May 2, 2020

retest vsimage please

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

lgtm-com bot commented May 3, 2020

This pull request fixes 1 alert when merging 06983e4 into 30bbbbf - view on LGTM.com

fixed alerts:

  • 1 for Unused import

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

lgtm-com bot commented May 4, 2020

This pull request fixes 1 alert when merging 17a0d04 into 30bbbbf - view on LGTM.com

fixed alerts:

  • 1 for Unused import

Copy link
Collaborator

@lguohan lguohan left a comment

Choose a reason for hiding this comment

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

:shipit:

@arlakshm arlakshm merged commit 8ac1c60 into sonic-net:master May 4, 2020
abdosi pushed a commit that referenced this pull request May 5, 2020
…e minigraph (#4222)

- Changes to minigraph.py to parse minigraph.xml of a multi asic platform 
- Changes to portconfig.py to parse additional column "asic_port_name" in
port_config.ini
- Add a new option -n to sonic-cfggen for multi asic platforms
- Add unit tests for config generation for multi asic platforms

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
elif child.tag == str(QName(ns, "PngDec")):
(neighbors, devices, console_dev, console_port, mgmt_dev, mgmt_port, port_speed_png, console_ports) = parse_png(child, hostname)
elif child.tag == str(QName(ns, "UngDec")):
(u_neighbors, u_devices, _, _, _, _, _, _) = parse_png(child, device_hostname)
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you use some local linter, you will find an error here.

[flake8] undefined name 'device_hostname' [Error]

@SuvarnaMeenakshi SuvarnaMeenakshi deleted the multiasic_minigraph branch December 14, 2020 09:28
SuvarnaMeenakshi added a commit to sonic-net/sonic-utilities that referenced this pull request Dec 6, 2021
What I did
get_port_config was modified to return different set number of arguments in PR: sonic-net/sonic-buildimage#4222. Changes in this PR is:

To address the different set of return values
To get the ports from all namespaces
To add unit-test
How I did it
Modify port2alias to read ports from all namespaces and also add unit-test

How to verify it
Test on single and multi-asic platforms.
unit-test passed.
abdosi pushed a commit to sonic-net/sonic-utilities that referenced this pull request Dec 8, 2021
What I did
get_port_config was modified to return different set number of arguments in PR: sonic-net/sonic-buildimage#4222. Changes in this PR is:

To address the different set of return values
To get the ports from all namespaces
To add unit-test
How I did it
Modify port2alias to read ports from all namespaces and also add unit-test

How to verify it
Test on single and multi-asic platforms.
unit-test passed.
SuvarnaMeenakshi added a commit to SuvarnaMeenakshi/sonic-utilities that referenced this pull request May 27, 2022
What I did
get_port_config was modified to return different set number of arguments in PR: sonic-net/sonic-buildimage#4222. Changes in this PR is:

To address the different set of return values
To get the ports from all namespaces
To add unit-test
How I did it
Modify port2alias to read ports from all namespaces and also add unit-test

How to verify it
Test on single and multi-asic platforms.
unit-test passed.

(cherry picked from commit 3714f63)
Signed-off-by: Suvarna Meenakshi <sumeenak@microsoft.com>
SuvarnaMeenakshi added a commit to sonic-net/sonic-utilities that referenced this pull request Jun 13, 2022
What I did
Cherry-pick of #1906 to 202012 branch
Fix conflict also few changes done to cherry-pick:

get_port_config function takes asic id as argument in 2019/202012 branches
Keep load_source of port2alias as module, as is used in unit-test in 202012 branch
get_port_config was modified to return different set number of arguments in PR: sonic-net/sonic-buildimage#4222. Changes in this PR is:

To address the different set of return values
To get the ports from all namespaces
To add unit-test
Additional change done over the cherry-pick:
added setup_class method in test case to load single asic mock db, this was done in pfcwd_test teardown method in 201911 and master branches. It is not done in 202012 branch, hence added setup_class method.

How I did it
Modify port2alias to read ports from all namespaces and also add unit-test

How to verify it
Verified on single and multi-asic DUTs with 202012 image.
malletvapid23 added a commit to malletvapid23/Sonic-Utility that referenced this pull request Aug 3, 2023
What I did
get_port_config was modified to return different set number of arguments in PR: sonic-net/sonic-buildimage#4222. Changes in this PR is:

To address the different set of return values
To get the ports from all namespaces
To add unit-test
How I did it
Modify port2alias to read ports from all namespaces and also add unit-test

How to verify it
Test on single and multi-asic platforms.
unit-test passed.
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.

7 participants