-
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
[macsec] Parse masec_enabled and macsec_profile from minigraph #10917
Conversation
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.
Please add unit tests for these ?
Added unit tests, but there are some validation failures which needs to be further discussed. Do we need macsec-profile yang checks enforced here, as we are not populating macsec_profile table contents from minigraph.
|
2b75155
to
ae13892
Compare
This pull request introduces 2 alerts when merging ae13892565ba8d5c710d42000e0ac3635ace61fd into 201792f - view on LGTM.com new alerts:
|
This issue is fixed by updating the testcases. It is passing now. |
@judyjoseph, LGTM. We will add tests for |
src/sonic-config-engine/minigraph.py
Outdated
return linkmetas | ||
|
||
def parse_macsec_profile(val_string): | ||
macsec_profile = {} | ||
values = val_string.strip().split(' ') |
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 parsing logic is too strict and not easy to read/extend. Could you explore libraries like https://docs.python.org/3/library/configparser.html?
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.
@Qi I am finding this config parser library used when we have to read from an input file and while parsing it has restrictions like need to have [SECTION] header etc - which I feel is not applicable here.
I checked the following, and the current parsing should take care of them.
the macsec profile name cannot be with spaces
the profile will have PrimaryKey and FallbackKey.
@@ -73,6 +73,9 @@ def validate(self, argument): | |||
cmd += ' -p ' + args.port_config | |||
if args.namespace is not None: | |||
cmd += ' -n ' + args.namespace | |||
if "-j " in argument: |
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.
Updated to use args itself.
@@ -73,6 +73,9 @@ def validate(self, argument): | |||
cmd += ' -p ' + args.port_config | |||
if args.namespace is not None: | |||
cmd += ' -n ' + args.namespace | |||
if "-j " in argument: | |||
strs = argument.split(' ') | |||
cmd += " -j {}".format(next(strs[i+1] for i in range(len(strs)) if strs[i]=='-j')) |
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.
Updated to use args itself.
7965f02
to
ea6dadd
Compare
yes, I will raise a separate PR for packet-chassis as the sample xml/portconfig.ini needs to be modified a bit which I will confirm, thanks. |
* Updates needed to parse the macsec config from minigraph * Add unit tests in tests/test_cfggen.py::TestCfgGen, and updates
…-net#10917) * Updates needed to parse the macsec config from minigraph * Add unit tests in tests/test_cfggen.py::TestCfgGen, and updates
Why I did it
In the Minigraph the following details are present for macsec configuration
Added the following
The macsec_profile eg: as below will be pushed into the device as a json file and loaded into the config DB's using "config load command"
How I did it
Added parsing logic in minigraph.py
How to verify it
Verified by generating config_db.json in a multi-asic device.
Which release branch to backport (provide reason below if selected)
Description for the changelog
Link to config_db schema for YANG module changes
A picture of a cute animal (not mandatory but encouraged)