0

我想为netbox开发一个插件。我在我的机器上安装了 netbox,现在我必须安装插件,该插件目前非常空白(类似于 netbox 文档中的那个)。有关如何安装插件或开发插件的基本信息,您可以查看 netbox 文档。我面临的问题是当我尝试启动 netbox 服务器时,它找不到配置文件中列出的插件。

首先我安装了插件

(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

之后,我从 Netbox 文件中将名称添加到 configuration.py

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

作为响应,当我尝试启动服务器时收到以下消息

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.

我使用的 venv 是我打开 netbox 目录时 Pycharm 创建的。我希望你们中的某个人可以帮助我解决这个问题。如果您需要更多信息,请添加评论。

4

1 回答 1

0

问题是由于目录命名不正确。这是正确命名的 netbox 插件目录的示例:

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

在我的情况下,具有名称的目录具有plugin_name不同的名称。一个是正​​确的名字,另一个有一个不同的名字。例如 1.: plugin_name2.:plugin-name

于 2021-02-05T09:33:30.637 回答