Floating_ip create /31,32 shouldn't silent error
Fixes bug 1017682 the netaddr.IPNetwork.iter_hosts method doesn't return any IPs when /32 or /31 and should throw an exception instead of silent error Change-Id: Id8875b6016a4dbb40b29d2f7687e6c35491e0129
This commit is contained in:
@@ -343,7 +343,13 @@ class FloatingIpCommands(object):
|
|||||||
try:
|
try:
|
||||||
return [netaddr.IPAddress(addresses)]
|
return [netaddr.IPAddress(addresses)]
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return netaddr.IPNetwork(addresses).iter_hosts()
|
net = netaddr.IPNetwork(addresses)
|
||||||
|
if net.size < 4:
|
||||||
|
reason = _("/%s should be specified as single address(es) "
|
||||||
|
"not in cidr format") % net.prefixlen
|
||||||
|
raise exception.InvalidInput(reason=reason)
|
||||||
|
else:
|
||||||
|
return net.iter_hosts()
|
||||||
|
|
||||||
@args('--ip_range', dest="ip_range", metavar='<range>', help='IP range')
|
@args('--ip_range', dest="ip_range", metavar='<range>', help='IP range')
|
||||||
@args('--pool', dest="pool", metavar='<pool>', help='Optional pool')
|
@args('--pool', dest="pool", metavar='<pool>', help='Optional pool')
|
||||||
|
|||||||
Reference in New Issue
Block a user