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

nornir_nos filter not working as expected #595

Closed
achhabr1 opened this issue Sep 25, 2020 · 7 comments
Closed

nornir_nos filter not working as expected #595

achhabr1 opened this issue Sep 25, 2020 · 7 comments

Comments

@achhabr1
Copy link

achhabr1 commented Sep 25, 2020

Hi

I am trying to us the inventory filter examples in the documentation. Somehow i am not able to make nornir_nos filter work the way its expected.

hosts.yaml

---
ptr74-ptr3:
    hostname: ptr74-jdm
    username: root
    password: xxxxx
    groups:
        - porter3
    data:
        deviceowner: ankit
        devicemodel: nfx250-s2

groups.yaml

---
porter3:
  port: 22
  platform: junos

Seeing this

>>> nr = InitNornir(config_file="config.yaml")
>>> print(nr.inventory.hosts)
{'ptr74-ptr3': Host: ptr74-ptr3}
>>> junos = nr.filter(F(nornir_nos="junos")) 
>>> print(junos.inventory.hosts)
{}
>>
>
@ktbyers
Copy link
Collaborator

ktbyers commented Sep 25, 2020

nornir_nos was changed to platform on the Nornir 1.x to Nornir 2.x transition.

Your filter should be similar to the following:

ipdb> nr.inventory.hosts
{'cisco3': Host: cisco3, 'cisco4': Host: cisco4, 'nxos1': Host: nxos1, 'nxos2': Host: nxos2, 'arista1': Host: arista1, 'arista2': Host: arista2, 'arista3': Host: arista3, 'arista4': Host: arista4, 'srx2': Host: srx2}
ipdb> nr.filter(platform="junos")
<nornir.core.Nornir object at 0x7f98a2708bd0>
ipdb> j1 = nr.filter(platform="junos")
ipdb> j1.inventory.hosts
{'srx2': Host: srx2}

@ktbyers ktbyers closed this as completed Sep 25, 2020
@achhabr1
Copy link
Author

Hi Kirk,

Thanks for promptly replying. Would you be able to help, to fix the documentation. It still points to use nornir_nos instead of platform.

@ktbyers
Copy link
Collaborator

ktbyers commented Sep 26, 2020

Can you show me where?

@achhabr1
Copy link
Author

Hi Kirk

It's in the inventory advance filter section. image

Hope this helps.

Thanks
Ankit

@ktbyers
Copy link
Collaborator

ktbyers commented Sep 27, 2020 via email

@ktbyers
Copy link
Collaborator

ktbyers commented Sep 27, 2020 via email

@achhabr1
Copy link
Author

https://nornir.readthedocs.io/en/latest/tutorial/inventory.html

Thanks

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

No branches or pull requests

2 participants