netdevopsbr/netbox-proxbox

errors python3 manage.py migrate

Soldier2003 opened this issue · 1 comments

Netbox 3.7.7
Ubuntu 22.04.4

According to the instructions, I followed the steps:
Enter Netbox's virtual environment.
source /opt/netbox/venv/bin/activate
Install the plugin package.
(venv) $ pip install netbox-proxbox

1.2. Enable the Plugin
Enable the plugin in /opt/netbox/netbox/netbox/configuration.py:
PLUGINS = ['netbox_proxbox']
1.3. Configure Plugin

PLUGINS_CONFIG = {
    'netbox_proxbox': {
        'proxmox': [
            {
                'domain': 'alt-pve-ksp-1.seclab.local',    # May also be IP address
                'http_port': 8006,
                'user': 'root@pam',   # always required
                #'password': 'Strong@P4ssword', # only required, if you don't want to use token based authentication
                'token': {
                    'name': 'tokenID',	# Only type the token name and not the 'user@pam:tokenID' format
                    'value': 'u3RXzXnNXUy5Ft89DHmnHNjR'
                },
                'ssl': False
            }
        ],
        'netbox': {
            'domain': 'localhost',     # Ensure localhost is added to ALLOWED_HOSTS
            'http_port': 8001,     # Gunicorn port.
            'token': '27a0f91c272307711b696f8e30803ddce6ca8483',
            'ssl': False,	# There is no support to SSL on Netbox yet, so let it always False.
            'settings': {
                'virtualmachine_role_id' : 9,
                'node_role_id' : 9,
                'site_id': 1
            }
        }
    }
}

And I get an errors

(venv) $ cd /opt/netbox/netbox/
(venv) demo@netbox:/opt/netbox/netbox$ python3 manage.py migrate
Traceback (most recent call last):
  File "/opt/netbox-3.7.7/netbox/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/netbox-3.7.7/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/opt/netbox-3.7.7/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 382, in execute
    settings.INSTALLED_APPS
  File "/opt/netbox-3.7.7/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 102, in __getattr__
    self._setup(name)
  File "/opt/netbox-3.7.7/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 89, in _setup
    self._wrapped = Settings(settings_module)
  File "/opt/netbox-3.7.7/venv/lib/python3.10/site-packages/django/conf/__init__.py", line 217, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/netbox-3.7.7/netbox/netbox/settings.py", line 751, in <module>
    plugin = importlib.import_module(plugin_name)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/netbox-3.7.7/venv/lib/python3.10/site-packages/netbox_proxbox/__init__.py", line 40, in <module>
    from . import proxbox_api
  File "/opt/netbox-3.7.7/venv/lib/python3.10/site-packages/netbox_proxbox/proxbox_api/__init__.py", line 1, in <module>
    from . import (
  File "/opt/netbox-3.7.7/venv/lib/python3.10/site-packages/netbox_proxbox/proxbox_api/update.py", line 2, in <module>
    from .plugins_config import (
  File "/opt/netbox-3.7.7/venv/lib/python3.10/site-packages/netbox_proxbox/proxbox_api/plugins_config.py", line 73, in <module>
    PROXMOX = PROXMOX_SETTING.get("domain", DEFAULT_PROXMOX)
AttributeError: 'list' object has no attribute 'get'

Then I tried to change the config (/opt/netbox/netbox/netbox/configuration.py)

PLUGINS_CONFIG = {
    'netbox_proxbox': {
        'proxmox': [
            {
                'domain': 'alt-pve-ksp-1.seclab.local',    # May also be IP address
                'http_port': 8006,
                'user': 'root@pam',   # always required
                'password': 'Strong@P4ssword', # only required, if you don't want to use token based authentication
                'token': {
                    'name': 'u3RXzXnNXUy5Ft89DHmnHNjR',	# Only type the token name and not the 'user@pam:tokenID' format
                    'value': '05373035-a7ec-445e-9b72-c3dac1aa2e7f'
                },
                'ssl': False
            }
        ],
        'netbox': {
            'domain': 'localhost',     # Ensure localhost is added to ALLOWED_HOSTS
            'http_port': 8001,     # Gunicorn port.
            'token': '27a0f91c272307711b696f8e30803ddce6ca8483',
            'ssl': False,	# There is no support to SSL on Netbox yet, so let it always False.
            'settings': {
                'virtualmachine_role_id' : 9,
                'node_role_id' : 9,
                'site_id': 1
            }
        }
    }
}

But I got the same errors as the first time, then I tried to change the config (/opt/netbox/netbox/netbox/configuration.py) again

PLUGINS_CONFIG = {
    'netbox_proxbox': {
        'proxmox': [
            {
                'domain': 'alt-pve-ksp-1.seclab.local',    # May also be IP address
                'http_port': 8006,
                'user': 'root@pam',   # always required
                'password': 'Strong@P4ssword', # only required, if you don't want to use token based authentication
                'token': {
                    'name': 'u3RXzXnNXUy5Ft89DHmnHNjR',	# Only type the token name and not the 'user@pam:tokenID' format
                    'value': '05373035-a7ec-445e-9b72-c3dac1aa2e7f'
                },
                'ssl': False
            }
        ],
        'netbox': {
            'domain': 'localhost',     # Ensure localhost is added to ALLOWED_HOSTS
            'http_port': 8001,     # Gunicorn port.
            'token': '27a0f91c272307711b696f8e30803ddce6ca8483',
            'ssl': False,	# There is no support to SSL on Netbox yet, so let it always False.
            'settings': {
                'virtualmachine_role_id' : 0,
                'node_role_id' : 0,
                'site_id': 0
            }
        }
    }
}

But the result is unchanged, I get errors.

I read this post and checked, but I have everything installed.

Either there is an error somewhere, or something is copied wrong from the main instruction, but here is a working version:

PLUGINS_CONFIG = {
    'netbox_proxbox': {
        'proxmox': {
            'domain': 'proxbox.example.com',    # May also be IP address
            'http_port': 8006,
            'user': 'root@pam',   # always required
            'password': 'Strong@P4ssword', # only required, if you don't want to use token based authentication
            'token': {
                'name': 'tokenID',	# Only type the token name and not the 'user@pam:tokenID' format
                'value': '039az154-23b2-4be0-8d20-b66abc8c4686'
            },
            'ssl': False
        },
        'netbox': {
            'domain': 'localhost',     # Ensure localhost is added to ALLOWED_HOSTS
            'http_port': 8001,     # Gunicorn port.
            'token': '0dd7cddfaee3b38bbffbd2937d44c4a03f9c9d38',
            'ssl': False,	# There is no support to SSL on Netbox yet, so let it always False.
            'settings': {
                'virtualmachine_role_id' : 0,
                'node_role_id' : 0,
                'site_id': 0
            }
        }
    }
}