vmware: add vm_status_on_create and vm_status_preserve - #563
Merged
Merged
Conversation
vm_status_on_create (default: active) defines the status a VM gets assigned when netbox-sync creates it as a new NetBox VM. The default matches previous behavior in practice, since offline VMs are skipped on the first parsing pass and newly created VMs were therefore always powered on and set to 'active'. vm_status_preserve (default: planned, staged, decommissioning) defines a list of NetBox VM statuses which are never changed on updates. This prevents power-state syncing from silently reverting human-set lifecycle states like 'planned' or 'staged' to 'active'. Set to an empty value to always update the VM status (previous behavior). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> (cherry picked from commit a64bdaa)
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.
Closes #528 by @eric-eisenhart, commits are his. Also covers #458.
Both options are useful and the implementation is his, including the parsing and the validation against the allowed NetBox statuses. The only thing I changed is the defaults: he shipped them as
activeandplanned, staged, decommissioning, which would have changed every existing installation on upgrade - a powered-off VM would have been created asactive, and three statuses would silently stop following the power state. Both are unset now, so nothing happens unless you configure them, and the example config says so.Had to resolve one conflict in
connection.py, his status block landed next to the device-type guard from #556. Both kept.tests/test_vmware_vm_status_options.pycovers the default path for new and existing VMs, both options doing their job when set, and that a config which does not mention them parses to unset - that last one fails if the defaults come back. Suite 120.