8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-23 11:53:12 +00:00

Serialisation des réglages pour la provision

This commit is contained in:
Gabriel Detraz 2018-07-09 22:59:47 +02:00 committed by grizzly
parent 5184fc165f
commit 396853db0e
2 changed files with 13 additions and 4 deletions

View file

@ -749,7 +749,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')
# LOCAL EMAILS

View file

@ -285,7 +285,11 @@ class Switch(AclMixin, Machine):
ValidationError(_("Creation of an existing port."))
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
@ -294,14 +298,17 @@ 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 the subnet of the management ip"""
return self.main_interface().type.ip_type.ip_set_full_info
@cached_property