netdevopsbr / netbox-proxbox

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

[ SOLVED ] proxmox_cluster['name']: object has no attribute 'name' #119

Closed Langlais115 closed 1 year ago

Langlais115 commented 1 year ago

I've got an issue with a proxmox cluster and the "name" attribute:

<class 'AttributeError'>

'NoneType' object has no attribute 'name'

Python version: 3.9.2
NetBox version: 3.5.1
2023-05-31 12:14:24,972 urllib3.connectionpool DEBUG: http://localhost:8001 "GET /api/dcim/devices/?name=proxmox01&limit=0 HTTP/1.1" 200 1743
2023-05-31 12:14:24,977 django.request ERROR: Internal Server Error: /plugins/proxbox/full_update/
Traceback (most recent call last):
  File "/opt/netbox-3.5.1/venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 56, in inner
    response = get_response(request)
  File "/opt/netbox-3.5.1/venv/lib/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-3.5.1/venv/lib/python3.9/site-packages/django/views/generic/base.py", line 103, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/netbox-3.5.1/venv/lib/python3.9/site-packages/django/contrib/auth/mixins.py", line 109, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/opt/netbox-3.5.1/venv/lib/python3.9/site-packages/django/views/generic/base.py", line 142, in dispatch
    return handler(request, *args, **kwargs)
  File "/opt/netbox-3.5.1/venv/lib/python3.9/site-packages/netbox_proxbox/views.py", line 93, in get
    "virtualmachines_table": VMUpdateResult(proxbox_api.update.all(remove_unused = True)["virtualmachines"]),
  File "/opt/netbox-3.5.1/venv/lib/python3.9/site-packages/netbox_proxbox/proxbox_api/update.py", line 434, in all
    node_updated = nodes(proxmox_json = px_node_each, proxmox_cluster = proxmox_cluster)
  File "/opt/netbox-3.5.1/venv/lib/python3.9/site-packages/netbox_proxbox/proxbox_api/update.py", line 392, in nodes
    full_update = node_full_update(netbox_node, proxmox_json, proxmox_cluster)
  File "/opt/netbox-3.5.1/venv/lib/python3.9/site-packages/netbox_proxbox/proxbox_api/update.py", line 60, in code_full_update
    cluster_updated = updates.node.cluster(netbox_node, proxmox_json, proxmox_cluster)
  File "/opt/netbox-3.5.1/venv/lib/python3.9/site-packages/netbox_proxbox/proxbox_api/updates/node.py", line 64, in cluster
    if netbox_node.cluster.name != proxmox_cluster['name']:
AttributeError: 'NoneType' object has no attribute 'name'

Solution

If you have this issue, make sure that you assign devices to your cluster. In my case this have solved my issue.

emersonfelipesp commented 1 year ago

I will later make sure if there's any automatic way to do this. Thank you for the feedback @Langlais115