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

[DON'T MERGE] - Add VRF structure in for get_interfaces_ip #819

Closed
wants to merge 8 commits into from

Conversation

ktbyers
Copy link
Contributor

@ktbyers ktbyers commented Sep 23, 2018

Add VRF structure for get_interfaces_ip

@ktbyers
Copy link
Contributor Author

ktbyers commented Sep 23, 2018

Replaces #815

@ktbyers
Copy link
Contributor Author

ktbyers commented Sep 23, 2018

Related to:

#792

@ktbyers
Copy link
Contributor Author

ktbyers commented Sep 23, 2018

Items that are needed (at least longer term):

  • unit tests
  • getters table updated to indicate vrf support
  • make sure napalm-validate works properly with getter
  • make sure napalm-ansible works with getter
  • make sure no issues with Salt.

@ktbyers
Copy link
Contributor Author

ktbyers commented Sep 23, 2018

@FloLaco Can you provide more details on what the issue with napalm validate is?

@coveralls
Copy link

coveralls commented Sep 23, 2018

Coverage Status

Coverage remained the same at 0.0% when pulling dcfbb83 on vrf_get_interface_ip into dd68b7f on develop.

@FloLaco
Copy link
Contributor

FloLaco commented Sep 23, 2018

The issue is how to provide the vrf argument in the validation file ?

@ktbyers
Copy link
Contributor Author

ktbyers commented Sep 24, 2018

I think you should be able to do:

    _kwargs:
      vrf: whatever

We will need to verify this though.

@ktbyers
Copy link
Contributor Author

ktbyers commented Oct 2, 2018

@bewing Any chance of reviewing this? Thanks.

@FloLaco
Copy link
Contributor

FloLaco commented Oct 8, 2018

I think you should be able to do:

    _kwargs:
      vrf: whatever

We will need to verify this though.

@ktbyers I tried to add kwargs in 2 places but it does not work.
Maybe I did something wrong ...

    napalm_validate:
      validation_file: "{{ val_dir }}/validate-nxos_{{ site }}.yml"
      [...]
      kwargs:
        - vrf: all

or

- get_ospf_neighbors:
    kwargs:
      - vrf: all
    UNDERLAY:
      global:
        peers:
         10.55.0.1: {}
         10.55.0.3: {}

I also tried _kwargs

@ktbyers ktbyers changed the title Add VRF structure in for get_interfaces_ip [DON'T MERGE] - Add VRF structure in for get_interfaces_ip Oct 8, 2018
@ktbyers
Copy link
Contributor Author

ktbyers commented Oct 8, 2018

Put on hold as we are probably going to solve this slightly differently.

@ktbyers
Copy link
Contributor Author

ktbyers commented Oct 8, 2018

@FloLaco It should be _kwargs.

Why are you making it a list?

    kwargs:
      - vrf: all

I think it should be:

    _kwargs:
         vrf: whatever

@FloLaco
Copy link
Contributor

FloLaco commented Oct 8, 2018

@FloLaco It should be _kwargs.

Why are you making it a list?

    kwargs:
      - vrf: all

I think it should be:

    _kwargs:
         vrf: whatever

@ktbyers
I also tried it but it didn't work.
Confirm me, I need to put this in my validation_file like I did on my 2nd example

@ktbyers
Copy link
Contributor Author

ktbyers commented Oct 8, 2018

@FloLaco I am pretty much going from this example (and I had checked the source code last week for a different issue). See the 'ping' example.

https://napalm.readthedocs.io/en/latest/validate/

Yes, in your validation file. Here is the relevant area of the source code:

https://github.com/napalm-automation/napalm/blob/develop/napalm/base/validate.py#L192

Note, this would be a separate issue so if there is a problem here you should open a separate issue on it.

@FloLaco
Copy link
Contributor

FloLaco commented Oct 8, 2018

@ktbyers Thanks for the links. Ok so it should work like you said. I'll try again tomorrow and will open a new issue if it's still not working.
Thanks

@ktbyers
Copy link
Contributor Author

ktbyers commented Oct 8, 2018

Yes, sounds good. I haven't tested it so if there is an issue there...just let us know.

@FloLaco
Copy link
Contributor

FloLaco commented Oct 9, 2018

@ktbyers I've tested and it works.. noob error, I've edited the wrong validation_file ...

@mirceaulinic mirceaulinic added this to the 2.4.0 milestone Oct 25, 2018
jobec added a commit to jobec/napalm that referenced this pull request Dec 3, 2018
@jobec
Copy link
Contributor

jobec commented Dec 3, 2018

For nxos_ssh the below patch should work.
We're using it internally in a custom nxoss_ssh driver.

--- a/napalm/nxos_ssh/nxos_ssh.py
+++ b/napalm/nxos_ssh/nxos_ssh.py
@@ -889,7 +889,7 @@ class NXOSSSHDriver(NXOSDriverBase):
         output = self._send_command(command) # noqa
         return ntp_stats

-    def get_interfaces_ip(self):
+    def get_interfaces_ip(self, vrf=""):
         """
         Get interface IP details. Returns a dictionary of dictionaries.

@@ -920,8 +920,8 @@ class NXOSSSHDriver(NXOSDriverBase):
         }
         """
         interfaces_ip = {}
-        ipv4_command = 'show ip interface vrf default'
-        ipv6_command = 'show ipv6 interface vrf default'
+        ipv4_command = 'show ip interface vrf {}'.format(vrf or "default")
+        ipv6_command = 'show ipv6 interface vrf {}'.format(vrf or "default")
         output_v4 = self._send_command(ipv4_command)
         output_v6 = self._send_command(ipv6_command)

@jobec
Copy link
Contributor

jobec commented Dec 7, 2018

I've implemented the above patch in PR #877

@jobec
Copy link
Contributor

jobec commented Dec 7, 2018

@ktbyers

From base.py:

'vrf' of null-string will default to the global or default VRF. 'vrf' of 'all' will
return the interface IPs for all VRFs. 'vrf' referring to a specific VRF will return
the interface IPs of that specific VRF. In all cases the same data structure is returned
and no reference to the VRF that was used is included in the output.

I would vote to turn this around and make the default to show from all VRFs. E.g. vrf='' equals vrf=all``.
Because:

  • It looks like this is already the case for all platforms except for nxos.
  • People expect to see everything by default, instead of only a subset on some platforms and all on others.
  • It would mean quite some juggling to turn it around for other platforms (e.g. show only global or default VRFs).

@ktbyers
Copy link
Contributor Author

ktbyers commented Dec 7, 2018

@jobec Let me review the past history on this issue a bit.

On the face of it that all sounds reasonable as my main concern regarding using 'all' related to backwards compatibility.

jobec added a commit to jobec/napalm that referenced this pull request Dec 17, 2018
jobec added a commit to jobec/napalm that referenced this pull request Dec 20, 2018
@mirceaulinic mirceaulinic removed this from the 2.4.0 milestone Sep 25, 2019
mirceaulinic and others added 4 commits April 14, 2020 11:03
* Add testcase for get_interfaces_ip with VRF

* Update eos.get_interfaces_ip to support VRF

* Update docs method alias for new test

Co-authored-by: Mircea Ulinic <mirceaulinic@users.noreply.github.com>
@ktbyers
Copy link
Contributor Author

ktbyers commented Jul 7, 2020

This is not being actively worked on any longer so I am going to close it.

@ktbyers ktbyers closed this Jul 7, 2020
@mirceaulinic mirceaulinic deleted the vrf_get_interface_ip branch July 7, 2020 13:49
@mirceaulinic mirceaulinic restored the vrf_get_interface_ip branch July 7, 2020 13:49
@mirceaulinic mirceaulinic deleted the vrf_get_interface_ip branch May 4, 2021 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants