mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-27 01:13:46 +00:00
Fix les erreurs de none sur macaddress
This commit is contained in:
parent
a8d54039c8
commit
8864bdba66
1 changed files with 9 additions and 1 deletions
|
@ -213,7 +213,15 @@ class Interface(models.Model):
|
||||||
def mac_bare(self):
|
def mac_bare(self):
|
||||||
return str(EUI(self.mac_address, dialect=mac_bare)).lower()
|
return str(EUI(self.mac_address, dialect=mac_bare)).lower()
|
||||||
|
|
||||||
|
def filter_macaddress(self):
|
||||||
|
mac_address = str(EUI(self.mac_address))
|
||||||
|
if mac_address:
|
||||||
|
self.mac_address = mac_address
|
||||||
|
else:
|
||||||
|
raise ValidationError("La mac donnée est invalide")
|
||||||
|
|
||||||
def clean(self, *args, **kwargs):
|
def clean(self, *args, **kwargs):
|
||||||
|
self.filter_macaddress()
|
||||||
self.mac_address = str(EUI(self.mac_address)) or None
|
self.mac_address = str(EUI(self.mac_address)) or None
|
||||||
if not self.ipv4 or self.type.ip_type != self.ipv4.ip_type:
|
if not self.ipv4 or self.type.ip_type != self.ipv4.ip_type:
|
||||||
self.assign_ipv4()
|
self.assign_ipv4()
|
||||||
|
@ -237,7 +245,7 @@ class Interface(models.Model):
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
self.mac_address = str(EUI(self.mac_address)) or None
|
self.filter_macaddress()
|
||||||
# On verifie la cohérence en forçant l'extension par la méthode
|
# On verifie la cohérence en forçant l'extension par la méthode
|
||||||
if self.type.ip_type != self.ipv4.ip_type:
|
if self.type.ip_type != self.ipv4.ip_type:
|
||||||
raise ValidationError("L'ipv4 et le type de la machine ne correspondent pas")
|
raise ValidationError("L'ipv4 et le type de la machine ne correspondent pas")
|
||||||
|
|
Loading…
Reference in a new issue