summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-03-07 18:01:36 +0000
committerGerrit Code Review <review@openstack.org>2012-03-07 18:01:36 +0000
commit855aae0f9cfc81b86d175e2fde69d5d888fc2a1b (patch)
tree0d94fc59677e177122572aaecc5a0e0b8f708c69
parentedac47a9cadda3d1f200c6748dda7758df268412 (diff)
parente430c8424a62d9d397980899ae0458a5e947704e (diff)
downloadnova-855aae0f9cfc81b86d175e2fde69d5d888fc2a1b.tar.gz
nova-855aae0f9cfc81b86d175e2fde69d5d888fc2a1b.tar.xz
nova-855aae0f9cfc81b86d175e2fde69d5d888fc2a1b.zip
Merge "nova-manage: allow use of /32 IP range"
-rwxr-xr-xbin/nova-manage18
1 files changed, 16 insertions, 2 deletions
diff --git a/bin/nova-manage b/bin/nova-manage
index 234f9d45e..dd4f6a389 100755
--- a/bin/nova-manage
+++ b/bin/nova-manage
@@ -627,6 +627,20 @@ class FixedIpCommands(object):
class FloatingIpCommands(object):
"""Class for managing floating ip."""
+ @staticmethod
+ def network_to_host_list(network):
+ """Return the list of host of a network.
+
+ If the network is empty and only has one host, then we consider it
+ has the host in the network.
+ """
+
+ if network.size == 1:
+ yield network.ip
+ else:
+ for host in network.iter_hosts():
+ yield host
+
@args('--ip_range', dest="ip_range", metavar='<range>', help='IP range')
@args('--pool', dest="pool", metavar='<pool>', help='Optional pool')
@args('--interface', dest="interface", metavar='<interface>',
@@ -639,7 +653,7 @@ class FloatingIpCommands(object):
pool = FLAGS.default_floating_pool
if not interface:
interface = FLAGS.public_interface
- for address in addresses.iter_hosts():
+ for address in self.network_to_host_list(addresses):
db.floating_ip_create(admin_context,
{'address': str(address),
'pool': pool,
@@ -648,7 +662,7 @@ class FloatingIpCommands(object):
@args('--ip_range', dest="ip_range", metavar='<range>', help='IP range')
def delete(self, ip_range):
"""Deletes floating ips by range"""
- for address in netaddr.IPNetwork(ip_range).iter_hosts():
+ for address in self.network_to_host_list(netaddr.IPNetwork(ip_range)):
db.floating_ip_destroy(context.get_admin_context(),
str(address))