summaryrefslogtreecommitdiffstats
path: root/nova/db
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-01-04 12:56:35 +0000
committerGerrit Code Review <review@openstack.org>2013-01-04 12:56:35 +0000
commitbe22c7fb23448980a2ed1e8dee28abb376e89faf (patch)
treee537f8288426bf0a186252cb0b9266c347722458 /nova/db
parentb4d72616c19d7b079f3225a3f57fe49e5df642f4 (diff)
parent881a93473c32a7c7e23a8e6dcede8394053408c6 (diff)
Merge "Eliminate race conditions in floating association"
Diffstat (limited to 'nova/db')
-rw-r--r--nova/db/api.py10
-rw-r--r--nova/db/sqlalchemy/api.py3
2 files changed, 11 insertions, 2 deletions
diff --git a/nova/db/api.py b/nova/db/api.py
index 4acff8a99..3e350fc75 100644
--- a/nova/db/api.py
+++ b/nova/db/api.py
@@ -290,7 +290,8 @@ def floating_ip_destroy(context, address):
def floating_ip_disassociate(context, address):
"""Disassociate a floating ip from a fixed ip by address.
- :returns: the address of the existing fixed ip.
+ :returns: the address of the previous fixed ip or None
+ if the ip was not associated to an ip.
"""
return IMPL.floating_ip_disassociate(context, address)
@@ -298,7 +299,12 @@ def floating_ip_disassociate(context, address):
def floating_ip_fixed_ip_associate(context, floating_address,
fixed_address, host):
- """Associate a floating ip to a fixed_ip by address."""
+ """Associate a floating ip to a fixed_ip by address.
+
+ :returns: the address of the new fixed ip (fixed_address) or None
+ if the ip was already associated to the fixed ip.
+ """
+
return IMPL.floating_ip_fixed_ip_associate(context,
floating_address,
fixed_address,
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index 8d087f28d..a1cca73be 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -761,9 +761,12 @@ def floating_ip_fixed_ip_associate(context, floating_address,
fixed_ip_ref = fixed_ip_get_by_address(context,
fixed_address,
session=session)
+ if floating_ip_ref.fixed_ip_id == fixed_ip_ref["id"]:
+ return None
floating_ip_ref.fixed_ip_id = fixed_ip_ref["id"]
floating_ip_ref.host = host
floating_ip_ref.save(session=session)
+ return fixed_address
@require_context