netdevopsbr / netbox-proxbox

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

Error creating PVE node when there's existing Netbox device with the same name (duplicate) #75

Closed RWL-Dittrich closed 1 year ago

RWL-Dittrich commented 1 year ago

I have set up the netbox-proxbox plugin following the setup guide in the README.MD

I also modified the models.py file to get it working with the newer netbox version

When I try to sync Proxmox to Netbox I get the following error:

<class 'AttributeError'>

'NoneType' object has no attribute 'name'

Python version: 3.10.6
NetBox version: 3.4.3

The stacktrace in the logs is as follows:

Jan 31 12:52:51 netbox-new-ubuntu gunicorn[7821]: Internal Server Error: /plugins/proxbox/full_update/
Jan 31 12:52:51 netbox-new-ubuntu gunicorn[7821]: Traceback (most recent call last):
Jan 31 12:52:51 netbox-new-ubuntu gunicorn[7821]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
Jan 31 12:52:51 netbox-new-ubuntu gunicorn[7821]:     response = get_response(request)
Jan 31 12:52:51 netbox-new-ubuntu gunicorn[7821]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
Jan 31 12:52:51 netbox-new-ubuntu gunicorn[7821]:     response = wrapped_callback(request, *callback_args, **callback_kwargs)
Jan 31 12:52:51 netbox-new-ubuntu gunicorn[7821]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 103, in view
Jan 31 12:52:51 netbox-new-ubuntu gunicorn[7821]:     return self.dispatch(request, *args, **kwargs)
Jan 31 12:52:51 netbox-new-ubuntu gunicorn[7821]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/contrib/auth/mixins.py", line 109, in dispatch
Jan 31 12:52:51 netbox-new-ubuntu gunicorn[7821]:     return super().dispatch(request, *args, **kwargs)
Jan 31 12:52:51 netbox-new-ubuntu gunicorn[7821]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 142, in dispatch
Jan 31 12:52:51 netbox-new-ubuntu gunicorn[7821]:     return handler(request, *args, **kwargs)
Jan 31 12:52:51 netbox-new-ubuntu gunicorn[7821]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/views.py", line 46, in get
Jan 31 12:52:51 netbox-new-ubuntu gunicorn[7821]:     update_all_result = proxbox_api.update.all(remove_unused = True)
Jan 31 12:52:51 netbox-new-ubuntu gunicorn[7821]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 420, in all
Jan 31 12:52:51 netbox-new-ubuntu gunicorn[7821]:     node_updated = nodes(proxmox_json = px_node_each, proxmox_cluster = proxmox_cluster)
Jan 31 12:52:51 netbox-new-ubuntu gunicorn[7821]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 378, in nodes
Jan 31 12:52:51 netbox-new-ubuntu gunicorn[7821]:     full_update = node_full_update(netbox_node, proxmox_json, proxmox_cluster)
Jan 31 12:52:51 netbox-new-ubuntu gunicorn[7821]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 57, in node_full_update
Jan 31 12:52:51 netbox-new-ubuntu gunicorn[7821]:     cluster_updated = updates.node.cluster(netbox_node, proxmox_json, proxmox_cluster)
Jan 31 12:52:51 netbox-new-ubuntu gunicorn[7821]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/updates/node.py", line 52, in cluster
Jan 31 12:52:51 netbox-new-ubuntu gunicorn[7821]:     if netbox_node.cluster.name != proxmox_cluster['name']:
Jan 31 12:52:51 netbox-new-ubuntu gunicorn[7821]: AttributeError: 'NoneType' object has no attribute 'name'

I do see some stuff being created in netbox like the Cluster (with the correct name) and the cluster type and tag so it seems the connection between the plugin, Netbox and Proxmox works. What could be causing this issue?

emersonfelipesp commented 1 year ago

Hi @RWL-Dittric, I have made many updates to code and would like to have you testing it again, if possible! Thanks already

RWL-Dittrich commented 1 year ago

Hello there!

I installed the plugin again (through git this time with the develop branch) and tested it again. I still get the same issue though. I have attached the log again below but it seems to be the exact same result as I got a while ago.

Mar 13 10:48:36 netbox-ubuntu gunicorn[45182]: [Proxbox - Netbox plugin | Update All]
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]: CLUSTER...
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]: [OK] CLUSTER created. -> PVE-app-cluster
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]: NODES...
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]: Internal Server Error: /plugins/proxbox/full_update/
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]: Traceback (most recent call last):
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 56, in inner
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     response = get_response(request)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     response = wrapped_callback(request, *callback_args, **callback_kwargs)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 103, in view
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     return self.dispatch(request, *args, **kwargs)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/contrib/auth/mixins.py", line 109, in dispatch
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     return super().dispatch(request, *args, **kwargs)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 142, in dispatch
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     return handler(request, *args, **kwargs)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/views.py", line 54, in get
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     update_all_result = proxbox_api.update.all(remove_unused = True)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 425, in all
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     node_updated = nodes(proxmox_json = px_node_each, proxmox_cluster = proxmox_cluster)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 383, in nodes
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     full_update = node_full_update(netbox_node, proxmox_json, proxmox_cluster)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 60, in node_full_update
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     cluster_updated = updates.node.cluster(netbox_node, proxmox_json, proxmox_cluster)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/updates/node.py", line 64, in cluster
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     if netbox_node.cluster.name != proxmox_cluster['name']:
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]: AttributeError: 'NoneType' object has no attribute 'name'
emersonfelipesp commented 1 year ago

Hello there!

I installed the plugin again (through git this time with the develop branch) and tested it again. I still get the same issue though. I have attached the log again below but it seems to be the exact same result as I got a while ago.

Mar 13 10:48:36 netbox-ubuntu gunicorn[45182]: [Proxbox - Netbox plugin | Update All]
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]: CLUSTER...
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]: [OK] CLUSTER created. -> PVE-app-cluster
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]: NODES...
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]: Internal Server Error: /plugins/proxbox/full_update/
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]: Traceback (most recent call last):
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 56, in inner
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     response = get_response(request)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     response = wrapped_callback(request, *callback_args, **callback_kwargs)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 103, in view
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     return self.dispatch(request, *args, **kwargs)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/contrib/auth/mixins.py", line 109, in dispatch
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     return super().dispatch(request, *args, **kwargs)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 142, in dispatch
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     return handler(request, *args, **kwargs)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/views.py", line 54, in get
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     update_all_result = proxbox_api.update.all(remove_unused = True)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 425, in all
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     node_updated = nodes(proxmox_json = px_node_each, proxmox_cluster = proxmox_cluster)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 383, in nodes
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     full_update = node_full_update(netbox_node, proxmox_json, proxmox_cluster)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 60, in node_full_update
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     cluster_updated = updates.node.cluster(netbox_node, proxmox_json, proxmox_cluster)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/updates/node.py", line 64, in cluster
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     if netbox_node.cluster.name != proxmox_cluster['name']:
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]: AttributeError: 'NoneType' object has no attribute 'name'

Thank you for testing, I will try to solve this and comeback to see if it works.

RWL-Dittrich commented 1 year ago

Hello there! I installed the plugin again (through git this time with the develop branch) and tested it again. I still get the same issue though. I have attached the log again below but it seems to be the exact same result as I got a while ago.

Mar 13 10:48:36 netbox-ubuntu gunicorn[45182]: [Proxbox - Netbox plugin | Update All]
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]: CLUSTER...
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]: [OK] CLUSTER created. -> PVE-app-cluster
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]: NODES...
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]: Internal Server Error: /plugins/proxbox/full_update/
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]: Traceback (most recent call last):
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 56, in inner
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     response = get_response(request)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     response = wrapped_callback(request, *callback_args, **callback_kwargs)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 103, in view
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     return self.dispatch(request, *args, **kwargs)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/contrib/auth/mixins.py", line 109, in dispatch
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     return super().dispatch(request, *args, **kwargs)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 142, in dispatch
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     return handler(request, *args, **kwargs)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/views.py", line 54, in get
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     update_all_result = proxbox_api.update.all(remove_unused = True)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 425, in all
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     node_updated = nodes(proxmox_json = px_node_each, proxmox_cluster = proxmox_cluster)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 383, in nodes
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     full_update = node_full_update(netbox_node, proxmox_json, proxmox_cluster)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 60, in node_full_update
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     cluster_updated = updates.node.cluster(netbox_node, proxmox_json, proxmox_cluster)
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/updates/node.py", line 64, in cluster
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]:     if netbox_node.cluster.name != proxmox_cluster['name']:
Mar 13 10:48:37 netbox-ubuntu gunicorn[45182]: AttributeError: 'NoneType' object has no attribute 'name'

Thank you for testing, I will try to solve this and comeback to see if it works.

Let me know if you need anything else. I will try to respond as quickly as possible!

emersonfelipesp commented 1 year ago

Hi @RWL-Dittrich, sorry for the late response. I have just commited a possible fix for your issue, if you could please test it again. Even if it does not work, I think it will help us as I added a exception handler. Thank you.

RWL-Dittrich commented 1 year ago

Hi @RWL-Dittrich, sorry for the late response. I have just commited a possible fix for your issue, if you could please test it again. Even if it does not work, I think it will help us as I added a exception handler. Thank you.

Hello @emersonfelipesp,

Thanks for getting back to me!

I just pulled the master branch again and restarted netbox. I now get the following error

error in browser:

<class 'UnboundLocalError'>

local variable 'cluster_updated' referenced before assignment

Python version: 3.10.6
NetBox version: 3.4.5

error in netbox:

Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]: [Proxbox - Netbox plugin | Update All]
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]: CLUSTER...
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]: [OK] CLUSTER created. -> PVE-app-cluster
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]: NODES...
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]: [ERROR] 'NoneType' object has no attribute 'name'
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]: Internal Server Error: /plugins/proxbox/full_update/
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]: Traceback (most recent call last):
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 56, in inner
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]:     response = get_response(request)
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]:     response = wrapped_callback(request, *callback_args, **callback_kwargs)
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 103, in view
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]:     return self.dispatch(request, *args, **kwargs)
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/contrib/auth/mixins.py", line 109, in dispatch
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]:     return super().dispatch(request, *args, **kwargs)
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 142, in dispatch
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]:     return handler(request, *args, **kwargs)
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/views.py", line 93, in get
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]:     "proxmox": proxbox_api.update.all(remove_unused = True),
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 440, in all
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]:     node_updated = nodes(proxmox_json = px_node_each, proxmox_cluster = proxmox_cluster)
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 396, in nodes
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]:     full_update = node_full_update(netbox_node, proxmox_json, proxmox_cluster)
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 60, in node_full_update
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]:     cluster_updated = updates.node.cluster(netbox_node, proxmox_json, proxmox_cluster)
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/updates/node.py", line 102, in cluster
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]:     return cluster_updated
Mar 20 13:06:19 netbox-ubuntu gunicorn[90001]: UnboundLocalError: local variable 'cluster_updated' referenced before assignment
emersonfelipesp commented 1 year ago

Please pull it again, I think it will work now.

RWL-Dittrich commented 1 year ago

I am now getting the following error:

<class 'TypeError'>

int() argument must be a string, a bytes-like object or a real number, not 'NoneType'

Python version: 3.10.6
NetBox version: 3.4.5
Mar 20 13:17:04 netbox-ubuntu gunicorn[90111]: [Proxbox - Netbox plugin | Update All]
Mar 20 13:17:04 netbox-ubuntu gunicorn[90111]: CLUSTER...
Mar 20 13:17:04 netbox-ubuntu gunicorn[90111]: [OK] CLUSTER created. -> PVE-app-cluster
Mar 20 13:17:04 netbox-ubuntu gunicorn[90111]: NODES...
Mar 20 13:17:05 netbox-ubuntu gunicorn[90111]: [ERROR] 'NoneType' object has no attribute 'name'
Mar 20 13:17:05 netbox-ubuntu gunicorn[90111]: Internal Server Error: /plugins/proxbox/full_update/
Mar 20 13:17:05 netbox-ubuntu gunicorn[90111]: Traceback (most recent call last):
Mar 20 13:17:05 netbox-ubuntu gunicorn[90111]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 56, in inner
Mar 20 13:17:05 netbox-ubuntu gunicorn[90111]:     response = get_response(request)
Mar 20 13:17:05 netbox-ubuntu gunicorn[90111]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
Mar 20 13:17:05 netbox-ubuntu gunicorn[90111]:     response = wrapped_callback(request, *callback_args, **callback_kwargs)
Mar 20 13:17:05 netbox-ubuntu gunicorn[90111]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 103, in view
Mar 20 13:17:05 netbox-ubuntu gunicorn[90111]:     return self.dispatch(request, *args, **kwargs)
Mar 20 13:17:05 netbox-ubuntu gunicorn[90111]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/contrib/auth/mixins.py", line 109, in dispatch
Mar 20 13:17:05 netbox-ubuntu gunicorn[90111]:     return super().dispatch(request, *args, **kwargs)
Mar 20 13:17:05 netbox-ubuntu gunicorn[90111]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 142, in dispatch
Mar 20 13:17:05 netbox-ubuntu gunicorn[90111]:     return handler(request, *args, **kwargs)
Mar 20 13:17:05 netbox-ubuntu gunicorn[90111]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/views.py", line 93, in get
Mar 20 13:17:05 netbox-ubuntu gunicorn[90111]:     "proxmox": proxbox_api.update.all(remove_unused = True),
Mar 20 13:17:05 netbox-ubuntu gunicorn[90111]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 440, in all
Mar 20 13:17:05 netbox-ubuntu gunicorn[90111]:     node_updated = nodes(proxmox_json = px_node_each, proxmox_cluster = proxmox_cluster)
Mar 20 13:17:05 netbox-ubuntu gunicorn[90111]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 396, in nodes
Mar 20 13:17:05 netbox-ubuntu gunicorn[90111]:     full_update = node_full_update(netbox_node, proxmox_json, proxmox_cluster)
Mar 20 13:17:05 netbox-ubuntu gunicorn[90111]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 61, in node_full_update
Mar 20 13:17:05 netbox-ubuntu gunicorn[90111]:     interfaces_updated = updates.node.interfaces(netbox_node, proxmox_json)
Mar 20 13:17:05 netbox-ubuntu gunicorn[90111]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/updates/node.py", line 111, in interfaces
Mar 20 13:17:05 netbox-ubuntu gunicorn[90111]:     _ntb_iface = [{'name': iface.name, 'mtu' : int(iface.mtu), 'tagged_vlans': [int(x['vid']) for x in iface.tagged_vlans]} for iface in nb.dcim.interfaces.filter(device_id=netbox_node.id)]
Mar 20 13:17:05 netbox-ubuntu gunicorn[90111]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/updates/node.py", line 111, in <listcomp>
Mar 20 13:17:05 netbox-ubuntu gunicorn[90111]:     _ntb_iface = [{'name': iface.name, 'mtu' : int(iface.mtu), 'tagged_vlans': [int(x['vid']) for x in iface.tagged_vlans]} for iface in nb.dcim.interfaces.filter(device_id=netbox_node.id)]
Mar 20 13:17:05 netbox-ubuntu gunicorn[90111]: TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
emersonfelipesp commented 1 year ago

I will open a pull request to it and add some prints to see what is happening to cluster. Can you send me the cluster names of your environment?

RWL-Dittrich commented 1 year ago

Sure! The cluster name is PVE-app-cluster

The cluster does get created but other than that nothing happens

emersonfelipesp commented 1 year ago

Pull it again and change the branch using the following commands: git pull and then git checkout cluster-nonetype

RWL-Dittrich commented 1 year ago

I switched to your other branch. The following logs appear:

Mar 20 13:31:07 netbox-ubuntu gunicorn[90262]: [Proxbox - Netbox plugin | Update All]
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]: CLUSTER...
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]: [OK] CLUSTER created. -> PVE-app-cluster
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]: NODES...
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]: Internal Server Error: /plugins/proxbox/full_update/
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]: Traceback (most recent call last):
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/updates/node.py", line 67, in cluster
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]:     if netbox_node.cluster.name != proxmox_cluster['name'] or netbox_node.cluster.name == None:
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]: AttributeError: 'NoneType' object has no attribute 'name'
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]: During handling of the above exception, another exception occurred:
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]: Traceback (most recent call last):
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 56, in inner
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]:     response = get_response(request)
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]:     response = wrapped_callback(request, *callback_args, **callback_kwargs)
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 103, in view
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]:     return self.dispatch(request, *args, **kwargs)
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/contrib/auth/mixins.py", line 109, in dispatch
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]:     return super().dispatch(request, *args, **kwargs)
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 142, in dispatch
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]:     return handler(request, *args, **kwargs)
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/views.py", line 93, in get
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]:     "proxmox": proxbox_api.update.all(remove_unused = True),
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 440, in all
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]:     node_updated = nodes(proxmox_json = px_node_each, proxmox_cluster = proxmox_cluster)
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 396, in nodes
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]:     full_update = node_full_update(netbox_node, proxmox_json, proxmox_cluster)
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 60, in node_full_update
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]:     cluster_updated = updates.node.cluster(netbox_node, proxmox_json, proxmox_cluster)
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/updates/node.py", line 100, in cluster
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]:     print(f"[ERROR] {error}\n netbox_node: {netbox_node}\n> netbox_node.cluster.id: {netbox_node.cluster.id}\n> proxmox_cluster: {proxmox_cluster}")
Mar 20 13:31:08 netbox-ubuntu gunicorn[90262]: AttributeError: 'NoneType' object has no attribute 'id'
emersonfelipesp commented 1 year ago

It seems netbox_node is None, I added another if statement to confirm this and then we'll have to find the reason for this. Could you please send the name of your nodes?

RWL-Dittrich commented 1 year ago

My proxmox cluster looks like the following: image

After running the updated code it spits out the following logs:

Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]: [Proxbox - Netbox plugin | Update All]
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]: CLUSTER...
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]: [OK] CLUSTER created. -> PVE-app-cluster
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]: NODES...
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]: Internal Server Error: /plugins/proxbox/full_update/
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]: Traceback (most recent call last):
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/updates/node.py", line 68, in cluster
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]:     if netbox_node.cluster.name != proxmox_cluster['name'] or netbox_node.cluster.name == None:
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]: AttributeError: 'NoneType' object has no attribute 'name'
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]: During handling of the above exception, another exception occurred:
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]: Traceback (most recent call last):
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 56, in inner
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]:     response = get_response(request)
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]:     response = wrapped_callback(request, *callback_args, **callback_kwargs)
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 103, in view
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]:     return self.dispatch(request, *args, **kwargs)
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/contrib/auth/mixins.py", line 109, in dispatch
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]:     return super().dispatch(request, *args, **kwargs)
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 142, in dispatch
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]:     return handler(request, *args, **kwargs)
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/views.py", line 93, in get
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]:     "proxmox": proxbox_api.update.all(remove_unused = True),
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 440, in all
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]:     node_updated = nodes(proxmox_json = px_node_each, proxmox_cluster = proxmox_cluster)
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 396, in nodes
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]:     full_update = node_full_update(netbox_node, proxmox_json, proxmox_cluster)
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 60, in node_full_update
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]:     cluster_updated = updates.node.cluster(netbox_node, proxmox_json, proxmox_cluster)
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/updates/node.py", line 101, in cluster
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]:     print(f"[ERROR] {error}\n netbox_node: {netbox_node}\n> netbox_node.cluster.id: {netbox_node.cluster.id}\n> proxmox_cluster: {proxmox_cluster}")
Mar 20 13:43:51 netbox-ubuntu gunicorn[90349]: AttributeError: 'NoneType' object has no attribute 'id'

I don't know if anything changed. Doesn't seem like it...

emersonfelipesp commented 1 year ago

Right, I'm really struggling to solve it, I added two more print() to see if it helps with more information.

RWL-Dittrich commented 1 year ago

That's no problem! I'm happy to provide any information you need :)

After running it again I get the following logs:

Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]: [Proxbox - Netbox plugin | Update All]
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]: CLUSTER...
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]: [OK] CLUSTER created. -> PVE-app-cluster
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]: NODES...
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]: (1) netbox_search: slc-app-02
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]: (1) netbox_node: slc-app-02
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]: Internal Server Error: /plugins/proxbox/full_update/
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]: Traceback (most recent call last):
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/updates/node.py", line 68, in cluster
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]:     if netbox_node.cluster.name != proxmox_cluster['name'] or netbox_node.cluster.name == None:
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]: AttributeError: 'NoneType' object has no attribute 'name'
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]: During handling of the above exception, another exception occurred:
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]: Traceback (most recent call last):
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 56, in inner
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]:     response = get_response(request)
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]:     response = wrapped_callback(request, *callback_args, **callback_kwargs)
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 103, in view
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]:     return self.dispatch(request, *args, **kwargs)
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/contrib/auth/mixins.py", line 109, in dispatch
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]:     return super().dispatch(request, *args, **kwargs)
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 142, in dispatch
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]:     return handler(request, *args, **kwargs)
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/views.py", line 93, in get
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]:     "proxmox": proxbox_api.update.all(remove_unused = True),
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 442, in all
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]:     node_updated = nodes(proxmox_json = px_node_each, proxmox_cluster = proxmox_cluster)
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 398, in nodes
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]:     full_update = node_full_update(netbox_node, proxmox_json, proxmox_cluster)
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 60, in node_full_update
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]:     cluster_updated = updates.node.cluster(netbox_node, proxmox_json, proxmox_cluster)
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/updates/node.py", line 101, in cluster
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]:     print(f"[ERROR] {error}\n netbox_node: {netbox_node}\n> netbox_node.cluster.id: {netbox_node.cluster.id}\n> proxmox_cluster: {proxmox_cluster}")
Mar 20 13:50:34 netbox-ubuntu gunicorn[90428]: AttributeError: 'NoneType' object has no attribute 'id'
Mar 20 13:50:35 netbox-ubuntu gunicorn[90428]: Not Found: /favicon.ico
emersonfelipesp commented 1 year ago

Have you created another device with the same name as the PVE's? Like slc-app-02

RWL-Dittrich commented 1 year ago

I was literally just looking at the code and thought of the same thing 🤣 That is actually the case. I tried to rename the other devices and suddenly it works. Would this be considered intended behavior or a bug?

What should I do? Can I use the new device objects to replace the old hosts I created in Netbox?

emersonfelipesp commented 1 year ago

Right, I will create a way to handle this, maybe appending (1) to final of device name. I could just update the existing node with the proxbox information, but I think someone could find it intrusive maybe. Initially, I think it is a better idea to just duplicate it and let user decide what to do.

emersonfelipesp commented 1 year ago

I was literally just looking at the code and thought of the same thing 🤣 That is actually the case. I tried to rename the other devices and suddenly it works. Would this be considered intended behavior or a bug?

What should I do? Can I use the new device objects to replace the old hosts I created in Netbox?

If you just delete the existing node or change its name, it will work as Proxbox will think there's no existing one!

RWL-Dittrich commented 1 year ago

Yeah I just renamed the old nodes by appending -a to the name 😆

I will update the newly created nodes with pictures/other device data and see where we and up!

Thank you so much for helping solve this issue ❤️

emersonfelipesp commented 1 year ago

Thank you for providing useful information, I will let this Issue open while I work on the defintive solution.

RWL-Dittrich commented 1 year ago

I seem to have found the reason the plugin is throwing the error. When setting up the devices to include the idrac interfaces and virtual bridges the plugin started crashing again.

Whenever I add an extra interface to one of the hosts that gets updated by proxbox the plugin fails. When I add an MTU to the interface it gets another error than the one we experienced above. Is adding extra interfaces to the proxbox nodes unsupported or is this a bug?

So after adding another interface (idrac) and giving it an MTU i get the following error:

Mar 20 15:03:35 netbox-ubuntu gunicorn[90603]: [Proxbox - Netbox plugin | Update All]
Mar 20 15:03:35 netbox-ubuntu gunicorn[90603]: CLUSTER...
Mar 20 15:03:35 netbox-ubuntu gunicorn[90603]: [OK] CLUSTER created. -> PVE-app-cluster
Mar 20 15:03:35 netbox-ubuntu gunicorn[90603]: NODES...
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]: Internal Server Error: /plugins/proxbox/full_update/
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]: Traceback (most recent call last):
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 56, in inner
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:     response = get_response(request)
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:     response = wrapped_callback(request, *callback_args, **callback_kwargs)
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 103, in view
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:     return self.dispatch(request, *args, **kwargs)
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/contrib/auth/mixins.py", line 109, in dispatch
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:     return super().dispatch(request, *args, **kwargs)
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 142, in dispatch
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:     return handler(request, *args, **kwargs)
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/views.py", line 93, in get
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:     "virtualmachines_table": VMUpdateResult(proxbox_api.update.all(remove_unused = True)["virtualmachines"]),
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 434, in all
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:     node_updated = nodes(proxmox_json = px_node_each, proxmox_cluster = proxmox_cluster)
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 392, in nodes
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:     full_update = node_full_update(netbox_node, proxmox_json, proxmox_cluster)
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 61, in node_full_update
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:     interfaces_updated = updates.node.interfaces(netbox_node, proxmox_json)
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/updates/node.py", line 219, in interfaces
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:     ntb_iface = list(nb.dcim.interfaces.filter(device_id=netbox_node.id, name=iface['name']))
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]: TypeError: string indices must be integers
emersonfelipesp commented 1 year ago

I seem to have found the reason the plugin is throwing the error. When setting up the devices to include the idrac interfaces and virtual bridges the plugin started crashing again.

Whenever I add an extra interface to one of the hosts that gets updated by proxbox the plugin fails. When I add an MTU to the interface it gets another error than the one we experienced above. Is adding extra interfaces to the proxbox nodes unsupported or is this a bug?

So after adding another interface (idrac) and giving it an MTU i get the following error:

Mar 20 15:03:35 netbox-ubuntu gunicorn[90603]: [Proxbox - Netbox plugin | Update All]
Mar 20 15:03:35 netbox-ubuntu gunicorn[90603]: CLUSTER...
Mar 20 15:03:35 netbox-ubuntu gunicorn[90603]: [OK] CLUSTER created. -> PVE-app-cluster
Mar 20 15:03:35 netbox-ubuntu gunicorn[90603]: NODES...
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]: Internal Server Error: /plugins/proxbox/full_update/
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]: Traceback (most recent call last):
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 56, in inner
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:     response = get_response(request)
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:     response = wrapped_callback(request, *callback_args, **callback_kwargs)
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 103, in view
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:     return self.dispatch(request, *args, **kwargs)
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/contrib/auth/mixins.py", line 109, in dispatch
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:     return super().dispatch(request, *args, **kwargs)
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:   File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 142, in dispatch
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:     return handler(request, *args, **kwargs)
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/views.py", line 93, in get
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:     "virtualmachines_table": VMUpdateResult(proxbox_api.update.all(remove_unused = True)["virtualmachines"]),
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 434, in all
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:     node_updated = nodes(proxmox_json = px_node_each, proxmox_cluster = proxmox_cluster)
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 392, in nodes
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:     full_update = node_full_update(netbox_node, proxmox_json, proxmox_cluster)
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py", line 61, in node_full_update
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:     interfaces_updated = updates.node.interfaces(netbox_node, proxmox_json)
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:   File "/opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/updates/node.py", line 219, in interfaces
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]:     ntb_iface = list(nb.dcim.interfaces.filter(device_id=netbox_node.id, name=iface['name']))
Mar 20 15:03:36 netbox-ubuntu gunicorn[90603]: TypeError: string indices must be integers

Could you please open other issue to report this interface related problem?