Skip to content

netbox: add orphaned_device_status and orphaned_vm_status - #564

Merged
semx merged 4 commits into
developmentfrom
feature/orphaned-object-status
Sep 9, 2026
Merged

semx merged 4 commits into
developmentfrom
feature/orphaned-object-status

Conversation

@semx

@semx semx commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Closes #514 by @berlikm and #458, his commit is in here unchanged.

The options do what #458 asked for: park a device or VM at a chosen status while it is orphaned. What needed fixing before it could land was the other half - his branch also restored a reappearing object to active, and that ran for everyone, including people who never set either option. A VM someone had deliberately put on planned would have been flipped to active on the next run.

It now only restores the status if the object still carries the exact status configured for orphans, so it only undoes what this program did itself. Anything a user or a source set is left alone. With neither option configured nothing touches a status at all.

Two things I checked while in there and left as they are: the orphan branch is gated on prune_enabled, which is right since pruning is disabled whenever a source was unavailable and we would otherwise park healthy objects; and the configured value is validated against NetBox's status list at config time, so a typo fails the run instead of writing garbage. Reworded both option descriptions to say all of that.

tests/test_orphaned_object_status.py: 3 of 13 fail without the fix - the two "option unset, status untouched" cases and the one where a user-set status must survive. Suite 137.

berlikm and others added 4 commits July 10, 2026 13:18
Closes #458

Adds two new config options to automatically set the NetBox status of
orphaned devices and VMs. When a device/VM is orphaned (source no
longer reports it), the status is changed to the configured value
(e.g. 'decommissioning'). When the object reappears in a source,
the status is restored to 'active'.

The status change is guarded by prune_enabled — if a source is
unavailable (failed to initialize), pruning is disabled which prevents
the status change. This protects against false decommissioning during
transient source outages.

Only affects NBDevice and NBVM — other prunable objects (interfaces,
IPs, etc.) don't have a status field.
@semx
semx requested a review from bb-Ricardo as a code owner September 9, 2026 23:43
@semx
semx merged commit 56d9479 into development Sep 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants