Closed matman26 closed 3 years ago
Hey @matman26
Branch in the linked pr should sort this. I re arranged some things so the pr is kinda big for this small fix but mostly was just organizational. If you an pull that and give it a shot and let me know if things look good I can get that merged.
I'll close this and ya can just chime in on the PR!
Thanks!
Carl
Describe the bug The diff functionality is not working properly for the last line of a given configuration input. Most precisely, line 100 of scrapli_cfg/platform/base/base_platform.py uses a join statement that doesn't properly append a \n to the last line of input.
This is an expected behaviour for the join function:
One alternative to add a trailing newline at the end of the output would be to either append a \n after the list comprehension is executed or use a format statement instead.
To Reproduce We're trying out scrapli_cfg via the nornir_scrapli plugin. Here's the basic setup:
Our Jinja2 template looks at the platform to determine which config block to apply, here's the snippet for IOSXE:
We're running our tests against an IOS XE on Cisco's Devnet Sandbox (IOS XE on CSR Recommended Code). When we try to add NTP configurations to a device which already has the same exact config on it, diff.scrapli_response.side_by_side_diff returns as if it detected a difference between the candidate config(for example, ntp server x.x.x.x) and the actual source config (ntp server x.x.x.x) as in the figure below:
This is due to the fact that even though our j2 template inserts a trailing newline, it seems to be removed the functions described under the Expect Behavior section.
Expected behavior The class method clean_config from /scrapli_cfg/platform/core/cisco_iosxe/sync_platform.py and class method _normalize_source_candidate_configs from scrapli_cfg/platform/core/cisco_iosxr/base_platform.py should return a string terminated by '\n' so that the candidate config would match loaded config during diff calculation in cfg_diff_config (otherwise the last line of the loaded config would not match the corresponding line in the source config).
OS: