ktbyers / pynet

Python for Network Engineers
Apache License 2.0
584 stars 513 forks source link

I'm runing nornir 2.0 in a bad way that I couldn't identify the issue, need help. #28

Open pravinrajPK opened 4 years ago

pravinrajPK commented 4 years ago

Hi Kirk,,

I followed your document of "Introduction to nornir' and facing the issues on nornir with windows OS.

The debugger logs :

c:\users\tkmamja.pycharmce2019.1\venv\scripts\lpthw\test\ktbyers\hey\heyhey.py(1)() -> from nornir import InitNornir (Pdb) n

c:\users\tkmamja.pycharmce2019.1\venv\scripts\lpthw\test\ktbyers\hey\heyhey.py(3)() -> nr = InitNornir() (Pdb) p nr NameError: name 'nr' is not defined (Pdb) p SyntaxError: unexpected EOF while parsing (Pdb) p nr *** NameError: name 'nr' is not defined (Pdb) n ruamel.yaml.scanner.ScannerError: mapping values are not allowed in this context in "hosts.yaml", line 2, column 5 c:\users\tkmamja.pycharmce2019.1\venv\scripts\lpthw\test\ktbyers\hey\heyhey.py(3)() -> nr = InitNornir() (Pdb) n --Return-- c:\users\tkmamja.pycharmce2019.1\venv\scripts\lpthw\test\ktbyers\hey\heyhey.py(3)()->None -> nr = InitNornir() (Pdb) n ruamel.yaml.scanner.ScannerError: mapping values are not allowed in this context in "hosts.yaml", line 2, column 5

(1)()->None (Pdb) p nr.inventory.hosts *** NameError: name 'nr' is not defined (Pdb) exit

When I ran the program I get this :

$ python heyhey.py Traceback (most recent call last): File "heyhey.py", line 5, in nr = InitNornir() File "C:\Users\TKMAMJA.PyCharmCE2019.1\venv\lib\site-packages\nornir\init_nornir.py", line 78, in InitNornir conf.inventory.options, File "C:\Users\TKMAMJA.PyCharmCE2019.1\venv\lib\site-packages\nornir\core\deserializer\inventory.py", line 129, in deserialize deserialized = cls(*args, *kwargs) File "C:\Users\TKMAMJA.PyCharmCE2019.1\venv\lib\site-packages\nornir\plugins\inventory\simple.py", line 55, in init super().init(hosts=hosts, groups=groups, defaults=defaults, args, kwargs) File "C:\Users\TKMAMJA.PyCharmCE2019.1\venv\lib\site-packages\pydantic\main.py", line 142, in init self.setstate(self._process_values(data)) File "C:\Users\TKMAMJA.PyCharmCE2019.1\venv\lib\site-packages\pydantic\main.py", line 312, in _process_values return validate_model(self, input_data) File "C:\Users\TKMAMJA.PyCharmCE2019.1\venv\lib\site-packages\pydantic\main.py", line 474, in validate_model raise ValidationError(errors) pydantic.error_wrappers.ValidationError: 4 validation errors hosts -> rtr1 -> nornir_host extra fields not permitted (type=value_error.extra) groups -> defaults -> nornir_password extra fields not permitted (type=value_error.extra) groups -> defaults -> nornir_username extra fields not permitted (type=value_error.extra) groups -> cisco_ios -> nornir_nos extra fields not permitted (type=value_error.extra)

What am I doing wrong here?????????? Could be great help.

ktbyers commented 4 years ago

Looks like your inventory format is probably wrong. You would have to post your inventory here for me to be able to help.

Obviously obfuscate anything that is confidential.

pravinrajPK commented 4 years ago

Hi Kirk,

I have the code and the nornir package in the same folder in my windows machine (windows 7 professional). I have attached the logs, groups and hosts yaml files in .txt to your review.

I'm just not sure what I'm doing wrong here.

nornir.log

groups.txt hosts.txt

ktbyers commented 4 years ago

@pravinrajgit You are using an old format of Nornir's inventory (before 2.X.X). You need to convert over to the new Nornir inventory format. See this tutorial for more details:

https://nornir.readthedocs.io/en/stable/tutorials/intro/inventory.html

pravinrajPK commented 4 years ago

Ahh I see that... Let me try that....

Kirk any comments on the attached image?

4a867f5b-738f-4e44-be4a-50380be097a3

ktbyers commented 4 years ago

I am not sure what you are trying to show me there?

Please don't include screen-shots i.e. copy-and paste is much better (as it is much easier to read and to reproduce if needed).

It still looks like your inventory format is probably incorrect.