okay, i think i fixed the range allocation issue.
This commit is contained in:
parent
50fd503ce6
commit
01acb18f5f
@ -1,5 +1,6 @@
|
|||||||
import ipaddress
|
import ipaddress
|
||||||
import logging
|
import logging
|
||||||
|
import re
|
||||||
import socket
|
import socket
|
||||||
##
|
##
|
||||||
import netaddr
|
import netaddr
|
||||||
@ -130,11 +131,16 @@ class Assignment(object):
|
|||||||
self.iface_blocks = self.alloc_block.extract_subnet(self.prefix, count = 1)
|
self.iface_blocks = self.alloc_block.extract_subnet(self.prefix, count = 1)
|
||||||
logger.debug('Allocation blocks for {0}: {1}'.format(self.iface, ','.join([str(i) for i in self.iface_blocks])))
|
logger.debug('Allocation blocks for {0}: {1}'.format(self.iface, ','.join([str(i) for i in self.iface_blocks])))
|
||||||
for idx, i in enumerate(self.iface_blocks):
|
for idx, i in enumerate(self.iface_blocks):
|
||||||
|
if i.prefixlen > 64:
|
||||||
|
raise ValueError('Allocation block must be a /64 or larger')
|
||||||
# DHCPv6 range.
|
# DHCPv6 range.
|
||||||
_base = '{0}:{1}'.format(str(i.ip).rstrip(':'), idx)
|
# We need to do some funky things here. Netaddr doesn't have an .exploded().
|
||||||
|
_base = ipaddress.IPv6Address(str(i.ip))
|
||||||
|
_base = ipaddress.IPv6Address(re.sub(r'(:0000){4}$', r':dead:beef:cafe::', str(_base.exploded)))
|
||||||
|
_base = re.sub(r':0$', r'', _base)
|
||||||
logger.debug('Base prefix for {0}: {1}'.format(str(i), _base))
|
logger.debug('Base prefix for {0}: {1}'.format(str(i), _base))
|
||||||
start = '{0}:dead:beef:cafe:0'.format(_base)
|
start = '{0}:0'.format(_base)
|
||||||
stop = '{0}:dead:beef:cafe:ffff'.format(_base)
|
stop = '{0}:ffff'.format(_base)
|
||||||
d_range = (start, stop)
|
d_range = (start, stop)
|
||||||
self.dhcp6_ranges.append(d_range)
|
self.dhcp6_ranges.append(d_range)
|
||||||
logger.debug('Added range {0} to block {1} for iface {2}'.format(d_range, str(i.ip), self.iface))
|
logger.debug('Added range {0} to block {1} for iface {2}'.format(d_range, str(i.ip), self.iface))
|
||||||
|
Loading…
Reference in New Issue
Block a user