Skip to content
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

Two-Way List Diffing w/ Key #191

Open
ghost opened this issue Nov 16, 2016 · 3 comments
Open

Two-Way List Diffing w/ Key #191

ghost opened this issue Nov 16, 2016 · 3 comments

Comments

@ghost
Copy link

ghost commented Nov 16, 2016

ref #167

I've been trying to figure out this for show bgp neighbors pre/post list diffing

Two-Way List Diffing Required

  • Unique key between lists: /bgp-information/bgp-peer/peer-id:text()
  • Post[] shall have all the peers as seen in Pre[] in Established state
  • Post[] shall not have any new peers compared to Pre[]

Difficulty arises from two-way diffing dynamic lists I see no way of doing..

@vnitinv @ydnath

My guess so far is something like this having to use template and XPath to cross-match[]:

test_command_bgp:
  - command: show bgp neighbor
{% for BpeerID in how-to-get-BpeerIDs? %}
  - iterate:
      xpath: '/bgp-information/bgp-peer/[peer-id:text()={{BpeerID}]'
      tests:
        - exists       # element in which test is performed
          err: "Test Failed!! peer-address got changed, it is now <{{post['peer-address']}}>"
          info: "Test succeeded!! peer-address is equal to <{{post['peer-address']}}>"

The above would need to have another list context from B-perspective so all the added peers could be found

Is this something I need to write a module for? I am new sorry :)

Cheers

@ydnath
Copy link
Member

ydnath commented Nov 16, 2016

@titusfoo The module approach would definitely give you more control as you can build contexts within your code.

@ghost
Copy link
Author

ghost commented Nov 17, 2016

@ydnath Two-Way list diff is pretty common use-case for many audit scenarios e.g. pre/post migrations to make sure all the same pre peers came up on post. Can we flag this as enhancement if nothing on base functionality yet?

@ydnath
Copy link
Member

ydnath commented Nov 17, 2016

@titusfoo We will evaluate this and check if a generic two-way diff can be implemented. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant