Fix duplicate PSU creation when dmidecode reports identical PSUs#401
Open
shbatm wants to merge 1 commit intoSolvik:masterfrom
Open
Fix duplicate PSU creation when dmidecode reports identical PSUs#401shbatm wants to merge 1 commit intoSolvik:masterfrom
shbatm wants to merge 1 commit intoSolvik:masterfrom
Conversation
When dmidecode reports multiple power supplies with identical data (common with generic/placeholder values like 'Default string'), the agent would attempt to create duplicate power ports in Netbox, causing a 400 error on the second attempt. Added deduplication logic in get_power_supply() to track PSUs by a tuple of (serial_number, description, max_power) and skip duplicates. This prevents attempting to create multiple PSUs with the same name in Netbox. Example case: System with 3 PSUs all reporting 'Default string' for all fields would previously try to create 3 PSUs named 'N/A' with identical descriptions, now only creates one. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #402
When dmidecode reports multiple power supplies with identical data (common with generic/placeholder values like "Default string"), the agent attempts to create duplicate power ports in Netbox. This causes a 400 error:
Example dmidecode output:
Since all PSUs have empty serial numbers, they all get name="N/A" and identical descriptions, causing Netbox to reject the duplicates.
Solution
Added deduplication logic in power.py:18-64
get_power_supply()method:(serial_number, description, max_power)Changes
seen_psusset to track unique PSU combinationsTesting
With this fix, systems reporting multiple identical PSUs will only create one power port in Netbox instead of failing on duplicate creation.
🤖 Generated with Claude Code