netdevopsbr / netbox-proxbox

Netbox Plugin for integration between Proxmox and Netbox
Apache License 2.0
341 stars 50 forks source link

Running into Error when starting the Proxmox Full Update #59

Closed PhilFalc0ne closed 1 year ago

PhilFalc0ne commented 2 years ago

I run a fresh Netbox Installation and added the Plugin according to the Documentation (used the git repository). When running the "Proxmox Full Update", I get the error message:

<class 'AttributeError'>

object has no attribute "slug"

Python version: 3.10.4 NetBox version: 3.2.4

I also tested to run the plugin in development mode to check if there are any differences, but I've got the same error page shown. My setup looks like this:

Promox Version 7.2.3 netbox-proxbox version 0.0.5-beta1 (github) Netbox version 3.2.4

Do you have any hint for me, what was going wrong?

jine commented 2 years ago

Same issue I'm having currently, investigating...

eliassteiner commented 2 years ago

same issue here has someone a workaround?

ghost commented 2 years ago

same problem

sugoy-desu commented 2 years ago

same problem, does anyone have a solution?

JouanDeag commented 2 years ago

Yup, also same problem here.

Kris33 commented 2 years ago

Same problem here : object has no attribute "slug"

PVE 7.2-7 Python version: 3.9.7 NetBox version: 3.2.6 netbox-proxbox version 0.0.5-beta1

vfosterm commented 1 year ago

would be nice to update the ReadMe of the project to warn people that it is currently not functioning. Would've saved me some hours today at least :)

beerygaz commented 1 year ago

I'm new to netbox too and have been struggling with the same issues. Add my hours to @vfosterm's hours

Chankster commented 1 year ago

Can anyone provide a full traceback?

Kris33 commented 1 year ago

If you tell me how to do it, I'll gladly provide it.

Chankster commented 1 year ago

It depends on your install. Check your netbox service logs, check your system syslog, if using docker containers check the container log, enable debug and capture.

Kris33 commented 1 year ago

Classic full install Netbox 3.4.3 on almalinux 8 + Netbox proxbox plugin from git. no docker.

Here is the Traceback:


Traceback (most recent call last):
  File "/opt/netbox/venv/lib64/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/opt/netbox/venv/lib64/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/netbox/venv/lib64/python3.9/site-packages/django/views/generic/base.py", line 103, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/netbox/venv/lib64/python3.9/site-packages/django/contrib/auth/mixins.py", line 109, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox/venv/lib64/python3.9/site-packages/django/views/generic/base.py", line 142, in dispatch
    return handler(request, *args, **kwargs)
  File "/opt/netbox/venv/lib64/python3.9/site-packages/netbox_proxbox/views.py", line 46, in get
    update_all_result = proxbox_api.update.all(remove_unused = True)
  File "/opt/netbox/venv/lib64/python3.9/site-packages/netbox_proxbox/proxbox_api/update.py", line 406, in all
    cluster = create.virtualization.cluster()
  File "/opt/netbox/venv/lib64/python3.9/site-packages/netbox_proxbox/proxbox_api/create/virtualization.py", line 68, in cluster
    type = cluster_type().slug
  File "/opt/netbox/venv/lib64/python3.9/site-packages/pynetbox/core/response.py", line 298, in __getattr__
    raise AttributeError('object has no attribute "{}"'.format(k))
AttributeError: object has no attribute "slug"
2023-01-23 17:43:58,979 django.request WARNING: Not Found: /favicon.ico
Chankster commented 1 year ago

It looks like this occurs whenever the netbox configuration within the netbox_proxbox section of PLUGINS_CONFIG is incorrect. The default has port 80 specified which is most likely getting redirected to 443 by nginx/apache.

In the PLUGINS_CONFIG try setting the netbox port to 8001 (the gunicorn default). Then ensure that whatever domain specified is added to ALLOWED_HOSTS

Kris33 commented 1 year ago

Nope.

It generates a connection refused error:

<class 'requests.exceptions.ConnectionError'>

HTTPConnectionPool(host='netbox.irisit.local', port=8001): Max retries exceeded with url: /api/virtualization/cluster-types/?name=Proxmox&slug=proxmox&limit=0 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f22d19cc490>: Failed to establish a new connection: [Errno 111] Connection refused'))

Python version: 3.9.13 NetBox version: 3.4.3

Traceback (most recent call last): File "/opt/netbox/venv/lib64/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) File "/opt/netbox/venv/lib64/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, callback_kwargs) File "/opt/netbox/venv/lib64/python3.9/site-packages/django/views/generic/base.py", line 103, in view return self.dispatch(request, *args, *kwargs) File "/opt/netbox/venv/lib64/python3.9/site-packages/django/contrib/auth/mixins.py", line 109, in dispatch return super().dispatch(request, args, kwargs) File "/opt/netbox/venv/lib64/python3.9/site-packages/django/views/generic/base.py", line 142, in dispatch return handler(request, *args, kwargs) File "/opt/netbox/venv/lib64/python3.9/site-packages/netbox_proxbox/views.py", line 46, in get update_all_result = proxbox_api.update.all(remove_unused = True) File "/opt/netbox/venv/lib64/python3.9/site-packages/netbox_proxbox/proxbox_api/update.py", line 406, in all cluster = create.virtualization.cluster() File "/opt/netbox/venv/lib64/python3.9/site-packages/netbox_proxbox/proxbox_api/create/virtualization.py", line 67, in cluster type = cluster_type().slug File "/opt/netbox/venv/lib64/python3.9/site-packages/netbox_proxbox/proxbox_api/create/virtualization.py", line 24, in cluster_type cluster_type_proxbox = nb.virtualization.cluster_types.get( File "/opt/netbox/venv/lib64/python3.9/site-packages/pynetbox/core/endpoint.py", line 148, in get ret = next(resp, None) File "/opt/netbox/venv/lib64/python3.9/site-packages/pynetbox/core/response.py", line 117, in next next(self.response), self.endpoint.api, self.endpoint File "/opt/netbox/venv/lib64/python3.9/site-packages/pynetbox/core/query.py", line 317, in get req = self._make_call(add_params=add_params) File "/opt/netbox/venv/lib64/python3.9/site-packages/pynetbox/core/query.py", line 267, in _make_call req = getattr(self.http_session, verb)( File "/opt/netbox/venv/lib64/python3.9/site-packages/requests/sessions.py", line 600, in get return self.request("GET", url, kwargs) File "/opt/netbox/venv/lib64/python3.9/site-packages/requests/sessions.py", line 587, in request resp = self.send(prep, send_kwargs) File "/opt/netbox/venv/lib64/python3.9/site-packages/requests/sessions.py", line 701, in send r = adapter.send(request, kwargs) File "/opt/netbox/venv/lib64/python3.9/site-packages/requests/adapters.py", line 565, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPConnectionPool(host='netbox.irisit.local', port=8001): Max retries exceeded with url: /api/virtualization/cluster-types/?name=Proxmox&slug=proxmox&limit=0 (Caused by NewConnectionErr('<urllib3.connection.HTTPConnection object at 0x7f22d19cc490>: Failed to establish a new connection: [Errno 111] Connection refused'))

Chankster commented 1 year ago

Likely you have your gunicorn.py bound to localhost instead of netbox.irisit.local

Kris33 commented 1 year ago

True. I followed the official guide to set it up.

So for those who would be looking for the answers to this problem: in /opt/netbox/netbox/netbox/configuration.py

I had to modify PLUGINS_CONFIG from the netbox section:

'http_port': 80, to 'http_port': 8001,

in /opt/netbox/gunicorn.py bind = '127.0.0.1:8001' to bind = 'your.beautiful.fqdn:8001'

in from /etc/nginx/nginx.conf proxy_pass http://127.0.0.1:8001; to proxy_pass http://your/beautiful.fqdn:8001;

then restart netbox, netbox-rq and nginx.

Thanks a lot to Chankster for debugging that.

Chankster commented 1 year ago

If you change the bind from localhost just be sure you have the appropriate firewall rules or network access restrictions in place as you're exposing gunicorn beyond the local system.

I would recommend changing the netbox host in PLUGINS_CONFIG to localhost and ensuring localhost is in ALLOWED_HOSTS.

Kris33 commented 1 year ago

OK Thanks.