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
Handling of configurations blocks with end-* at the end of the block #39673
Conversation
@gdpak this PR contains the following merge commits: Please rebase your branch to remove these commits. |
Worth adding unit tests for this? |
@@ -290,6 +290,9 @@ def _diff_line(self, other): | |||
for item in self.items: | |||
if item not in other: | |||
updates.append(item) | |||
# special trailing parents need to be included in diff | |||
elif item.line == 'end-policy' or item.line == 'end-set': |
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.
It seems this configuration is specific for a particular platform. Is it possible to sanitize the config indentation in the module code?
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.
right now there is no platform specific instance of NetworkConfig. It can be done to inherit this class at iosxr code and overwrite function 'difference' and 'diff_exact' to handle these special commands. will that work ?
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.
pros of above approach: no extra check penalty for other OS, no regression on other
con: code duplication and fixes in common code would need to be ported
Integration tests: ansible-test network-integration --inventory /tmp/inventory_deepak iosxr_config --testcase misplaced_sublevel -vvvv TASK [iosxr_config : debug] ********************************************************************************************************************** PLAY RECAP *************************************************************************************************************************************** |
The test
|
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.
lgtm
…nsible#39673) * handle end-policy issue * revert changes in iosxr cliconf * fix trailing parents not included in difference * Moving fix to platform specific fix * pep 8 issues (cherry picked from commit ef577b7)
…39843) * Handling of configurations blocks with end-* at the end of the block (#39673) * handle end-policy issue * revert changes in iosxr cliconf * fix trailing parents not included in difference * Moving fix to platform specific fix * pep 8 issues (cherry picked from commit ef577b7) * changelog entry
…nsible#39673) * handle end-policy issue * revert changes in iosxr cliconf * fix trailing parents not included in difference * Moving fix to platform specific fix * pep 8 issues
…nsible#39673) * handle end-policy issue * revert changes in iosxr cliconf * fix trailing parents not included in difference * Moving fix to platform specific fix * pep 8 issues
…nsible#39673) * handle end-policy issue * revert changes in iosxr cliconf * fix trailing parents not included in difference * Moving fix to platform specific fix * pep 8 issues
…nsible#39673) * handle end-policy issue * revert changes in iosxr cliconf * fix trailing parents not included in difference * Moving fix to platform specific fix * pep 8 issues
…nsible#39673) * handle end-policy issue * revert changes in iosxr cliconf * fix trailing parents not included in difference * Moving fix to platform specific fix * pep 8 issues
…nsible#39673) * handle end-policy issue * revert changes in iosxr cliconf * fix trailing parents not included in difference * Moving fix to platform specific fix * pep 8 issues
…nsible#39673) * handle end-policy issue * revert changes in iosxr cliconf * fix trailing parents not included in difference * Moving fix to platform specific fix * pep 8 issues
SUMMARY
Fixes #39351
Few commands like route-policy and prefix-set have end-policy/end-set at the end of the block
e.g.
prefix-set ebpg_filter
192.168.0.0/16 ge 17 le 30
end-set
here current parser logic sets parent for line '192.168.0.0/16 ge 17 le 30' as 'prefix-set ebpg_filter'. It
also marks 'end-set' as new parent with no children.
Now say when we have a diff between candidate and running-config. we try to just play above config block without 'end-set' . This will cause all configs to fail below this line as command prompts will not accept any command until we come-out of this prefix-set context.
Solutions approach:
1 approach is clean but much more intrusive in common code of parsing. Right now I have implemented and tested approach 2) we can discuss if there is alternative better approach
ISSUE TYPE
COMPONENT NAME
lib/ansible/module_utils/network/common/config.py
ANSIBLE VERSION
2.6