Improve floating IP delete speed.

This is similar to the change to improve bulk creation speed. Before:

./bin/nova-manage floating delete --ip_range 10.250.0.0/16
337.20user 10.22system 44:07.10elapsed 13%CPU (0avgtext+0avgdata 119536maxresident)k
400inputs+0outputs (4major+11704minor)pagefaults 0swaps

After:

./bin/nova-manage floating delete --ip_range 10.250.0.0/16
6.95user 0.16system 1:04.04elapsed 11%CPU (0avgtext+0avgdata 120016maxresident)k
0inputs+0outputs (0major+11750minor)pagefaults 0swaps

Resolves bug 1023560.

Change-Id: If4f23222025cae88576f469022e0f7d907c9c4fa
This commit is contained in:
Michael Still
2012-09-04 20:46:00 +10:00
parent 328680da00
commit a80c7c20c3

View File

@@ -63,7 +63,6 @@ import optparse
import os
import sys
# If ../nova/__init__.py exists, add ../ to Python search path, so that
# it will override what happens to be installed in /usr/(local/)lib/python...
POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
@@ -396,12 +395,11 @@ 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 self.address_to_hosts(ip_range):
try:
db.floating_ip_destroy(context.get_admin_context(),
str(address))
except exception.FloatingIpNotFoundForAddress as ex:
print "Warning: %s" % ex
admin_context = context.get_admin_context()
ips = ({'address': str(address)}
for address in self.address_to_hosts(ip_range))
db.floating_ip_bulk_destroy(admin_context, ips)
@args('--host', dest="host", metavar='<host>', help='Host')
def list(self, host=None):