fix allocated_draw for inactive PSU #168

Merged
z0nker merged 2 commits from master into master 2020-09-07 14:20:32 +02:00
z0nker commented 2020-09-07 10:26:12 +02:00 (Migrated from github.com)

If you have a setup when one of the power supplies is in passive mode, you may get an error from the API:

DEBUG:urllib3.connectionpool:https://netbox.domain.com:443 "PATCH /api/dcim/power-ports/16/ HTTP/1.1" 400 71
Traceback (most recent call last):
File "/opt/rh/rh-python36/root/usr/bin/netbox_agent", line 11, in
sys.exit(main())
File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/netbox_agent/cli.py", line 44, in main
return run(config)
File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/netbox_agent/cli.py", line 39, in run
server.netbox_create_or_update(config)
File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/netbox_agent/server.py", line 301, in netbox_create_or_update
self.power.report_power_consumption()
File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/netbox_agent/power.py", line 123, in report_power_consumption
nb_psu.save()
File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pynetbox/core/response.py", line 391, in save
if req.patch({i: serialized[i] for i in diff}):
File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pynetbox/core/query.py", line 409, in patch
return self._make_call(verb="patch", data=data)
File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pynetbox/core/query.py", line 274, in _make_call
raise RequestError(req)
pynetbox.core.query.RequestError: The request failed with code 400 Bad Request: {'allocated_draw': ['Ensure this value is greater than or equal to 1.']}

If you have a setup when one of the power supplies is in passive mode, you may get an error from the API: DEBUG:urllib3.connectionpool:https://netbox.domain.com:443 "PATCH /api/dcim/power-ports/16/ HTTP/1.1" 400 71 Traceback (most recent call last): File "/opt/rh/rh-python36/root/usr/bin/netbox_agent", line 11, in <module> sys.exit(main()) File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/netbox_agent/cli.py", line 44, in main return run(config) File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/netbox_agent/cli.py", line 39, in run server.netbox_create_or_update(config) File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/netbox_agent/server.py", line 301, in netbox_create_or_update self.power.report_power_consumption() File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/netbox_agent/power.py", line 123, in report_power_consumption nb_psu.save() File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pynetbox/core/response.py", line 391, in save if req.patch({i: serialized[i] for i in diff}): File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pynetbox/core/query.py", line 409, in patch return self._make_call(verb="patch", data=data) File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/pynetbox/core/query.py", line 274, in _make_call raise RequestError(req) pynetbox.core.query.RequestError: The request failed with code 400 Bad Request: {'allocated_draw': ['Ensure this value is greater than or equal to 1.']}
Solvik commented 2020-09-07 14:20:58 +02:00 (Migrated from github.com)

thanks for the contribution @z0nker :)

thanks for the contribution @z0nker :)
Sign in to join this conversation.
No description provided.