netdevopsbr / netbox-proxbox

Netbox Plugin for integration between Proxmox and Netbox
Apache License 2.0
349 stars 53 forks source link

OS error: 'coroutine' object has no attribute 'id' #129

Open islepnev opened 1 year ago

islepnev commented 1 year ago

Hello, installed from git devel, followed the instructions. NetBox 3.5.6 Proxmox 8.0.3, 7.4.16 (same problems)

There are already nodes in netbox, it should not be a problem, but something went wrong and I got empty result after pressing "Proxmox Update" button:

[
    {
        "message": "OS error: 'coroutine' object has no attribute 'id'"
    }
]

Here is the log:

Jul 21 20:12:11 netbox.example.com gunicorn[122137]: Start process Sequential
Jul 21 20:12:11 netbox.example.com gunicorn[122137]: Processing data for: pve1.example.com
Jul 21 20:12:11 netbox.example.com gunicorn[122137]: [Proxbox - Netbox plugin | Update All]
Jul 21 20:12:11 netbox.example.com gunicorn[122137]: /opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/create/virtualization.py:86: RuntimeWarning: coroutine 'tag' was never awaited
Jul 21 20:12:11 netbox.example.com gunicorn[122137]:   search_tag = cluster_proxbox.tags.index(extras.tag())
Jul 21 20:12:11 netbox.example.com gunicorn[122137]: RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Jul 21 20:12:11 netbox.example.com gunicorn[122137]: WARNING:root:[WARNING] Cluster with the same name as C5 already exists.
Jul 21 20:12:11 netbox.example.com gunicorn[122137]: > Proxbox will create another one with (2) in the name
Jul 21 20:12:11 netbox.example.com gunicorn[122137]: <coroutine object tag at 0x7fc3f25dbcc0> is not in list
Jul 21 20:12:11 netbox.example.com gunicorn[122137]: /opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/create/virtualization.py:117: RuntimeWarning: coroutine 'tag' was never awaited
Jul 21 20:12:11 netbox.example.com gunicorn[122137]:   tags = [extras.tag().id]
Jul 21 20:12:11 netbox.example.com gunicorn[122137]: RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Jul 21 20:12:11 netbox.example.com gunicorn[122137]: CLUSTER...
Jul 21 20:12:11 netbox.example.com gunicorn[122137]: NODES...
Jul 21 20:12:12 netbox.example.com gunicorn[122137]: /opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py:425: RuntimeWarning: coroutine 'tag' was never awaited
Jul 21 20:12:12 netbox.example.com gunicorn[122137]:   search_tag = netbox_search.tags.index(extras.tag())
Jul 21 20:12:12 netbox.example.com gunicorn[122137]: RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Jul 21 20:12:12 netbox.example.com gunicorn[122137]: WARNING:root:[WARNING] Device with the same name as pve1 already exists.
Jul 21 20:12:12 netbox.example.com gunicorn[122137]: > Proxbox will create another one with (2) in the name
Jul 21 20:12:12 netbox.example.com gunicorn[122137]: <coroutine object tag at 0x7fc3f1c4dbc0> is not in list
Jul 21 20:12:12 netbox.example.com gunicorn[122137]: /opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/create/dcim.py:137: RuntimeWarning: coroutine 'role' was never awaited
Jul 21 20:12:12 netbox.example.com gunicorn[122137]:   node_json["device_role"] = extras.role(role_id = NETBOX_NODE_ROLE_ID).id
Jul 21 20:12:12 netbox.example.com gunicorn[122137]: RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Jul 21 20:12:12 netbox.example.com gunicorn[122137]: OS error: 'coroutine' object has no attribute 'id'
Jul 21 20:12:12 netbox.example.com gunicorn[122137]: --- 0.5793492794036865 seconds ---
emersonfelipesp commented 1 year ago

I'm aware of this error, try using v0.0.5 while I solve it

chodorenko commented 1 year ago

@emersonfelipesp Have the same issue on developer version. I test multi-cluster and revert netbox_proxbox/proxbox_api/init.py to old version for normal load function load work as there redefine 'password': None in plugins.py for use token and retrieve same error

netbox2_netbox.    | Start process Sequential
netbox2_netbox.    | Processing data for: 85.206.X.X
netbox2_netbox.    | [Proxbox - Netbox plugin | Update All]
netbox2_netbox.    | 🧬 loaded config '/etc/netbox/config/ldap/ldap_config.py'
netbox2_netbox.    | 🧬 loaded config '/etc/netbox/config/ldap/extra.py'
netbox2_netbox.    | 127.0.0.1 - - [31/Jul/2023:14:51:24 +0000] "GET /api/virtualization/cluster-types/?name=Proxmox&slug=proxmox&limit=0 HTTP/1.1" 200 396 "-" "python-requests/2.31.0"
netbox2_netbox.    | 127.0.0.1 - - [31/Jul/2023:14:51:24 +0000] "GET /api/virtualization/clusters/?name=DC-101&type=proxmox&limit=0 HTTP/1.1" 200 52 "-" "python-requests/2.31.0"
netbox2_netbox.    | 127.0.0.1 - - [31/Jul/2023:14:51:24 +0000] "GET /api/virtualization/cluster-types/?name=Proxmox&slug=proxmox&limit=0 HTTP/1.1" 200 396 "-" "python-requests/2.31.0"
netbox2_netbox.    | /opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/create/virtualization.py:134: RuntimeWarning: coroutine 'tag' was never awaited
netbox2_netbox.    |   return f"Error creating the '{proxmox_cluster_name}' cluster. Possible errors: the name '{proxmox_cluster_name}' is already used."
netbox2_netbox.    | RuntimeWarning: Enable tracemalloc to get the object allocation traceback
netbox2_netbox.    |
netbox2_netbox.    |
netbox2_netbox.    |
netbox2_netbox.    | CLUSTER...
netbox2_netbox.    | [OK] Cluster created. -> Error creating the 'DC-101' cluster. Possible errors: the name 'DC-101' is already used.
netbox2_netbox.    |
netbox2_netbox.    |
netbox2_netbox.    |
netbox2_netbox.    | NODES...
netbox2_netbox.    | 127.0.0.1 - - [31/Jul/2023:14:51:24 +0000] "GET /api/dcim/devices/?name=prx1&limit=0 HTTP/1.1" 200 52 "-" "python-requests/2.31.0"
netbox2_netbox.    | OS error: 'coroutine' object has no attribute 'id'
netbox2_netbox.    | /opt/netbox/netbox/netbox-proxbox/netbox_proxbox/proxbox_api/update.py:531: RuntimeWarning: coroutine 'role' was never awaited
netbox2_netbox.    |   results.append(output)
netbox2_netbox.    | RuntimeWarning: Enable tracemalloc to get the object allocation traceback
netbox2_netbox.    | --- 0.33696579933166504 seconds ---
netbox2_netbox.    | 10.0.0.2 - - [31/Jul/2023:14:51:25 +0000] "POST /plugins/proxbox/single_update/ HTTP/1.0" 200 85509 "https://netbox/plugins/proxbox/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 
netbox2_netbox.    | 127.0.0.1 - - [31/Jul/2023:14:51:28 +0000] "GET /api/ HTTP/1.1" 200 510 "-" "curl/7.81.0"
alryaz commented 12 months ago

This regression is introduced by https://github.com/netdevopsbr/netbox-proxbox/commit/42a2bc5affd8c9ba643bb3d2690053428f28b443

Code is shared between pynetbox calls and FastAPI.