Fixes #2222: IP addresses created via the available-ips API endpoint should have the same mask as their parent prefix (not /32)

This commit is contained in:
Jeremy Stretch 2018-07-18 15:27:45 -04:00
parent 6e037e91d3
commit c2573774bf

View File

@ -196,8 +196,9 @@ class PrefixViewSet(CustomFieldModelViewSet):
# Assign addresses from the list of available IPs and copy VRF assignment from the parent prefix
available_ips = iter(available_ips)
prefix_length = prefix.prefix.prefixlen
for requested_ip in requested_ips:
requested_ip['address'] = next(available_ips)
requested_ip['address'] = '{}/{}'.format(next(available_ips), prefix_length)
requested_ip['vrf'] = prefix.vrf.pk if prefix.vrf else None
# Initialize the serializer with a list or a single object depending on what was requested