-
Notifications
You must be signed in to change notification settings - Fork 24k
New modules nxos_tms_global and nxos_tms_destgroup #58018
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” 8000 , 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
Conversation
@mikewiebe this PR contains more than one new module. Please submit only one new module per pull request. For a detailed explanation, please read the grouped modules documentation |
The test
The test
The test
The test
The test
The test
The test
The test
The test
The test
The test
The test
The test
The test
The test
The test
|
protocol = cmd_ref._ref['destination']['existing'][key]['protocol'].lower() | ||
encoding = cmd_ref._ref['destination']['existing'][key]['encoding'].lower() | ||
cmd_ref._ref['destination']['existing'][key]['protocol'] = protocol | ||
cmd_ref._ref['destination']['existing'][key]['encoding'] = encoding |
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.
Consider this approach instead. It's a bit more readable.
playval = cmd_ref._ref.get('destination').get('playval')
existing = cmd_ref._ref.get('destination').get('existing')
keys = ['protocol', 'encoding']
if playval:
for key in keys:
playval[key] = playval[key].lower()
if existing:
for key in keys:
existing[key] = existing[key].lower()
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 code mostly worked as is but had to modify existing to account for the fact that each existing instance has an instance index.
cmd_ref._ref['destination']['existing'][key]['protocol'] = protocol | ||
cmd_ref._ref['destination']['existing'][key]['encoding'] = encoding | ||
|
||
return cmd_ref |
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 don't think you need to return cmd_ref.
|
||
def get_aggregate_cmds(module): | ||
''' Get list of commands from aggregate parameter ''' | ||
|
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.
Nit: a little wordy. Consider:
params = module.params
if 'protocol' in k: | ||
module.params['destination']['protocol'] = v | ||
if 'encoding' in k: | ||
module.params['destination']['encoding'] = v |
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 more terse:
if 'destination' in k:
+ dest = {}
for k, v in v.items():
+ dest[k] = v
+ params['destination'] = dest
- if 'ip' in k:
- module.params['destination']['ip'] = v
- if 'port' in k:
- module.params['destination']['port'] = v
- if 'protocol' in k:
- module.params['destination']['protocol'] = v
- if 'encoding' in k:
- module.params['destination']['encoding'] = v
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.
Good refactor suggestion
cmd_ref.get_playvals() | ||
cmd_ref = normalize_data(cmd_ref) | ||
cmds = cmd_ref.get_proposed() | ||
proposed_cmds.extend(cmds) |
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'm okay with the code above, just wondering if it would be good to disambiguate the multi-instance cmd_ref
objects in this method's for loop from the single-instance cmd_ref
in main()
?
e.g. make these mi_cmd_ref
, agg_cmd_ref
, etc.
Your call.
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.
Nah.. I plan to leave it as is. It's in a separate method so I think it's clear enough and besides the cmd_ref objects in get_aggregate_cmds
are discarded and only the resulting command set is returned.
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.
👍
yup, just discombobulating the combobulated.
# Normalize interface name. | ||
int = module.params.get('destination_profile_source_interface') | ||
if int: | ||
module.params['destination_profile_source_interface'] = normalize_interface(int) |
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.
Or just:
int = module.params.get('destination_profile_source_interface')
module.params['destination_profile_source_interface'] = normalize_interface(int)
It's a nit. Keep it if you want.
@@ -0,0 +1,3 @@ | |||
dependencies: | |||
# Uncomment in the future if needed. | |||
# - prepare_nxos_tests |
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 skip prepare_nxos_tests
?
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.
We don't explicitly need it right now and it just adds runtime. That will likely change in the future if/when we add additional nxos platform support but decided to save the time for now.
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.
👍
@@ -0,0 +1,3 @@ | |||
dependencies: | |||
# Uncomment in the future if needed. | |||
# - prepare_nxos_tests |
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.
ditto
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.
ditto
# Assumes feature telemetry is disabled | ||
# TMS global config is not present. | ||
# Configure only vrf | ||
module_name = self.module.__name__.rsplit('.', 1)[1] |
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.
module_name
isn't used anywhere else. Remove?
274295f
to
c841370
Compare
1f727c7
to
b815f5e
Compare
The test
The test
The test
The test
The test
The test
|
The test
The test
The test
The test
The test
The test
The test
The test
The test
|
The test
The test
The test
The test
|
@trishnaguha This one is ready for review and merge. @chrisvanheuveln Reviewed it and I finished addressing all of his comments. |
shipit |
Closing. Redundant with #59126 |
SUMMARY
CmdRef
.ISSUE TYPE
COMPONENT NAME
nxos_tms_global
nxos_tms_destgroup
TESTING INFORMATION
This PR includes both unit and integration tests. Tests have been run against N9k.
A future PR will include support for other NX-OS platforms.