|
|
|
@ -179,7 +179,6 @@ class InetNumForm(MntFormMixin, WhoisObjectFormMixin, forms.ModelForm):
|
|
|
|
|
prefix = cleaned_data['prefix']
|
|
|
|
|
parent = cleaned_data['parent_range']
|
|
|
|
|
if parent:
|
|
|
|
|
|
|
|
|
|
parentNet = parent.getNetwork()
|
|
|
|
|
|
|
|
|
|
if cleaned_data['protocol'] != parent.protocol:
|
|
|
|
@ -189,6 +188,7 @@ class InetNumForm(MntFormMixin, WhoisObjectFormMixin, forms.ModelForm):
|
|
|
|
|
if prefix.network_address not in parentNet or prefix.prefixlen < parentNet.prefixlen:
|
|
|
|
|
raise forms.ValidationError("Prefix must be inside parent network range")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# check if parent block has net that overlaps with us
|
|
|
|
|
for otherNet in parent.inetnum_set.all():
|
|
|
|
|
if self.instance and self.instance.pk == otherNet.pk:
|
|
|
|
@ -197,6 +197,12 @@ class InetNumForm(MntFormMixin, WhoisObjectFormMixin, forms.ModelForm):
|
|
|
|
|
if otherNet.getNetwork().overlaps(prefix):
|
|
|
|
|
raise forms.ValidationError("The given prefix overlaps with network %s" % otherNet.handle)
|
|
|
|
|
|
|
|
|
|
# check if subnets to this subnet are (still) in current network
|
|
|
|
|
if not self._create:
|
|
|
|
|
for subnet in self.instance.inetnum_set.all():
|
|
|
|
|
if subnet.getNetwork().network_address not in self.instance.getNetwork():
|
|
|
|
|
raise forms.ValidationError("Subnet %s with %s is not in block anymore" % (subnet, subnet.getNetwork()))
|
|
|
|
|
|
|
|
|
|
self.instance.address = str(prefix.network_address)
|
|
|
|
|
self.instance.netmask = prefix.prefixlen
|
|
|
|
|
|
|
|
|
@ -272,6 +278,18 @@ class ASBlockForm(MntFormMixin, WhoisObjectFormMixin, forms.ModelForm):
|
|
|
|
|
asBegin <= block.asBegin <= asEnd or asBegin <= block.asEnd <= asEnd:
|
|
|
|
|
raise forms.ValidationError("Block overlaps with block %s" % block.handle)
|
|
|
|
|
|
|
|
|
|
if not self._create:
|
|
|
|
|
# check if subblocks are still in range
|
|
|
|
|
for subblock in self.instance.asblock_set.all():
|
|
|
|
|
if not (asBegin <= subblock.asBegin <= asEnd and asBegin <= subblock.asEnd <= asEnd):
|
|
|
|
|
raise forms.ValidationError("Subblock %s (%s - %s) is not contained in this block anymore" % (subblock, subblock.asBegin, subblock.asEnd))
|
|
|
|
|
|
|
|
|
|
# check if asnumbers are still in range
|
|
|
|
|
for asnumber in self.instance.asnumber_set.all():
|
|
|
|
|
if not (asBegin <= asnumber.number <= asEnd):
|
|
|
|
|
raise forms.ValidationError("AS %s (%s) is not contained in this block anymore" % (asnumber, asnumber.number))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return cleaned_data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|