From ee3682087e330114cb69a9212f0aaa573b575d41 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Wed, 5 Aug 2020 00:06:05 +0200 Subject: [PATCH 1/2] Don't use disabled ip for administration purpose --- machines/models.py | 4 ++-- preferences/models.py | 2 +- topologie/models.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/machines/models.py b/machines/models.py index 19d252b7..d5eb15ca 100644 --- a/machines/models.py +++ b/machines/models.py @@ -1365,11 +1365,11 @@ class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model): DHCPv6). """ if preferences.models.OptionalMachine.get_cached_value("ipv6_mode") == "SLAAC": - return self.ipv6list.all() + return self.ipv6list.filter(active=True) elif ( preferences.models.OptionalMachine.get_cached_value("ipv6_mode") == "DHCPV6" ): - return self.ipv6list.filter(slaac_ip=False) + return self.ipv6list.filter(active=True).filter(slaac_ip=False) else: return [] diff --git a/preferences/models.py b/preferences/models.py index b012b12b..68b8286c 100644 --- a/preferences/models.py +++ b/preferences/models.py @@ -369,7 +369,7 @@ class OptionalTopologie(AclMixin, PreferencesModel): def return_ips_dict(interfaces): return { "ipv4": [str(interface.ipv4) for interface in interfaces], - "ipv6": Ipv6List.objects.filter(interface__in=interfaces).values_list( + "ipv6": Ipv6List.objects.filter(interface__in=interfaces).filter(active=True).values_list( "ipv6", flat=True ), } diff --git a/topologie/models.py b/topologie/models.py index 85f6d188..94ecee87 100644 --- a/topologie/models.py +++ b/topologie/models.py @@ -377,7 +377,7 @@ class Switch(Machine): def return_ips_dict(interfaces): return { "ipv4": [str(interface.ipv4) for interface in interfaces], - "ipv6": Ipv6List.objects.filter(interface__in=interfaces).values_list( + "ipv6": Ipv6List.objects.filter(interface__in=interfaces).filter(active=True).values_list( "ipv6", flat=True ), } From 4333e5f804add0955e43cf0c278e62ffad666090 Mon Sep 17 00:00:00 2001 From: chirac Date: Fri, 7 Aug 2020 19:25:34 +0200 Subject: [PATCH 2/2] Update comments models.py --- topologie/models.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/topologie/models.py b/topologie/models.py index 94ecee87..9607e811 100644 --- a/topologie/models.py +++ b/topologie/models.py @@ -366,6 +366,11 @@ class Switch(Machine): @cached_property def get_radius_servers_objects(self): + """Return radius servers objects for Switchs provisioning, via REST API. + + Returns : + Interfaces objects query_set for the Role type radius-server + """ return Role.all_interfaces_for_roletype("radius-server").filter( machine_type__in=MachineType.objects.filter( interface__in=self.interface_set.all() @@ -374,6 +379,12 @@ class Switch(Machine): @cached_property def get_radius_servers(self): + """Return radius servers string, ipv4 and ipv6 for Switchs provisioning, + via REST API. + + Returns : + Ip dict of interfaces for the Role type radius-server + """ def return_ips_dict(interfaces): return { "ipv4": [str(interface.ipv4) for interface in interfaces],