|
|
@ -193,6 +193,10 @@ class OptionalTopologie(AclMixin, PreferencesModel): |
|
|
(DEFINED, 'Prédéfini dans "Vlan où placer les machines\ |
|
|
(DEFINED, 'Prédéfini dans "Vlan où placer les machines\ |
|
|
après acceptation RADIUS"'), |
|
|
après acceptation RADIUS"'), |
|
|
) |
|
|
) |
|
|
|
|
|
CHOICE_PROVISION = ( |
|
|
|
|
|
('sftp', 'sftp'), |
|
|
|
|
|
('tftp', 'tftp'), |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
radius_general_policy = models.CharField( |
|
|
radius_general_policy = models.CharField( |
|
|
max_length=32, |
|
|
max_length=32, |
|
|
@ -235,6 +239,24 @@ class OptionalTopologie(AclMixin, PreferencesModel): |
|
|
null=True, |
|
|
null=True, |
|
|
help_text="Plage d'ip de management des switchs" |
|
|
help_text="Plage d'ip de management des switchs" |
|
|
) |
|
|
) |
|
|
|
|
|
switchs_provision = models.CharField( |
|
|
|
|
|
max_length=32, |
|
|
|
|
|
choices=CHOICE_PROVISION, |
|
|
|
|
|
default='tftp', |
|
|
|
|
|
help_text="Mode de récupération des confs par les switchs" |
|
|
|
|
|
) |
|
|
|
|
|
sftp_login = models.CharField( |
|
|
|
|
|
max_length=32, |
|
|
|
|
|
null=True, |
|
|
|
|
|
blank=True, |
|
|
|
|
|
help_text="Login sftp des switchs" |
|
|
|
|
|
) |
|
|
|
|
|
sftp_pass = AESEncryptedField( |
|
|
|
|
|
max_length=63, |
|
|
|
|
|
null=True, |
|
|
|
|
|
blank=True, |
|
|
|
|
|
help_text="Mot de passe sftp" |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
@cached_property |
|
|
@cached_property |
|
|
def provisioned_switchs(self): |
|
|
def provisioned_switchs(self): |
|
|
@ -258,6 +280,14 @@ class OptionalTopologie(AclMixin, PreferencesModel): |
|
|
return None |
|
|
return None |
|
|
return self.switchs_management_interface.ipv4 |
|
|
return self.switchs_management_interface.ipv4 |
|
|
|
|
|
|
|
|
|
|
|
@cached_property |
|
|
|
|
|
def switchs_management_sftp_creds(self): |
|
|
|
|
|
"""Credentials des switchs pour provion sftp""" |
|
|
|
|
|
if self.sftp_login and self.sftp_pass: |
|
|
|
|
|
return {'login' : self.sftp_login, 'pass' : self.sftp_pass} |
|
|
|
|
|
else: |
|
|
|
|
|
return None |
|
|
|
|
|
|
|
|
@cached_property |
|
|
@cached_property |
|
|
def switchs_management_utils(self): |
|
|
def switchs_management_utils(self): |
|
|
"""Used for switch_conf, return a list of ip on vlans""" |
|
|
"""Used for switch_conf, return a list of ip on vlans""" |
|
|
@ -280,7 +310,7 @@ class OptionalTopologie(AclMixin, PreferencesModel): |
|
|
def provision_switchs_enabled(self): |
|
|
def provision_switchs_enabled(self): |
|
|
"""Return true if all settings are ok : switchs on automatic provision, |
|
|
"""Return true if all settings are ok : switchs on automatic provision, |
|
|
ip_type""" |
|
|
ip_type""" |
|
|
return bool(self.provisioned_switchs and self.switchs_ip_type and SwitchManagementCred.objects.filter(default_switch=True).exists() and self.switchs_management_interface_ip) |
|
|
return bool(self.provisioned_switchs and self.switchs_ip_type and SwitchManagementCred.objects.filter(default_switch=True).exists() and self.switchs_management_interface_ip and bool(self.switchs_provision != 'sftp' or self.switchs_management_sftp_creds)) |
|
|
|
|
|
|
|
|
class Meta: |
|
|
class Meta: |
|
|
permissions = ( |
|
|
permissions = ( |
|
|
|