netbox-sync
netbox-sync copied to clipboard
[VCenter] IP addresses marked as orphan when VM is turned off
Hi, I recently noted that if a VM is turned off the IPs synced in NetBox are marked as orphans. This could lead to a misunderstanding in IPAM documentation because after "orphans cleanup/deletion" that IPs are marked as "free to use" in NetBox but actually they aren't.
Currently running v1.2.3
Hi, I have a look. This is not meant to happen.
Yeah thank you, in the meantime I'll try to do some other tests.
Hey @rizlas,
I just checked and figured this is the default. If the VM is stopped, the IP address is not visible via the VMWare API. The IP address was initially found on this interface and added via netbox-sync. Now the IP address can't be found anymore and therefore marked orphaned.
Unlucky, thank you for digging into this. Sorry also about the issue.
Unlucky, thank you for digging into this. Sorry also about the issue.
Don't be sorry about opening an issue. It usually is an "issue" or "unwanted behaviour".
I also thought about this. It seems a bit difficult to implement but: If an IP address belongs to a VM which is currently only "inactive" then we should refrain from marking it as orphan. This is a totally valid use case.
Good point! Maybe netbox-sync can change only the status of the IpAddress to Reserverd when a VM has an offline status? Just an idea..
Hi, i JUST implemented this. Now the IP address will not be marked orphaned if it belongs to a device/vm object which is present but not in status "active".
Amazing! Thank you!
fix is pushed to "development" branch. Can you please test it out?
So i tried:
- if delete orphan is set to 0, IP will be deleted anyway
- Cleaning the tag before run. After run no tag added - Raised delete orphan > 0. Tag is NOT removed
Hi, I don't really know what are the preconditions to your findings. Unfortunately I won't be able to test it by myself.
here is the relevant code: https://github.com/bb-Ricardo/netbox-sync/blob/c4e0e7772604bf2b0dab662dca65d00fffb9d719/module/netbox/inventory.py#L314-L325
Enabling or disabling prune_enabled
and changing prune_delay_in_days
has no effect on tagging objects as orphaned.
Does this information help?
Preconditions are: VM has state set to Offline, IP address bonded to that VM is already been tagged has orphan.
A better explanation.. Currently the update works, but it's is not backward compatible especially if a tag is already there it is not cleaned.
This is still ongoing?
Hi, yes this is still ongoing. Need to take care of it when syncing from NetBox. Only did the part with syncing to NetBox.
Currently on holidays and will have a look once I'm back.
Hi, yes this is still ongoing. Need to take care of it when syncing from NetBox. Only did the part with syncing to NetBox.
Currently on holidays and will have a look once I'm back.
Ah don't worry. It was only for information. Enjoy your holiday 👍🏻
Hi @rizlas,
sorry for the long wait. I'm back again and I just pushed another change to development
. Would you mind testing it? This should solve your issue.
You can close the ticket if the issue is resolved.
Hi, thank you. It is working.
Test:
- Turn off a Vm
- Sync
- IP not removed nor tagged as orphan
Thank you for testing