From aa8dd795c48232c61e27eb7a9bc6ac6eca60d582 Mon Sep 17 00:00:00 2001 From: Victor Golovanenko Date: Wed, 21 Apr 2021 20:53:55 +0300 Subject: [PATCH] FIxed a bug when correcting interfaces with the same name but different types --- netbox_interface_sync/views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/netbox_interface_sync/views.py b/netbox_interface_sync/views.py index d4537c4..1d3e771 100644 --- a/netbox_interface_sync/views.py +++ b/netbox_interface_sync/views.py @@ -72,15 +72,15 @@ class InterfaceComparisonView(LoginRequiredMixin, PermissionRequiredMixin, View) map(int, filter(lambda x: x.isdigit(), request.POST.getlist("remove_from_device"))) ) + # Remove selected interfaces from the device and count them + interfaces_deleted = Interface.objects.filter(id__in=remove_from_device).delete()[0] + # Add selected interfaces to the device and count them add_to_device_interfaces = InterfaceTemplate.objects.filter(id__in=add_to_device) interfaces_created = len(Interface.objects.bulk_create([ Interface(device=device, name=i.name, type=i.type) for i in add_to_device_interfaces ])) - # Remove selected interfaces from the device and count them - interfaces_deleted = Interface.objects.filter(id__in=remove_from_device).delete()[0] - # Getting and validating a list of interfaces to rename fix_name_interfaces = filter(lambda i: str(i.id) in request.POST.getlist("fix_name"), interfaces) # Casting interface templates into UnifiedInterface objects for proper comparison with interfaces for renaming