Always attempt to delete entire floating IP range.

Fix bug 1021222.

This patch tweaks nova-manage to always attempt to delete all addresses
in the specified IP range, even if an error is encountered.  This is an
easy way to handle a case where a range was created, but then a subset
of that range was deleted.  Otherwise, deleting the rest of the range is
a pain.

An example of this would be:

  # nova-manage floating create --ip_range=1.1.1.0/24
  # nova-manage floating delete 1.1.1.1
  # nova-manage floating delete 1.1.1.0/24

Previously this would fail.  Now it works.

Change-Id: Ia01c04dee5383f597976c6a79d9a0d9e19985898
This commit is contained in:
Russell Bryant 2012-07-11 13:57:41 -04:00
parent 786ec05dec
commit 42e785561e

View File

@ -366,8 +366,11 @@ class FloatingIpCommands(object):
def delete(self, ip_range):
"""Deletes floating ips by range"""
for address in self.address_to_hosts(ip_range):
db.floating_ip_destroy(context.get_admin_context(),
str(address))
try:
db.floating_ip_destroy(context.get_admin_context(),
str(address))
except exception.FloatingIpNotFoundForAddress as ex:
print "Warning: %s" % ex
@args('--host', dest="host", metavar='<host>', help='Host')
def list(self, host=None):