Commit 1471faf0 by Őry Máté

firewall: fix #28

parent f3a566cf
...@@ -120,6 +120,12 @@ class Alias(models.Model): ...@@ -120,6 +120,12 @@ class Alias(models.Model):
created_at = models.DateTimeField(auto_now_add=True) created_at = models.DateTimeField(auto_now_add=True)
modified_at = models.DateTimeField(auto_now=True) modified_at = models.DateTimeField(auto_now=True)
def clean(self):
# FIXME later: critical race condition
for h in Host.objects:
if h.get_fqdn() == self.alias:
raise ValidationError(_("Host name already used."))
class Meta: class Meta:
verbose_name_plural = 'aliases' verbose_name_plural = 'aliases'
...@@ -182,6 +188,13 @@ class Host(models.Model): ...@@ -182,6 +188,13 @@ class Host(models.Model):
def get_fqdn(self): def get_fqdn(self):
return self.hostname + u'.' + self.vlan.domain return self.hostname + u'.' + self.vlan.domain
def clean(self):
# FIXME later: critical race condition
for a in Alias.objects:
if self.get_fqdn() == a.alias:
raise ValidationError(_("Host name already used as alias."))
class Firewall(models.Model): class Firewall(models.Model):
name = models.CharField(max_length=20, unique=True) name = models.CharField(max_length=20, unique=True)
......
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 sign in to comment