summaryrefslogtreecommitdiffstats
path: root/nova/db
diff options
context:
space:
mode:
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