summaryrefslogtreecommitdiffstats
path: root/nova/db
diff options
context:
space:
mode:
authorAaron Lee <aaron.lee@rackspace.com>2011-10-27 17:37:34 -0500
committerAaron Lee <aaron.lee@rackspace.com>2011-10-27 17:37:34 -0500
commitfcbb8780386b3ff48653da23a1ffb3f5aa0c8b13 (patch)
tree539bae59237f36bb447dcbf3077a78b0d49d4172 /nova/db
parent16bacc3252b9a792159b247dcf9d2f3ebb6842ac (diff)
downloadnova-fcbb8780386b3ff48653da23a1ffb3f5aa0c8b13.tar.gz
nova-fcbb8780386b3ff48653da23a1ffb3f5aa0c8b13.tar.xz
nova-fcbb8780386b3ff48653da23a1ffb3f5aa0c8b13.zip
Adding bulk create fixed ips. The true issue here
is the creation of IPs in the DB that are not currently used(we are building the entire block). This fix is just a bandaid, but it does cut ~25 seconds off of the quantum tests on my laptop. (pre)$ ./run_tests.sh -N nova.tests.test_quantum:QuantumNovaIPAMTestCase QuantumNovaIPAMTestCase test_allocate_and_deallocate_instance_dynamic OK 11.36 test_allocate_and_deallocate_instance_static OK 11.27 test_create_and_delete_nets OK 10.35 test_validate_bad_network OK 0.10 (post)$ ./run_tests.sh -N nova.tests.test_quantum:QuantumNovaIPAMTestCase QuantumNovaIPAMTestCase test_allocate_and_deallocate_instance_dynamic OK 2.94 test_allocate_and_deallocate_instance_static OK 3.12 test_create_and_delete_nets OK 1.86 test_validate_bad_network OK 0.11 Change-Id: I46b629f9ca6e019c7c4c6aa8e869c551e5c13fb8
Diffstat (limited to 'nova/db')
-rw-r--r--nova/db/api.py5
-rw-r--r--nova/db/sqlalchemy/api.py10
2 files changed, 15 insertions, 0 deletions
diff --git a/nova/db/api.py b/nova/db/api.py
index 601bdcee0..915589fb3 100644
--- a/nova/db/api.py
+++ b/nova/db/api.py
@@ -357,6 +357,11 @@ def fixed_ip_create(context, values):
return IMPL.fixed_ip_create(context, values)
+def fixed_ip_bulk_create(context, ips):
+ """Create a lot of fixed ips from the values dictionary."""
+ return IMPL.fixed_ip_bulk_create(context, ips)
+
+
def fixed_ip_disassociate(context, address):
"""Disassociate a fixed ip from an instance by address."""
return IMPL.fixed_ip_disassociate(context, address)
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index 983c48145..47efb9019 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -768,6 +768,16 @@ def fixed_ip_create(_context, values):
@require_context
+def fixed_ip_bulk_create(_context, ips):
+ session = get_session()
+ with session.begin():
+ for ip in ips:
+ model = models.FixedIp()
+ model.update(ip)
+ session.add(model)
+
+
+@require_context
def fixed_ip_disassociate(context, address):
session = get_session()
with session.begin():