nornir-automation / nornir

Pluggable multi-threaded framework with inventory management to help operate collections of devices
https://nornir.readthedocs.io/
Apache License 2.0
1.38k stars 234 forks source link

plugin 'NetBoxInventory2' is not registered #784

Closed rickdonato closed 2 years ago

rickdonato commented 2 years ago

Im running a script using the NetBoxInventory2 plugin. However I get:

❯ /bin/python3 /mnt/c/Users/rick/nornir-course/003_inventory/003_dynamic/nr_print_inventory.py
Traceback (most recent call last):
  File "/mnt/c/Users/rick/nornir-course/003_inventory/003_dynamic/nr_print_inventory.py", line 6, in <module>
    nr = nornir_setup()
  File "/mnt/c/Users/rick/nornir-course/003_inventory/003_dynamic/nr_setup.py", line 17, in nornir_setup
    nr = InitNornir(config_file=NORNIR_CONFIG_FILE)
  File "/home/rick/.local/lib/python3.8/site-packages/nornir/init_nornir.py", line 64, in InitNornir
    inventory=load_inventory(config),
  File "/home/rick/.local/lib/python3.8/site-packages/nornir/init_nornir.py", line 17, in load_inventory
    inventory_plugin = InventoryPluginRegister.get_plugin(config.inventory.plugin)
  File "/home/rick/.local/lib/python3.8/site-packages/nornir/core/plugins/register.py", line 75, in get_plugin
    raise PluginNotRegistered(f"plugin {name!r} is not registered")
nornir.core.exceptions.PluginNotRegistered: plugin 'NetBoxInventory2' is not registered

Looking through other threads/issues it seems to be that this plugin self registers. Just to confirm it is installed:

❯ poetry show nornir-netbox
/home/rick/.cache/pypoetry/virtualenvs/nornir-course-iatnHwlm-py3.8/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
name         : nornir-netbox
version      : 0.3.0
description  : Netbox plugin for Nornir

dependencies
 - nornir >=3,<4
 - requests >=2.23.0,<3.0.0

The strange thing is I have another project on my box using this and it is working fine, which is using the same pyproject and lock file. Thanks in advance...

dbarrosop commented 2 years ago

I'd suggest you start by deleting the environment and creating a new one, specially if you say there is another project of yours with the same dependencies that work.

rickdonato commented 2 years ago

Thanks. Yep I tried this. Apologies should of mentioned this. Still the same. Can you point me to where the plugin registration occurs etc. As might be able to figure it out myself. Thanks.

ubaumann commented 2 years ago

You should find the information about the "auto registration" here: https://nornir.readthedocs.io/en/latest/plugins/index.html#registering-plugins

It is using an entry point.

How do you install it? Pip? As a workaround you can also register it in your code

rickdonato commented 2 years ago

Thanks for your help. This was fortunately/unfortunately a layer8 issue (facepalm). Seem by VSCode suddenly dropped my interpreter and was using the local python. Apologies. But appreciate the responses.