netbox-agent
netbox-agent copied to clipboard
'1 is not a valid choice' when adding interface
Describe the bug
when running netbox_agent -c netbox_agent.yml --register
it breaks with:
INFO:root:Create new IP 172.19.0.3/24 on enp130s0f0
DEBUG:urllib3.connectionpool:https://netbox.host:443 "POST /api/ipam/ip-addresses/ HTTP/1.1" 400 39
Traceback (most recent call last):
File "/usr/local/bin/netbox_agent", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python3.6/dist-packages/netbox_agent/cli.py", line 44, in main
return run(config)
File "/usr/local/lib/python3.6/dist-packages/netbox_agent/cli.py", line 39, in run
server.netbox_create_or_update(config)
File "/usr/local/lib/python3.6/dist-packages/netbox_agent/server.py", line 292, in netbox_create_or_update
self.network.create_or_update_netbox_network_cards()
File "/usr/local/lib/python3.6/dist-packages/netbox_agent/network.py", line 444, in create_or_update_netbox_network_cards
self.create_or_update_netbox_ip_on_interface(ip, interface)
File "/usr/local/lib/python3.6/dist-packages/netbox_agent/network.py", line 319, in create_or_update_netbox_ip_on_interface
status=1,
File "/usr/local/lib/python3.6/dist-packages/pynetbox/core/endpoint.py", line 283, in create
).post(args[0] if args else kwargs)
File "/usr/local/lib/python3.6/dist-packages/pynetbox/core/query.py", line 383, in post
return self._make_call(verb="post", data=data)
File "/usr/local/lib/python3.6/dist-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: {'status': ['1 is not a valid choice.']}
Expected behavior It should create the interface with the ip
Configuration file
# Netbox configuration
netbox:
url: 'https://netbox.host'
token: XXXX
network:
ignore_interfaces: "(dummy.*|docker.*)"
ignore_ips: (127\.0\.0\..*|.*:.*)
datacenter_location:
driver: "cmd:cat /root/datacenter"
regex: "(.*)"
inventory: true
Environment:
- OS: Ubuntu 18.04.3
- Netbox agent version v0.6.2
- Netbox version v2.11.3
We found there is a switch in how it stores status, so by changing from ' status=1' to 'status="active", we got past that problem
Can confirm.
I have the "active" status
query_params = { 'address': ip, 'status': "active", 'assigned_object_type': self.assigned_object_type, 'assigned_object_id': interface.id }
if there is no ipmi on the server, I can collect the information