From 27374d7a4320d1357d07a7e9fd4180f3c1685fa3 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Mon, 9 Jul 2018 22:59:47 +0200 Subject: [PATCH] =?UTF-8?q?Serialisation=20des=20r=C3=A9glages=20pour=20la?= =?UTF-8?q?=20provision?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/serializers.py | 4 +++- topologie/models.py | 13 ++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/api/serializers.py b/api/serializers.py index a0726dd9..6e732ff8 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -723,7 +723,9 @@ class SwitchPortSerializer(serializers.ModelSerializer): class Meta: model = topologie.Switch - fields = ('short_name', 'complete_name', 'model', 'switchbay', 'ports', 'ipv4', 'ipv6', 'subnet', 'subnet6') + fields = ('short_name', 'model', 'switchbay', 'ports', 'ipv4', 'ipv6', + 'subnet', 'subnet6', 'automatic_provision', 'rest_enabled', + 'web_management_enabled') # DHCP diff --git a/topologie/models.py b/topologie/models.py index 55f9aee6..7952371f 100644 --- a/topologie/models.py +++ b/topologie/models.py @@ -273,7 +273,11 @@ class Switch(AclMixin, Machine): ValidationError("Création d'un port existant.") def main_interface(self): - """ Returns the 'main' interface of the switch """ + """ Returns the 'main' interface of the switch + It must the the management interface for that device""" + switch_iptype = OptionalTopologie.get_cached_value('switchs_ip_type') + if switch_iptype: + return self.interface_set.filter(type__ip_type=switch_iptype).first() return self.interface_set.first() @cached_property @@ -286,19 +290,22 @@ class Switch(AclMixin, Machine): @cached_property def ipv4(self): + """Return the switch's management ipv4""" return str(self.main_interface().ipv4) @cached_property def ipv6(self): + """Returne the switch's management ipv6""" return str(self.main_interface().ipv6().first()) @cached_property def subnet(self): - return self.main_interface().type.ip_type.ip_set_full_info + """ Return the subnet of the management ip""" + return self.main_interface().type.ip_type.ip_set_full_info @cached_property def subnet6(self): - return self.main_interface().type.ip_type.ip6_set_full_info + return self.main_interface().type.ip_type.ip6_set_full_info def __str__(self): return str(self.main_interface())