mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-27 07:02:26 +00:00
Merge branch 'multi_iptypes_switchs' into 'dev'
Multi iptypes switchs See merge request federez/re2o!459
This commit is contained in:
commit
59ce4829aa
4 changed files with 31 additions and 10 deletions
|
@ -824,7 +824,7 @@ class SwitchPortSerializer(serializers.ModelSerializer):
|
|||
fields = ('short_name', 'model', 'switchbay', 'ports', 'ipv4', 'ipv6',
|
||||
'interfaces_subnet', 'interfaces6_subnet', 'automatic_provision', 'rest_enabled',
|
||||
'web_management_enabled', 'get_radius_key_value', 'get_management_cred_value',
|
||||
'list_modules')
|
||||
'get_radius_servers', 'list_modules')
|
||||
|
||||
# LOCAL EMAILS
|
||||
|
||||
|
|
|
@ -448,12 +448,17 @@ class IpType(RevMixin, AclMixin, models.Model):
|
|||
@cached_property
|
||||
def ip_net_full_info(self):
|
||||
"""Renvoie les infos du network contenant du range"""
|
||||
if self.ip_network:
|
||||
return {
|
||||
'network': str(self.ip_network.network),
|
||||
'netmask': str(self.ip_network.netmask),
|
||||
'broadcast': str(self.ip_network.broadcast),
|
||||
'netmask_cidr': str(self.ip_network.prefixlen),
|
||||
'vlan': str(self.vlan),
|
||||
'vlan_id': self.vlan.vlan_id
|
||||
}
|
||||
else:
|
||||
return None
|
||||
|
||||
@cached_property
|
||||
def complete_prefixv6(self):
|
||||
|
|
|
@ -294,7 +294,7 @@ class OptionalTopologie(AclMixin, PreferencesModel):
|
|||
subnet = None
|
||||
subnet6 = None
|
||||
if self.switchs_ip_type:
|
||||
subnet = self.switchs_ip_type.ip_set_full_info
|
||||
subnet = self.switchs_ip_type.ip_net_full_info or self.switchs_ip_type.ip_set_full_info[0]
|
||||
subnet6 = self.switchs_ip_type.ip6_set_full_info
|
||||
return {'ntp_servers': return_ips_dict(ntp_servers), 'log_servers': return_ips_dict(log_servers), 'radius_servers': return_ips_dict(radius_servers), 'dhcp_servers': return_ips_dict(dhcp_servers), 'dns_recursive_servers': return_ips_dict(dns_recursive_servers), 'subnet': subnet, 'subnet6': subnet6}
|
||||
|
||||
|
|
|
@ -55,7 +55,13 @@ from preferences.models import (
|
|||
RadiusKey,
|
||||
SwitchManagementCred
|
||||
)
|
||||
from machines.models import Machine, regen
|
||||
from machines.models import (
|
||||
Machine,
|
||||
regen,
|
||||
Role,
|
||||
MachineType,
|
||||
Ipv6List
|
||||
)
|
||||
from re2o.mixins import AclMixin, RevMixin
|
||||
|
||||
|
||||
|
@ -321,6 +327,16 @@ class Switch(AclMixin, Machine):
|
|||
else:
|
||||
return None
|
||||
|
||||
@cached_property
|
||||
def get_radius_servers_objects(self):
|
||||
return Role.all_interfaces_for_roletype("radius-server").filter(machine_type__in=MachineType.objects.filter(interface__in=self.interface_set.all()))
|
||||
|
||||
@cached_property
|
||||
def get_radius_servers(self):
|
||||
def return_ips_dict(interfaces):
|
||||
return {'ipv4' : [str(interface.ipv4) for interface in interfaces], 'ipv6' : Ipv6List.objects.filter(interface__in=interfaces).values_list('ipv6', flat=True)}
|
||||
return return_ips_dict(self.get_radius_servers_objects)
|
||||
|
||||
@cached_property
|
||||
def get_management_cred(self):
|
||||
"""Retourne l'objet des creds de managament de ce switch"""
|
||||
|
@ -362,7 +378,7 @@ class Switch(AclMixin, Machine):
|
|||
@cached_property
|
||||
def interfaces_subnet(self):
|
||||
"""Return dict ip:subnet for all ip of the switch"""
|
||||
return dict((str(interface.ipv4), interface.machine_type.ip_type.ip_set_full_info) for interface in self.interface_set.all())
|
||||
return dict((str(interface.ipv4), interface.machine_type.ip_type.ip_net_full_info or interface.machine_type.ip_type.ip_set_full_info[0]) for interface in self.interface_set.all())
|
||||
|
||||
@cached_property
|
||||
def interfaces6_subnet(self):
|
||||
|
|
Loading…
Reference in a new issue