pythondjangonetbox

NetBox plugin installation for development


I want do develop a plugin for netbox. I installed netbox on my machine and now I have to install the plugin, which is pretty blank at the moment(similar to the one from the netbox docs). For Basic information on how to install a plugin or develop one you can look at the netbox documentation. The Problem that I#m facing is when I try to start the netbox server it doesn't find the Plugin which is listed in the config file.

First I installed the plugin

(venv) i518240@ubuntu:~/projects/netbox_dashboard$ python setup.py develop
running develop
running egg_info
creating ccloud_netbox_dashboard_plugin.egg-info
writing ccloud_netbox_dashboard_plugin.egg-info/PKG-INFO
writing dependency_links to ccloud_netbox_dashboard_plugin.egg-info/dependency_links.txt
writing top-level names to ccloud_netbox_dashboard_plugin.egg-info/top_level.txt
writing manifest file 'ccloud_netbox_dashboard_plugin.egg-info/SOURCES.txt'
reading manifest file 'ccloud_netbox_dashboard_plugin.egg-info/SOURCES.txt'
writing manifest file 'ccloud_netbox_dashboard_plugin.egg-info/SOURCES.txt'
running build_ext
Creating /home/i518240/projects/netbox/venv/lib/python3.8/site-packages/ccloud-netbox-dashboard-plugin.egg-link (link to .)
Adding ccloud-netbox-dashboard-plugin 0.1 to easy-install.pth file

Installed /home/i518240/projects/netbox_dashboard
Processing dependencies for ccloud-netbox-dashboard-plugin==0.1
Finished processing dependencies for ccloud-netbox-dashboard-plugin==0.1

after that I added the name to the configuration.py from the Netbox files

# Enable installed plugins. Add the name of each plugin to the list.
PLUGINS = [
    'ccloud-netbox-dashboard-plugin',
           ]

As respones, I get the following message when I try to start the server

django.core.exceptions.ImproperlyConfigured: Unable to import plugin ccloud-netbox-dashboard-plugin: Module not found. Check that the plugin module has been installed within the correct Python environment.

The venv I used was the one created by Pycharm when I opened the netbox directory. I hope someone of you can help me with this problem. If you need further information just add comment.


Solution

  • The problem was due to an incorrect naming of the directories. Here is an example of an correctly named netbox plugin directory:

    plugin_name/
      - plugin_name/
        - templates/
          - plugin_name/
            - *.html
        - __init__.py
        - middleware.py
        - navigation.py
        - signals.py
        - template_content.py
        - urls.py
        - views.py
      - README
      - setup.py
    

    In my case the directories which have the name plugin_name had diffrent names. One was correctly name the other one had a slitly diffrent name. For example 1.:plugin_name 2.: plugin-name