Merge trunk to resolve nova/network/linux_net.py conflict

This commit is contained in:
Mark McLoughlin 2011-09-17 07:47:45 +01:00
commit f0a2e881ea
2 changed files with 59 additions and 8 deletions
nova/db
api.py
sqlalchemy

@ -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):
@ -324,13 +326,15 @@ def migration_get_by_instance_and_status(context, instance_uuid, status):
####################
def fixed_ip_associate(context, address, instance_id, network_id=None):
def fixed_ip_associate(context, address, instance_id, network_id=None,
reserved=False):
"""Associate fixed ip to instance.
Raises if fixed ip is not available.
"""
return IMPL.fixed_ip_associate(context, address, instance_id, network_id)
return IMPL.fixed_ip_associate(context, address, instance_id, network_id,
reserved)
def fixed_ip_associate_pool(context, network_id, instance_id=None, host=None):
@ -365,7 +369,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):
@ -420,6 +424,11 @@ def virtual_interface_get_by_address(context, address):
return IMPL.virtual_interface_get_by_address(context, address)
def virtual_interface_get_by_uuid(context, vif_uuid):
"""Gets a virtual interface from the table filtering on vif uuid."""
return IMPL.virtual_interface_get_by_uuid(context, vif_uuid)
def virtual_interface_get_by_fixed_ip(context, fixed_ip_id):
"""Gets the virtual interface fixed_ip is associated with."""
return IMPL.virtual_interface_get_by_fixed_ip(context, fixed_ip_id)
@ -715,6 +724,11 @@ def network_get_by_bridge(context, bridge):
return IMPL.network_get_by_bridge(context, bridge)
def network_get_by_uuid(context, uuid):
"""Get a network by uuid or raise if it does not exist."""
return IMPL.network_get_by_uuid(context, uuid)
def network_get_by_cidr(context, cidr):
"""Get a network by cidr or raise if it does not exist"""
return IMPL.network_get_by_cidr(context, cidr)

@ -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
@ -669,14 +672,19 @@ def floating_ip_update(context, address, values):
@require_admin_context
def fixed_ip_associate(context, address, instance_id, network_id=None):
def fixed_ip_associate(context, address, instance_id, network_id=None,
reserved=False):
"""Keyword arguments:
reserved -- should be a boolean value(True or False), exact value will be
used to filter on the fixed ip address
"""
session = get_session()
with session.begin():
network_or_none = or_(models.FixedIp.network_id == network_id,
models.FixedIp.network_id == None)
fixed_ip_ref = session.query(models.FixedIp).\
filter(network_or_none).\
filter_by(reserved=False).\
filter_by(reserved=reserved).\
filter_by(deleted=False).\
filter_by(address=address).\
with_lockmode('update').\
@ -944,6 +952,22 @@ def virtual_interface_get_by_address(context, address):
return vif_ref
@require_context
def virtual_interface_get_by_uuid(context, vif_uuid):
"""Gets a virtual interface from the table.
:param vif_uuid: the uuid of the interface you're looking to get
"""
session = get_session()
vif_ref = session.query(models.VirtualInterface).\
filter_by(uuid=vif_uuid).\
options(joinedload('network')).\
options(joinedload('instance')).\
options(joinedload('fixed_ips')).\
first()
return vif_ref
@require_context
def virtual_interface_get_by_fixed_ip(context, fixed_ip_id):
"""Gets the virtual interface fixed_ip is associated with.
@ -1857,6 +1881,19 @@ def network_get_by_bridge(context, bridge):
return result
@require_admin_context
def network_get_by_uuid(context, uuid):
session = get_session()
result = session.query(models.Network).\
filter_by(uuid=uuid).\
filter_by(deleted=False).\
first()
if not result:
raise exception.NetworkNotFoundForUUID(uuid=uuid)
return result
@require_admin_context
def network_get_by_cidr(context, cidr):
session = get_session()