ICTU / netbox_slm

Netbox Software Lifecycle Management Extension
Other
36 stars 7 forks source link

Cannot install on 3.6.4 #33

Closed xonacs closed 11 months ago

xonacs commented 1 year ago

Is it compatible with latest netbox?

MartVisser commented 1 year ago

@xonacs What problems are you running into with Netbox version 3.6.4?

The latest version we (successfully) tested the plugin on is Netbox version 3.6.3.

GoldyXXD commented 12 months ago

I'm also having issues installing it on 3.6.4

After putting netbox_slm in the plug-ins section in configuration.py and netbox-slm in the local_requirements.txt file I then run the upgade.py script and I get the following

Installing collected packages: pyserial, yamlordereddictloader, ttp, transitions, pyparsing, pyeapi, pyasn1-modules, netutils, netbox-slm, lxml, future, bcrypt, ttp-templates, textfsm, python-ldap, pynacl, paramiko, ntc-templates, django-storages, django-auth-ldap, scp, ncclient, netmiko, junos-eznc, napalm
Successfully installed bcrypt-4.0.1 django-auth-ldap-4.6.0 django-storages-1.14.2 future-0.18.3 junos-eznc-2.6.8 lxml-4.9.3 napalm-4.1.0 ncclient-0.6.13 netbox-slm-1.2 netmiko-4.3.0 netutils-1.6.0 ntc-templates-4.0.1 paramiko-3.3.1 pyasn1-modules-0.3.0 pyeapi-1.0.2 pynacl-1.5.0 pyparsing-3.1.1 pyserial-3.5 python-ldap-3.4.4 scp-0.14.5 textfsm-1.1.3 transitions-0.9.0 ttp-0.9.5 ttp-templates-0.3.5 yamlordereddictloader-0.4.2
Applying database migrations (python3 netbox/manage.py migrate)...
Traceback (most recent call last):
  File "netbox/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/netbox-3.6.4/venv/lib64/python3.8/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/opt/netbox-3.6.4/venv/lib64/python3.8/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/netbox-3.6.4/venv/lib64/python3.8/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/netbox-3.6.4/venv/lib64/python3.8/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
  File "/opt/netbox-3.6.4/venv/lib64/python3.8/site-packages/django/core/management/base.py", line 106, in wrapper
    res = handle_func(*args, **kwargs)
  File "/opt/netbox-3.6.4/venv/lib64/python3.8/site-packages/django/core/management/commands/migrate.py", line 100, in handle
    self.check(databases=[database])
  File "/opt/netbox-3.6.4/venv/lib64/python3.8/site-packages/django/core/management/base.py", line 485, in check
    all_issues = checks.run_checks(
  File "/opt/netbox-3.6.4/venv/lib64/python3.8/site-packages/django/core/checks/registry.py", line 88, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "/opt/netbox-3.6.4/venv/lib64/python3.8/site-packages/django/core/checks/urls.py", line 14, in check_url_config
    return check_resolver(resolver)
  File "/opt/netbox-3.6.4/venv/lib64/python3.8/site-packages/django/core/checks/urls.py", line 24, in check_resolver
    return check_method()
  File "/opt/netbox-3.6.4/venv/lib64/python3.8/site-packages/django/urls/resolvers.py", line 494, in check
    for pattern in self.url_patterns:
  File "/opt/netbox-3.6.4/venv/lib64/python3.8/site-packages/django/utils/functional.py", line 57, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/opt/netbox-3.6.4/venv/lib64/python3.8/site-packages/django/urls/resolvers.py", line 715, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/opt/netbox-3.6.4/venv/lib64/python3.8/site-packages/django/utils/functional.py", line 57, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/opt/netbox-3.6.4/venv/lib64/python3.8/site-packages/django/urls/resolvers.py", line 708, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib64/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/opt/netbox-3.6.4/netbox/netbox/urls.py", line 9, in <module>
    from extras.plugins.urls import plugin_admin_patterns, plugin_patterns, plugin_api_patterns
  File "/opt/netbox-3.6.4/netbox/extras/plugins/urls.py", line 31, in <module>
    urlpatterns = import_string(f"{plugin_path}.urls.urlpatterns")
  File "/opt/netbox-3.6.4/venv/lib64/python3.8/site-packages/django/utils/module_loading.py", line 30, in import_string
    return cached_import(module_path, class_name)
  File "/opt/netbox-3.6.4/venv/lib64/python3.8/site-packages/django/utils/module_loading.py", line 15, in cached_import
    module = import_module(module_path)
  File "/usr/lib64/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/opt/netbox-3.6.4/venv/lib64/python3.8/site-packages/netbox_slm/urls.py", line 4, in <module>
    from netbox_slm import views
  File "/opt/netbox-3.6.4/venv/lib64/python3.8/site-packages/netbox_slm/views.py", line 3, in <module>
    from netbox_slm import forms
  File "/opt/netbox-3.6.4/venv/lib64/python3.8/site-packages/netbox_slm/forms.py", line 6, in <module>
    from netbox.forms import (
ImportError: cannot import name 'NetBoxModelCSVForm' from 'netbox.forms' (/opt/netbox-3.6.4/netbox/netbox/forms/__init__.py)
wkoot commented 12 months ago

The NetBoxModelCSVForm is no longer used in the latest version, but your output suggests you've got version 1.2 instead of 1.5.1

GoldyXXD commented 11 months ago

The NetBoxModelCSVForm is no longer used in the latest version, but your output suggests you've got version 1.2 instead of 1.5.1

@wkoot It looks like pip is only showing 1.2 as available.

image

GoldyXXD commented 11 months ago

I forgot to mention that i'm running this instance on RockyLinux and not using Docker.

I just figured out how to specify a github url so I could get it to pull the latest, as pip seemed to be pulling 1.2 from an older repo it has somewhere. This can be done by specifying the github url in the requirements.txt config file like this: netbox-slm @ git+https://github.com/ICTU/netbox_slm I've yet to find how to specify the exact version using the release tags so it just grabs the latest.

Also this plugin requires Python3.9 so I also had to upgrade to that from 3.8

Now i'm getting a another error during the DB migration

Applying database migrations (python3 netbox/manage.py migrate)...
Traceback (most recent call last):
  File "/opt/netbox-3.6.4/netbox/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/netbox-3.6.4/venv/lib64/python3.9/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/opt/netbox-3.6.4/venv/lib64/python3.9/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/netbox-3.6.4/venv/lib64/python3.9/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/netbox-3.6.4/venv/lib64/python3.9/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
  File "/opt/netbox-3.6.4/venv/lib64/python3.9/site-packages/django/core/management/base.py", line 106, in wrapper
    res = handle_func(*args, **kwargs)
  File "/opt/netbox-3.6.4/venv/lib64/python3.9/site-packages/django/core/management/commands/migrate.py", line 100, in handle
    self.check(databases=[database])
  File "/opt/netbox-3.6.4/venv/lib64/python3.9/site-packages/django/core/management/base.py", line 485, in check
    all_issues = checks.run_checks(
  File "/opt/netbox-3.6.4/venv/lib64/python3.9/site-packages/django/core/checks/registry.py", line 88, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "/opt/netbox-3.6.4/venv/lib64/python3.9/site-packages/django/core/checks/urls.py", line 42, in check_url_namespaces_unique
    all_namespaces = _load_all_namespaces(resolver)
  File "/opt/netbox-3.6.4/venv/lib64/python3.9/site-packages/django/core/checks/urls.py", line 61, in _load_all_namespaces
    url_patterns = getattr(resolver, "url_patterns", [])
  File "/opt/netbox-3.6.4/venv/lib64/python3.9/site-packages/django/utils/functional.py", line 57, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/opt/netbox-3.6.4/venv/lib64/python3.9/site-packages/django/urls/resolvers.py", line 715, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/opt/netbox-3.6.4/venv/lib64/python3.9/site-packages/django/utils/functional.py", line 57, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/opt/netbox-3.6.4/venv/lib64/python3.9/site-packages/django/urls/resolvers.py", line 708, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib64/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/opt/netbox-3.6.4/netbox/netbox/urls.py", line 9, in <module>
    from extras.plugins.urls import plugin_admin_patterns, plugin_patterns, plugin_api_patterns
  File "/opt/netbox-3.6.4/netbox/extras/plugins/urls.py", line 31, in <module>
    urlpatterns = import_string(f"{plugin_path}.urls.urlpatterns")
  File "/opt/netbox-3.6.4/venv/lib64/python3.9/site-packages/django/utils/module_loading.py", line 30, in import_string
    return cached_import(module_path, class_name)
  File "/opt/netbox-3.6.4/venv/lib64/python3.9/site-packages/django/utils/module_loading.py", line 15, in cached_import
    module = import_module(module_path)
  File "/usr/lib64/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/opt/netbox-3.6.4/venv/lib64/python3.9/site-packages/netbox_slm/urls.py", line 4, in <module>
    from netbox_slm import views
ImportError: cannot import name 'views' from 'netbox_slm' (/opt/netbox-3.6.4/venv/lib64/python3.9/site-packages/netbox_slm/__init__.py)
wkoot commented 11 months ago

All versions on all OS/platforms should work on python 3.9 and above. What do you see when you curl https://pypi.org/simple/netbox-slm/ from that machine? It could be very likely that other packages are also "stuck" on very old versions.

What do you see in the folder /opt/netbox-3.6.4/venv/lib64/python3.9/site-packages/netbox_slm/views/ ?

GoldyXXD commented 11 months ago

This is my output. But i'm guessing my pip isn't pointing to that pypi repo for some reason maybe?

<html>
  <head>
    <meta name="pypi:repository-version" content="1.1">
    <title>Links for netbox-slm</title>
  </head>
  <body>
    <h1>Links for netbox-slm</h1>
<a href="https://files.pythonhosted.org/packages/61/61/41a316ce2f326e9b8ab150f8336a44ea1e1b4b6757c1a30850d7b01fb1e1/netbox-slm-0.1.tar.gz#sha256=7f0c8357ebc33d04a24bc0f6ccfff97398e296a7d8ca8691845f1dc2eb6b87a3" >netbox-slm-0.1.tar.gz</a><br />
<a href="https://files.pythonhosted.org/packages/96/f2/925e628e7aba044bec858bbe5b46dd1dbba11043c7d272a36742f9cc935c/netbox-slm-0.9.tar.gz#sha256=b86e4ee82884267cd81d15de2f3f77afc6ffaad42b8e6d610d2922b99571790b" >netbox-slm-0.9.tar.gz</a><br />
<a href="https://files.pythonhosted.org/packages/18/90/daf550e33e60a29eb0243cb5b8d968f7001da8a7fc7158787b31498408e8/netbox-slm-0.91.tar.gz#sha256=e716a3ad770b2313cca0b51d2f6e796cd5e0ed27d45350f9e6dd0851f3a6cf86" data-requires-python="&gt;=3.6" >netbox-slm-0.91.tar.gz</a><br />
<a href="https://files.pythonhosted.org/packages/a8/41/4434cef801f2f5631aeb9f7caea392ab346eb0791f680a8470e3c56ad414/netbox-slm-0.92.tar.gz#sha256=0ec769dab15fd8705b7b89de2c185690bea1ae651f348d960e8fad7914555e6e" data-requires-python="&gt;=3.6" >netbox-slm-0.92.tar.gz</a><br />
<a href="https://files.pythonhosted.org/packages/93/c9/82ac2c16056271502b70a2cf252057071997832f75fbd6a4759811489913/netbox-slm-0.93.tar.gz#sha256=0c29cff9f8b420a39f3ffda5a1c8d7eed6b5d1a48cff2676c7db19bb1845446e" data-requires-python="&gt;=3.6" >netbox-slm-0.93.tar.gz</a><br />
<a href="https://files.pythonhosted.org/packages/0f/0c/d0d9c9dbc08093192caaab4468c7e61dfd42e6ed63edfcc9f1be3eadd838/netbox-slm-0.94.tar.gz#sha256=575ac38fcce919a61b47f3120601416d9ec5c760ced27d40ce10531a4d70857d" data-requires-python="&gt;=3.7" >netbox-slm-0.94.tar.gz</a><br />
<a href="https://files.pythonhosted.org/packages/c6/97/46d2c548ab148e35fa88b964f6df3e2c6280ef8c8f023f0d63a84e5f0adb/netbox-slm-0.95.tar.gz#sha256=7f47a9717ebdc8ca275b8d6b054f80391d34f8ec6a8f3250ac942c7e64058e8a" data-requires-python="&gt;=3.7" >netbox-slm-0.95.tar.gz</a><br />
<a href="https://files.pythonhosted.org/packages/72/87/363861c65eff6a96cdc506d8e00fb4e3a1990785bc938c9e10eb39402142/netbox-slm-0.96.tar.gz#sha256=634200f8a93d32d4365b64a01f033824bdc79ed9a5317c551d5b330da8ad3ecd" data-requires-python="&gt;=3.7" >netbox-slm-0.96.tar.gz</a><br />
<a href="https://files.pythonhosted.org/packages/1a/f9/98e28fc669194444eec32c1c38c86bcadf52f08ce036bfabb6db7c4ea4e4/netbox-slm-0.98.tar.gz#sha256=c042b42757219a4144c61c2db596a4e42dacf75b89dc70ea0d570d33da88774e" data-requires-python="&gt;=3.7" >netbox-slm-0.98.tar.gz</a><br />
<a href="https://files.pythonhosted.org/packages/63/e8/b9ff7ab8ab1d4febc3f3662aa91931a8508434c291cd9758fe9378381ce5/netbox-slm-0.99.tar.gz#sha256=3531a159e6510fdc213a3aba770b26c7a2cd479c9429299ff7560270701533c8" data-requires-python="&gt;=3.7" >netbox-slm-0.99.tar.gz</a><br />
<a href="https://files.pythonhosted.org/packages/a0/94/8394c03f69440b36d5dfdd82bc5680589f87ca35147196e89ac585d373ef/netbox-slm-1.1.tar.gz#sha256=56c143d585d7e529bd8f2467485e84213a9e9e234f9b6e3227703a759d6b6bb7" data-requires-python="&gt;=3.7" >netbox-slm-1.1.tar.gz</a><br />
<a href="https://files.pythonhosted.org/packages/ae/0e/cdbf22326f2f94e94f97e7bedbfdf150d9c2c85c6d919de1138a05d098af/netbox-slm-1.2.tar.gz#sha256=783ef71eee8c92d156eb2f5d74d44cfe4d8a4fb1f59edd0f4a21d1121d7336fe" data-requires-python="&gt;=3.7" >netbox-slm-1.2.tar.gz</a><br />
<a href="https://files.pythonhosted.org/packages/4a/19/8d20a832f6bd647b98b5dd9612dfdd6ac61bbde438454c50c33d3f94278b/netbox-slm-1.3.tar.gz#sha256=48d2238bf783e006704d29238a351fad9def9fdbf6d596f0f9a638e27c16517a" data-requires-python="&gt;=3.9" >netbox-slm-1.3.tar.gz</a><br />
<a href="https://files.pythonhosted.org/packages/1e/52/89ccfd60a7836a72baeb57d0d277351431c6868b6d58f2a97275f2b5dbd8/netbox-slm-1.4.tar.gz#sha256=58d7fd3aba48e12e6a842ef55e654ec5c236305fbdfad7c1c69d294e10c42dbf" data-requires-python="&gt;=3.9" >netbox-slm-1.4.tar.gz</a><br />
<a href="https://files.pythonhosted.org/packages/89/69/87ddc392a05a4447f9e635987e7260fdb98c866ddeda02b736f143f3cbe3/netbox-slm-1.5.1.tar.gz#sha256=49e3df65eac992ac5515b74b0697cd5b31f912048a97d44b7495e5e729b8abd8" data-requires-python="&gt;=3.9" >netbox-slm-1.5.1.tar.gz</a><br />
<a href="https://files.pythonhosted.org/packages/0b/09/e32c842cde3b7ceb55c822bcbb70e687af1a0b2b640f208c574739fca8b5/netbox_slm-1.5.1-py3-none-any.whl#sha256=af8ff61a6fc92a601bfc78887df65bf25804876bdf5cf3f3a4dc91c21e770386" data-requires-python="&gt;=3.9" data-dist-info-metadata="sha256=d6fa6f5aa60352c69d4702fe2b752ffe8c6770ddae303997ef290fd623537210" data-core-metadata="sha256=d6fa6f5aa60352c69d4702fe2b752ffe8c6770ddae303997ef290fd623537210">netbox_slm-1.5.1-py3-none-any.whl</a><br />
</body>
</html>

Dosn't look like the views folder is created

/opt/netbox-3.6.4/venv/lib64/python3.9/site-packages/netbox_slm
[root@netbox netbox_slm]# ls -lah
total 60K
drwxr-xr-x.   4 root root  168 Dec  4 16:08 .
drwxr-xr-x. 273 root root  12K Dec  4 16:08 ..
-rw-r--r--.   1 root root  215 Dec  4 16:08 admin.py
-rw-r--r--.   1 root root 2.6K Dec  4 16:08 filtersets.py
-rw-r--r--.   1 root root  446 Dec  4 16:08 __init__.py
-rw-r--r--.   1 root root 5.2K Dec  4 16:08 models.py
-rw-r--r--.   1 root root 2.9K Dec  4 16:08 navigation.py
drwxr-xr-x.   2 root root 4.0K Dec  4 16:08 __pycache__
-rw-r--r--.   1 root root 6.6K Dec  4 16:08 tables.py
drwxr-xr-x.   3 root root   24 Dec  4 16:08 templates
-rw-r--r--.   1 root root 5.1K Dec  4 16:08 urls.py
wkoot commented 11 months ago

Yes, this simply looks like you've still got the old version 1.2: https://github.com/ICTU/netbox_slm/tree/1.2/netbox_slm Do you have any overrides set for pip, such as PIP_INDEX_URL ? Since you can see the latest images via curl, it doesn't seem to be a proxy issue.

GoldyXXD commented 11 months ago

So it looks like it might have been a pip cache issue. Once I removed the netbox-slm @ git+https://github.com/ICTU/netbox_slm line I added in the requirements.txt file and the netbox_slm folder from /opt/netbox/venv/lib64/python3.9/site-packages/ and re-ran the update I still got 1.2. I checked the logs during the upgrade.sh run and it was pulling it from cache. Accessed the venv evnrionment, ran pip cache purge and re-ran the upgrade.sh script and it pulled all pacakges down from scratch including 1.5

wkoot commented 11 months ago

Excellent. Does install, migration and running work now?

GoldyXXD commented 11 months ago

Yes installs and runs fine now. Thanks for your help.