-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Parser changes to support parsing of multi-asic device minigraph #4222
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
Conversation
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.
added in port table only if it is present in port_config.ini.
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <[email protected]>
need unit test on the sonic-cfggen part to parse multi-asic minigraph. |
num_npus = token[1].strip() | ||
return num_npus | ||
|
||
def get_namespaces(): |
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 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?
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.
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 <[email protected]>
This pull request introduces 1 alert when merging d4fe8e0 into 2a59551 - view on LGTM.com new alerts:
|
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <[email protected]>
Added Unit test for parsing multi-npu minigraph. |
retest this please |
src/sonic-config-engine/sonic-cfggen
Outdated
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) |
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.
why do you need specify /etc/sonic/minigraph.xml, it is in line 196.
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 is needed when the sonic-cfggen command is executed without -m option.
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.
Should we show error in this case?
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.
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.
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 think In this case you need to use option --minigraph= and provide the required minigraph
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.
Changed to use the minigraph only when --minigraph option is provided.
src/sonic-config-engine/tests/multi_npu_data/sample_port_config-1.ini
Outdated
Show resolved
Hide resolved
can you resolve conflict? |
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <[email protected]>
…_changes Signed-off-by: SuvarnaMeenakshi <[email protected]>
resolved conflicts. |
This pull request fixes 1 alert when merging 9c9f8c2 into 695652c - view on LGTM.com fixed alerts:
|
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.
As comments. I'll check minigraph part later
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\']') |
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.
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.
changed in latest commit
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'}}") |
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.
assertDictEqual
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.
changed in latest commit
src/sonic-config-engine/sonic-cfggen
Outdated
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) |
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.
Should we show error in this case?
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <[email protected]>
This pull request introduces 1 alert and fixes 1 when merging 5b6892e into 744d33d - view on LGTM.com new alerts:
fixed alerts:
|
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <[email protected]>
This pull request introduces 1 alert and fixes 1 when merging 78a2bf7 into d8b7166 - view on LGTM.com new alerts:
fixed alerts:
|
concise and readable. Signed-off-by: SuvarnaMeenakshi <[email protected]>
Signed-off-by: SuvarnaMeenakshi <[email protected]>
…ic-buildimage into comment_fix
This pull request fixes 1 alert when merging 110d1b8 into c55603f - view on LGTM.com fixed alerts:
|
Signed-off-by: SuvarnaMeenakshi <[email protected]>
This pull request fixes 1 alert when merging 247370b into c55603f - view on LGTM.com fixed alerts:
|
src/sonic-config-engine/minigraph.py
Outdated
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) |
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.
remove
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 as per comment
Signed-off-by: SuvarnaMeenakshi <[email protected]>
retest vsimage please |
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <[email protected]>
This pull request fixes 1 alert when merging 06983e4 into 30bbbbf - view on LGTM.com fixed alerts:
|
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <[email protected]>
This pull request fixes 1 alert when merging 17a0d04 into 30bbbbf - view on LGTM.com fixed alerts:
|
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.
…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 <[email protected]> Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <[email protected]>
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) |
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.
If you use some local linter, you will find an error here.
[flake8] undefined name 'device_hostname' [Error]
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.
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.
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 <[email protected]>
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.
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.
- 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
- 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)