Browse Source

Fix old code related to automatic allocation

Baptiste Jonglez 11 years ago
parent
commit
623e16af88
1 changed files with 2 additions and 2 deletions
  1. 2 2
      coin/resources/models.py

+ 2 - 2
coin/resources/models.py

@@ -67,7 +67,7 @@ class IPSubnet(models.Model):
                 first_free = available.next()
             except StopIteration:
                 raise ValidationError('Unable to allocate an IP subnet in the specified pool: not enough space left.')
-            self.inet = first_free.subnet(SUBNET_SIZE, 1).next()
+            self.inet = first_free.subnet(self.ip_pool.default_subnetsize, 1).next()
         else:
             # Check that we are included in the IP pool.
             if not self.inet in self.ip_pool.inet:
@@ -76,7 +76,7 @@ class IPSubnet(models.Model):
             # TODO: use precise database query instead of querying all
             # subnets and filtering in Python.
             existing = IPSet((s.inet for s in self.ip_pool.ipsubnet_set.all()))
-            intersection = subnet.intersection(existing)
+            intersection = IPSet([self.inet]).intersection(existing)
             if intersection.size:
                 raise ValidationError('Subnet must not intersect with existing subnets.\nIntersected subnets: {}.'.format([str(p) for p in intersection.iter_cidrs()]))