Comment 1 for bug 943923

Revision history for this message
Édouard Thuleau (ethuleau) wrote :

diff --git a/bin/nova-manage b/bin/nova-manage
index 08c4133..45f23e2 100755
--- a/bin/nova-manage
+++ b/bin/nova-manage
@@ -702,6 +702,12 @@ class FloatingIpCommands(object):
             pool = FLAGS.default_floating_pool
         if not interface:
             interface = FLAGS.public_interface
+ if addresses.size == 1:
+ db.floating_ip_create(admin_context,
+ {'address': str(addresses.ip),
+ 'pool': pool,
+ 'interface': interface})
+ return
         for address in addresses.iter_hosts():
             db.floating_ip_create(admin_context,
                                   {'address': str(address),
@@ -711,7 +717,12 @@ 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():
+ addresses = netaddr.IPNetwork(ip_range)
+ if addresses.size == 1:
+ db.floating_ip_destroy(context.get_admin_context(),
+ str(addresses.ip))
+ return
+ for address in addresses.iter_hosts():
             db.floating_ip_destroy(context.get_admin_context(),
                                    str(address))