Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/1176.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed vSphere nautobot adapter sync_complete to handle missing VirtualMachine gracefully instead of raising DoesNotExist exception.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@
def sync_complete(self, source, diff, flags: DiffSyncFlags = DiffSyncFlags.NONE, logger=None):
"""Update devices with their primary IPs once the sync is complete."""
for info in self._primary_ips:
vm = VirtualMachine.objects.get(**info["device"])
try:
vm = VirtualMachine.objects.get(**info["device"])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we get test coverage on this?

except VirtualMachine.DoesNotExist:
self.job.logger.warning(
f"VirtualMachine not found for {info['device']}, skipping primary IP assignment."
)
continue

Check warning on line 56 in nautobot_ssot/integrations/vsphere/diffsync/adapters/adapter_nautobot.py

View workflow job for this annotation

GitHub Actions / unittest_report (3.13, postgresql, stable)

Missing coverage

Missing coverage on lines 52-56
for ip in ["primary_ip4", "primary_ip6"]:
if info[ip]:
setattr(vm, ip, IPAddress.objects.get(host=info[ip]))
Expand Down
Loading