# mode is optional and is not set - skip it
if mode:
- cmd.append('--dhcp-range=%s%s,%s,%s,%s' %
- ('set:', self._TAG_PREFIX % i,
- cidr.network, mode, lease))
+ if subnet.ip_version == 4:
+ cmd.append('--dhcp-range=%s%s,%s,%s,%s' %
+ ('set:', self._TAG_PREFIX % i,
+ cidr.network, mode, lease))
+ else:
+ cmd.append('--dhcp-range=%s%s,%s,%s,%d,%s' %
+ ('set:', self._TAG_PREFIX % i,
+ cidr.network, mode,
+ cidr.prefixlen, lease))
possible_leases += cidr.size
# Cap the limit because creating lots of subnets can inflate
seconds = 's'
if has_static:
prefix = '--dhcp-range=set:tag%d,%s,static,%s%s'
+ prefix6 = '--dhcp-range=set:tag%d,%s,static,%s,%s%s'
else:
prefix = '--dhcp-range=set:tag%d,%s,%s%s'
+ prefix6 = '--dhcp-range=set:tag%d,%s,%s,%s%s'
possible_leases = 0
for i, s in enumerate(network.subnets):
if (s.ip_version != 6
or s.ipv6_address_mode == constants.DHCPV6_STATEFUL):
- expected.extend([prefix % (
- i, s.cidr.split('/')[0], lease_duration, seconds)])
+ if s.ip_version == 4:
+ expected.extend([prefix % (
+ i, s.cidr.split('/')[0], lease_duration, seconds)])
+ else:
+ expected.extend([prefix6 % (
+ i, s.cidr.split('/')[0], s.cidr.split('/')[1],
+ lease_duration, seconds)])
possible_leases += netaddr.IPNetwork(s.cidr).size
expected.append('--dhcp-lease-max=%d' % min(