pynetbox.core.query.RequestError: The request failed with code 400 Bad Request: {'role': ['This field is required.']} with version 0.7.2 #303

Closed
opened 2024-08-13 14:59:43 +02:00 by juhnny5 · 2 comments
juhnny5 commented 2024-08-13 14:59:43 +02:00 (Migrated from github.com)

Describe the bug
As soon as I want to register a physical machine (Dell PowerEdge R620), I get the message below.

/usr/loca/usr/local/bin/netbox_agent -c /etc/netbox_agent.yaml -r

INFO:root:Creating server (serial: xxxxx) myserver
DEBUG:urllib3.connectionpool:https://netbox.example.org:443 "POST /api/dcim/devices/ HTTP/1.1" 400 36
Traceback (most recent call last):
  File "/usr/local/bin/netbox_agent", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.10/dist-packages/netbox_agent/cli.py", line 50, in main
    return run(config)
  File "/usr/local/lib/python3.10/dist-packages/netbox_agent/cli.py", line 43, in run
    server.netbox_create_or_update(config)
  File "/usr/local/lib/python3.10/dist-packages/netbox_agent/server.py", line 407, in netbox_create_or_update
    server = self._netbox_create_server(datacenter, tenant, rack)
  File "/usr/local/lib/python3.10/dist-packages/netbox_agent/server.py", line 272, in _netbox_create_server
    new_server = nb.dcim.devices.create(
  File "/usr/local/lib/python3.10/dist-packages/pynetbox/core/endpoint.py", line 309, in create
    ).post(args[0] if args else kwargs)
  File "/usr/local/lib/python3.10/dist-packages/pynetbox/core/query.py", line 387, in post
    return self._make_call(verb="post", data=data)
  File "/usr/local/lib/python3.10/dist-packages/pynetbox/core/query.py", line 282, in _make_call
    raise RequestError(req)
pynetbox.core.query.RequestError: The request failed with code 400 Bad Request: {'role': ['This field is required.']}

Expected behavior
A clear and concise description of what you expected to happen :

As soon as I want to register a physical machine (Dell PowerEdge R620), I get the message below.

Configuration file
Paste here your netbox agent configuration file :

netbox:
 url: https://netbox.example.org
 token: xxxxx
device:
 server_role: "Server"

# Enable datacenter location feature in Netbox
datacenter_location:
 driver: "cmd:cat /etc/qualification | tr [A-Z] [a-z]"
 regex: "datacenter: \"(?P<datacenter>[A-Za-z0-9]+)\""

tenant:
 driver: "cmd:cat /etc/qualification | tr [A-Z] [a-z]"
 regex: "tenant: \"(?P<tenant>[A-Za-z0-9]+)\""

# Network configuration
network:
 # Regex to ignore interfaces
 ignore_interfaces: (lo.*|dummy.*|docker.*)
 # Regex to ignore IP addresses
 ignore_ips: (127\.0\.0\..*)
 # enable auto-cabling by parsing LLDP answers
 lldp: True

inventory: True

Environment:

  • OS: Ubuntu 22.04 LTS
  • Netbox agent version 0.7.2
**Describe the bug** As soon as I want to register a physical machine (Dell PowerEdge R620), I get the message below. ``` /usr/loca/usr/local/bin/netbox_agent -c /etc/netbox_agent.yaml -r INFO:root:Creating server (serial: xxxxx) myserver DEBUG:urllib3.connectionpool:https://netbox.example.org:443 "POST /api/dcim/devices/ HTTP/1.1" 400 36 Traceback (most recent call last): File "/usr/local/bin/netbox_agent", line 8, in <module> sys.exit(main()) File "/usr/local/lib/python3.10/dist-packages/netbox_agent/cli.py", line 50, in main return run(config) File "/usr/local/lib/python3.10/dist-packages/netbox_agent/cli.py", line 43, in run server.netbox_create_or_update(config) File "/usr/local/lib/python3.10/dist-packages/netbox_agent/server.py", line 407, in netbox_create_or_update server = self._netbox_create_server(datacenter, tenant, rack) File "/usr/local/lib/python3.10/dist-packages/netbox_agent/server.py", line 272, in _netbox_create_server new_server = nb.dcim.devices.create( File "/usr/local/lib/python3.10/dist-packages/pynetbox/core/endpoint.py", line 309, in create ).post(args[0] if args else kwargs) File "/usr/local/lib/python3.10/dist-packages/pynetbox/core/query.py", line 387, in post return self._make_call(verb="post", data=data) File "/usr/local/lib/python3.10/dist-packages/pynetbox/core/query.py", line 282, in _make_call raise RequestError(req) pynetbox.core.query.RequestError: The request failed with code 400 Bad Request: {'role': ['This field is required.']} ``` **Expected behavior** A clear and concise description of what you expected to happen : As soon as I want to register a physical machine (Dell PowerEdge R620), I get the message below. **Configuration file** Paste here your netbox agent configuration file : ``` netbox: url: https://netbox.example.org token: xxxxx device: server_role: "Server" # Enable datacenter location feature in Netbox datacenter_location: driver: "cmd:cat /etc/qualification | tr [A-Z] [a-z]" regex: "datacenter: \"(?P<datacenter>[A-Za-z0-9]+)\"" tenant: driver: "cmd:cat /etc/qualification | tr [A-Z] [a-z]" regex: "tenant: \"(?P<tenant>[A-Za-z0-9]+)\"" # Network configuration network: # Regex to ignore interfaces ignore_interfaces: (lo.*|dummy.*|docker.*) # Regex to ignore IP addresses ignore_ips: (127\.0\.0\..*) # enable auto-cabling by parsing LLDP answers lldp: True inventory: True ``` **Environment:** - OS: Ubuntu 22.04 LTS - Netbox agent version 0.7.2
msteggink commented 2024-08-13 21:07:34 +02:00 (Migrated from github.com)

This is a known issue but has not been merged yet. See: https://github.com/Solvik/netbox-agent/pull/289

This is a known issue but has not been merged yet. See: https://github.com/Solvik/netbox-agent/pull/289
CllaudiaB commented 2024-09-05 15:57:32 +02:00 (Migrated from github.com)

@juhnny5 Hello
I can confirm that you need to replace device_role with role.
I'll look into this in the next few weeks.

@juhnny5 Hello I can confirm that you need to replace device_role with role. I'll look into this in the next few weeks.
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#303
No description provided.