fix: DCIM rack U count auto-update when adding/removing devices via C…#728
Draft
ljluestc wants to merge 1 commit intoveops:masterfrom
Draft
fix: DCIM rack U count auto-update when adding/removing devices via C…#728ljluestc wants to merge 1 commit intoveops:masterfrom
ljluestc wants to merge 1 commit intoveops:masterfrom
Conversation
…I relations - Add DCIM rack U count recalculation logic to ci_relation_cache() and ci_relation_delete() - Automatically update rack free_u_count when devices are added/removed via CI relations - Fixes issue veops#676: DCIM cabinet available U count not automatically calculated - No more manual rack editing required after adding physical machines Technical details: - Detects DCIM rack + device relations using ci_type.name and U attributes - Calls RackManager.calc_u_free_count() to recalculate available U space - Updates rack CI with new free_u_count value - Includes proper error handling and logging - Maintains backward compatibility with existing DCIM interface
Collaborator
|
Thanks for this contribution! I have a few suggestions to improve code quality:
Please update these points and I'll be happy to approve! |
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.
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