|
@@ -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()]))
|
|
|
|