Description
When dmidecode reports multiple power supplies with identical data (commonly seen with generic/placeholder values like "Default string"), the agent attempts to create duplicate power ports in Netbox, which fails with a 400 error.
Error Message
INFO:root:Creating PSU Default string (Default string - Default string), NoneW
DEBUG:urllib3.connectionpool:https://netbox.example.com:443 "POST /api/dcim/power-ports/ HTTP/1.1" 201 781
INFO:root:Creating PSU Default string (Default string - Default string), NoneW
DEBUG:urllib3.connectionpool:https://netbox.example.com:443 "POST /api/dcim/power-ports/ HTTP/1.1" 400 68
Traceback (most recent call last):
File "/usr/local/bin/netbox_agent", line 8, in <module>
sys.exit(main())
File "/opt/netbox-agent/netbox_agent/cli.py", line 68, in main
return run(config)
File "/opt/netbox-agent/netbox_agent/cli.py", line 63, in run
server.netbox_create_or_update(config)
File "/opt/netbox-agent/netbox_agent/server.py", line 439, in netbox_create_or_update
self.power.create_or_update_power_supply()
File "/opt/netbox-agent/netbox_agent/power.py", line 84, in create_or_update_power_supply
nb_psu = nb.dcim.power_ports.create(**psu)
pynetbox.core.query.RequestError: The request failed with code 400 Bad Request: {'__all__': ['Power port with this Device and Name already exists.']}
Example dmidecode Output
System Power Supply
Power Unit Group: 1
Location: Default string
Name: Default string
Manufacturer: Default string
Serial Number: Default string
Asset Tag: Default string
Model Part Number: Default string
System Power Supply
Power Unit Group: 1
Location: Default string
Name: Default string
Manufacturer: Default string
Serial Number: Default string
Asset Tag: Default string
Model Part Number: Default string
System Power Supply
Power Unit Group: 1
Location: Default string
Name: Default string
Manufacturer: Default string
Serial Number: Default string
Asset Tag: Default string
Model Part Number: Default string
Root Cause
In power.py, the get_power_supply() method:
- Uses the serial number as the power port name
- If the serial number is empty, it defaults to "N/A"
- Multiple PSUs with identical data all get name="N/A" and the same description
- Netbox rejects the duplicate when trying to create the second PSU
Expected Behavior
The agent should deduplicate PSUs with identical attributes before attempting to create them in Netbox.
Environment
- Netbox Agent Version: master branch
- Hardware: Systems with multiple PSUs reporting generic dmidecode data
- Netbox Version: >= 3.7
Proposed Solution
Add deduplication logic in get_power_supply() to track PSUs by a tuple of (serial_number, description, max_power) and skip duplicates before returning the list.
A fix is available in PR #401.
Description
When dmidecode reports multiple power supplies with identical data (commonly seen with generic/placeholder values like "Default string"), the agent attempts to create duplicate power ports in Netbox, which fails with a 400 error.
Error Message
Example dmidecode Output
Root Cause
In power.py, the
get_power_supply()method:Expected Behavior
The agent should deduplicate PSUs with identical attributes before attempting to create them in Netbox.
Environment
Proposed Solution
Add deduplication logic in
get_power_supply()to track PSUs by a tuple of (serial_number, description, max_power) and skip duplicates before returning the list.A fix is available in PR #401.