fix: DCIM rack U count auto-update when adding/removing devices via C… #728
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.
Fix: DCIM Rack Available U Count Auto-Update
Problem
GitHub Issue #676: DCIM cabinet available U count not automatically calculated when adding physical machines through CI relations.
Current Behavior
free_u_countis only updated when using the DCIM web interface (RackManager.add_device()/remove_device())Impact
Users must manually edit rack properties and save to trigger U count recalculation after adding devices, which is inefficient and error-prone.
Solution
Modified
ci_relation_cache()andci_relation_delete()functions incmdb-api/api/tasks/cmdb.pyto automatically detect and handle DCIM rack U count updates.Technical Implementation
Files Changed:
cmdb-api/api/tasks/cmdb.py(39 lines added)Key Changes:
from api.lib.cmdb.const import BuiltinModelEnumci_relation_cache()to detect DCIM rack + device relationsci_relation_delete()to detect DCIM rack + device relation removalsRackManager.calc_u_free_count()Code Logic
Trigger Conditions
ci_type.name == 'dcim_rack')u_startis not None)free_u_countrecalculation