makes sure floating addresses are associated with host on associate so they come back

This commit is contained in:
Vishvananda Ishaya
2011-09-13 16:38:46 -07:00
parent 67a2445265
commit de3d94726c
4 changed files with 14 additions and 6 deletions

View File

@@ -261,11 +261,13 @@ def floating_ip_disassociate(context, address):
return IMPL.floating_ip_disassociate(context, address)
def floating_ip_fixed_ip_associate(context, floating_address, fixed_address):
def floating_ip_fixed_ip_associate(context, floating_address,
fixed_address, host):
"""Associate an floating ip to a fixed_ip by address."""
return IMPL.floating_ip_fixed_ip_associate(context,
floating_address,
fixed_address)
fixed_address,
host)
def floating_ip_get_all(context):
@@ -365,7 +367,7 @@ def fixed_ip_get_all(context):
def fixed_ip_get_all_by_instance_host(context, host):
"""Get all allocated fixed ips filtered by instance host."""
return IMPL.fixed_ip_get_all_instance_by_host(context, host)
return IMPL.fixed_ip_get_all_by_instance_host(context, host)
def fixed_ip_get_by_address(context, address):

View File

@@ -529,7 +529,8 @@ def floating_ip_count_by_project(context, project_id):
@require_context
def floating_ip_fixed_ip_associate(context, floating_address, fixed_address):
def floating_ip_fixed_ip_associate(context, floating_address,
fixed_address, host):
session = get_session()
with session.begin():
# TODO(devcamcar): How to ensure floating_id belongs to user?
@@ -540,6 +541,7 @@ def floating_ip_fixed_ip_associate(context, floating_address, fixed_address):
fixed_address,
session=session)
floating_ip_ref.fixed_ip = fixed_ip_ref
floating_ip_ref.host = host
floating_ip_ref.save(session=session)
@@ -583,6 +585,7 @@ def floating_ip_disassociate(context, address):
else:
fixed_ip_address = None
floating_ip_ref.fixed_ip = None
floating_ip_ref.host = None
floating_ip_ref.save(session=session)
return fixed_ip_address