'1 is not a valid choice' when adding interface #191

Open
opened 2021-08-18 10:18:52 +02:00 by Joshi425 · 4 comments
Joshi425 commented 2021-08-18 10:18:52 +02:00 (Migrated from github.com)

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
**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
KivraChristoffer commented 2021-09-02 10:22:22 +02:00 (Migrated from github.com)

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

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
sylr commented 2022-08-08 15:56:15 +02:00 (Migrated from github.com)

Can confirm.

Can confirm.
orlov88 commented 2022-09-19 12:17:05 +02:00 (Migrated from github.com)

I have the "active" status
query_params = { 'address': ip, 'status': "active", 'assigned_object_type': self.assigned_object_type, 'assigned_object_id': interface.id }

I have the "active" status `query_params = { 'address': ip, 'status': "active", 'assigned_object_type': self.assigned_object_type, 'assigned_object_id': interface.id }`
orlov88 commented 2022-09-19 12:25:46 +02:00 (Migrated from github.com)

if there is no ipmi on the server, I can collect the information

if there is no ipmi on the server, I can collect the information
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: DGNum/netbox-agent#191
No description provided.