netdevopsbr / netbox-proxbox

Netbox Plugin for integration between Proxmox and Netbox
Apache License 2.0
320 stars 45 forks source link

'NoneType' object has no attribute 'id' #110

Open dmembibre opened 1 year ago

dmembibre commented 1 year ago

When attempting to retrieve data from the cluster, the following error is displayed

<class 'AttributeError'>

'NoneType' object has no attribute 'id'

Python version: 3.10.6
NetBox version: 3.5.1

And de logs says

May 17 11:35:16 netbox gunicorn[76783]: http://localhost:8001 "GET /api/ipam/vlans/?vid=22&limit=0 HTTP/1.1" 200 52
May 17 11:35:16 netbox gunicorn[76783]: Internal Server Error: /plugins/proxbox/full_update/
May 17 11:35:16 netbox gunicorn[76783]: Traceback (most recent call last):
May 17 11:35:16 netbox gunicorn[76783]:   File "/opt/netbox/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 56, in inner
May 17 11:35:16 netbox gunicorn[76783]:     response = get_response(request)
May 17 11:35:16 netbox gunicorn[76783]:   File "/opt/netbox/netbox/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
May 17 11:35:16 netbox gunicorn[76783]:     response = wrapped_callback(request, *callback_args, **callback_kwargs)
May 17 11:35:16 netbox gunicorn[76783]:   File "/opt/netbox/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 103, in view
May 17 11:35:16 netbox gunicorn[76783]:     return self.dispatch(request, *args, **kwargs)
May 17 11:35:16 netbox gunicorn[76783]:   File "/opt/netbox/netbox/venv/lib/python3.10/site-packages/django/contrib/auth/mixins.py", line 109, in dispatch
May 17 11:35:16 netbox gunicorn[76783]:     return super().dispatch(request, *args, **kwargs)
May 17 11:35:16 netbox gunicorn[76783]:   File "/opt/netbox/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 142, in dispatch
May 17 11:35:16 netbox gunicorn[76783]:     return handler(request, *args, **kwargs)
May 17 11:35:16 netbox gunicorn[76783]:   File "/opt/netbox/netbox/venv/lib/python3.10/site-packages/netbox_proxbox/views.py", line 93, in get
May 17 11:35:16 netbox gunicorn[76783]:     "virtualmachines_table": VMUpdateResult(proxbox_api.update.all(remove_unused = True)["virtualmachines"]),
May 17 11:35:16 netbox gunicorn[76783]:   File "/opt/netbox/netbox/venv/lib/python3.10/site-packages/netbox_proxbox/proxbox_api/update.py", line 434, in all
May 17 11:35:16 netbox gunicorn[76783]:     node_updated = nodes(proxmox_json = px_node_each, proxmox_cluster = proxmox_cluster)
May 17 11:35:16 netbox gunicorn[76783]:   File "/opt/netbox/netbox/venv/lib/python3.10/site-packages/netbox_proxbox/proxbox_api/update.py", line 392, in nodes
May 17 11:35:16 netbox gunicorn[76783]:     full_update = node_full_update(netbox_node, proxmox_json, proxmox_cluster)
May 17 11:35:16 netbox gunicorn[76783]:   File "/opt/netbox/netbox/venv/lib/python3.10/site-packages/netbox_proxbox/proxbox_api/update.py", line 61, in node_full_update
May 17 11:35:16 netbox gunicorn[76783]:     interfaces_updated = updates.node.interfaces(netbox_node, proxmox_json)
May 17 11:35:16 netbox gunicorn[76783]:   File "/opt/netbox/netbox/venv/lib/python3.10/site-packages/netbox_proxbox/proxbox_api/updates/node.py", line 173, in interfaces
May 17 11:35:16 netbox gunicorn[76783]:     ntb_iface = nb.dcim.interfaces.create(device=netbox_node.id, name=iface['iface'], type='virtual', mtu=int(iface.get('mtu', 1500)), mode='tagged', tagged_vlans=[nb.ipam.vlans.get(vid=_tagged_vlans[0]).id])
tpsretard commented 1 year ago

i had a similar problem to this. It ended up being caused by my first failed attempt. I had to delete a few entires that were brought in from an incomplete sync.

devopstales commented 1 year ago

The problem is that the plugin dose not create vlans. My proxmox host has vlan tagaded interfaces so first I had to create the vlans in netbox. This slowed my problem.

ben-ihelputech commented 7 months ago

I get the same error, but for me I noticed that is happens whenever the MTU on the interface is set to 1 (match the MTU of the bridge). Removing the MTU of one (letting it be the default value of 1500) resolves the issue.

Netbox V3.6.4 Proxbox V0.0.5 Proxmox 8.0.4

Nov 20 13:43:30 netbox NetBox[287696]: level=ERROR,logger=django.request,msg=Internal Server Error: /plugins/proxbox/full_update/
                                       Traceback (most recent call last):
                                         File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
                                           response = get_response(request)
                                         File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
                                           response = wrapped_callback(request, *callback_args, **callback_kwargs)
                                         File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 104, in view
                                           return self.dispatch(request, *args, **kwargs)
                                         File "/opt/netbox/venv/lib/python3.10/site-packages/django/contrib/auth/mixins.py", line 109, in dispatch
                                           return super().dispatch(request, *args, **kwargs)
                                         File "/opt/netbox/venv/lib/python3.10/site-packages/django/views/generic/base.py", line 143, in dispatch
                                           return handler(request, *args, **kwargs)
                                         File "/opt/netbox/venv/lib/python3.10/site-packages/netbox_proxbox/views.py", line 93, in get
                                           "virtualmachines_table": VMUpdateResult(proxbox_api.update.all(remove_unused = True)["virtualmachines"]),
                                         File "/opt/netbox/venv/lib/python3.10/site-packages/netbox_proxbox/proxbox_api/update.py", line 448, in all
                                           vm_updated = virtual_machine(proxmox_json = px_vm_each)
                                         File "/opt/netbox/venv/lib/python3.10/site-packages/netbox_proxbox/proxbox_api/update.py", line 312, in virtual_machine
                                           full_update = vm_full_update(netbox_vm, proxmox_json)
                                         File "/opt/netbox/venv/lib/python3.10/site-packages/netbox_proxbox/proxbox_api/update.py", line 36, in vm_full_update
                                           interfaces_updated = updates.virtual_machine.interfaces(netbox_vm, proxmox_vm)
                                         File "/opt/netbox/venv/lib/python3.10/site-packages/netbox_proxbox/proxbox_api/updates/virtual_machine.py", line 318, in interfaces
                                           brg = nb.dcim.interfaces.get(device_id=node.id, name=_bridge)
                                       AttributeError: 'NoneType' object has no attribute 'id'