Browse Source

Check consistency between subnets and reverse DNS entries

Baptiste Jonglez 11 years ago
parent
commit
de2d1c8446
1 changed files with 7 additions and 0 deletions
  1. 7 0
      coin/resources/models.py

+ 7 - 0
coin/resources/models.py

@@ -83,11 +83,18 @@ class IPSubnet(models.Model):
         if conflicting:
             raise ValidationError('Subnet must not intersect with existing subnets.\nIntersected subnets: {}.'.format(conflicting))
 
+    def validate_reverse_dns(self):
+        """Check that reverse DNS entries, if any, are included in the subnet"""
+        incorrect = [str(rev.ip) for rev in self.reversednsentry_set.all() if not rev.ip in self.inet]
+        if incorrect:
+            raise ValidationError('Some reverse DNS entries are not in the subnet: {}.'.format(incorrect))
+
     def clean(self):
         if not self.inet:
             self.allocate()
         else:
             self.validate_inclusion()
+        self.validate_reverse_dns()
 
     def __unicode__(self):
         return str(self.inet)