diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-09-05 21:54:11 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-09-05 21:54:11 +0000 |
| commit | 1ca3d8d15e560076d8e620fd7f61529f0fb2d000 (patch) | |
| tree | c1b0c42704055e3fc73ea75687b8261aa8de4ee0 | |
| parent | 95fb70be29d735a34549c91ac5967d4b5faec7b8 (diff) | |
| parent | 0bd4a04afb35d7e60b34b8a1aaab45b7805cad15 (diff) | |
| download | nova-1ca3d8d15e560076d8e620fd7f61529f0fb2d000.tar.gz nova-1ca3d8d15e560076d8e620fd7f61529f0fb2d000.tar.xz nova-1ca3d8d15e560076d8e620fd7f61529f0fb2d000.zip | |
Merge "Speed up creating floating ips."
| -rw-r--r-- | nova/db/sqlalchemy/api.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 106c8b8ed..797516ac9 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -716,10 +716,21 @@ def floating_ip_allocate_address(context, project_id, pool): @require_context def floating_ip_bulk_create(context, ips): + existing_ips = {} + for floating in _floating_ip_get_all(context).all(): + existing_ips[floating['address']] = floating + session = get_session() with session.begin(): for ip in ips: - floating_ip_create(context, ip, session) + addr = ip['address'] + if (addr in existing_ips and + ip.get('id') != existing_ips[addr]['id']): + raise exception.FloatingIpExists(**dict(existing_ips[addr])) + + model = models.FloatingIp() + model.update(ip) + session.add(model) @require_context |
