Merge with trunk. Still one test failure in test_images.
This commit is contained in:
commit
c44f2abc24
@ -324,13 +324,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):
|
||||
@ -420,6 +422,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 +722,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)
|
||||
|
@ -669,14 +669,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 +949,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 +1878,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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user