Ce serveur Gitlab sera éteint le 30 juin 2020, pensez à migrer vos projets vers les serveurs gitlab-research.centralesupelec.fr et gitlab-student.centralesupelec.fr !

Commit 3c22ea4e authored by Gabriel Detraz's avatar Gabriel Detraz Committed by grizzly

Export de l'ensemble des ip du switch

parent ae0f134c
......@@ -750,7 +750,7 @@ class SwitchPortSerializer(serializers.ModelSerializer):
class Meta:
model = topologie.Switch
fields = ('short_name', 'model', 'switchbay', 'ports', 'ipv4', 'ipv6',
'subnet', 'subnet6', 'automatic_provision', 'rest_enabled',
'interfaces_subnet', 'interfaces6_subnet', 'automatic_provision', 'rest_enabled',
'web_management_enabled', 'get_radius_key_value', 'get_management_cred_value')
......@@ -377,7 +377,7 @@ class IpType(RevMixin, AclMixin, models.Model):
'netmask' : 'ffff:ffff:ffff:ffff::',
'netmask_cidr' : str(self.prefix_v6_length),
'vlan': str(self.vlan),
'vlan_id': str(self.vlan.vlan_id)
'vlan_id': self.vlan.vlan_id
return None
......@@ -367,13 +367,14 @@ class Switch(AclMixin, Machine):
return str(self.main_interface().ipv6().first())
def subnet(self):
""" Return the subnet of the management ip"""
return self.main_interface().type.ip_type.ip_set_full_info
def interfaces_subnet(self):
"""Return dict ip:subnet for all ip of the switch"""
return dict((str(interface.ipv4), interface.type.ip_type.ip_set_full_info) for interface in self.interface_set.all())
def subnet6(self):
return self.main_interface().type.ip_type.ip6_set_full_info
def interfaces6_subnet(self):
"""Return dict ip6:subnet for all ipv6 of the switch"""
return dict((str(interface.ipv6().first()), interface.type.ip_type.ip6_set_full_info) for interface in self.interface_set.all())
def __str__(self):
return str(self.get_name)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment