Drop support for conductor 1.x rpc interface
In commit 330ce897c1
, a part of
Icehouse, we added support for the 2.x interface. Now that Juno
development is open, we can drop support for the old API, 1.x.
For more information on this change, see:
https://wiki.openstack.org/wiki/RpcMajorVersionUpdates
UpgradeImpact
Change-Id: Id7e605d493a53eaaa2a9afa0c99ac721f590ca3f
This commit is contained in:
parent
25ea5f480d
commit
47f6ffad82
|
@ -68,10 +68,11 @@ class LocalAPI(object):
|
|||
|
||||
def instance_get_all_by_host(self, context, host, columns_to_join=None):
|
||||
return self._manager.instance_get_all_by_host(
|
||||
context, host, columns_to_join=columns_to_join)
|
||||
context, host, None, columns_to_join=columns_to_join)
|
||||
|
||||
def instance_get_all_by_host_and_node(self, context, host, node):
|
||||
return self._manager.instance_get_all_by_host(context, host, node)
|
||||
return self._manager.instance_get_all_by_host(context, host, node,
|
||||
None)
|
||||
|
||||
def instance_info_cache_delete(self, context, instance):
|
||||
return self._manager.instance_info_cache_delete(context, instance)
|
||||
|
@ -87,7 +88,8 @@ class LocalAPI(object):
|
|||
key)
|
||||
|
||||
def bw_usage_get(self, context, uuid, start_period, mac):
|
||||
return self._manager.bw_usage_update(context, uuid, mac, start_period)
|
||||
return self._manager.bw_usage_update(context, uuid, mac, start_period,
|
||||
None, None, None, None, None, False)
|
||||
|
||||
def bw_usage_update(self, context, uuid, mac, start_period,
|
||||
bw_in, bw_out, last_ctr_in, last_ctr_out,
|
||||
|
@ -118,7 +120,8 @@ class LocalAPI(object):
|
|||
|
||||
def block_device_mapping_update_or_create(self, context, values):
|
||||
return self._manager.block_device_mapping_update_or_create(context,
|
||||
values)
|
||||
values,
|
||||
create=None)
|
||||
|
||||
def block_device_mapping_get_all_by_instance(self, context, instance,
|
||||
legacy=True):
|
||||
|
@ -138,26 +141,31 @@ class LocalAPI(object):
|
|||
update_totals)
|
||||
|
||||
def service_get_all(self, context):
|
||||
return self._manager.service_get_all_by(context)
|
||||
return self._manager.service_get_all_by(context, host=None, topic=None,
|
||||
binary=None)
|
||||
|
||||
def service_get_all_by_topic(self, context, topic):
|
||||
return self._manager.service_get_all_by(context, topic=topic)
|
||||
return self._manager.service_get_all_by(context, topic=topic,
|
||||
host=None, binary=None)
|
||||
|
||||
def service_get_all_by_host(self, context, host):
|
||||
return self._manager.service_get_all_by(context, host=host)
|
||||
return self._manager.service_get_all_by(context, host=host, topic=None,
|
||||
binary=None)
|
||||
|
||||
def service_get_by_host_and_topic(self, context, host, topic):
|
||||
return self._manager.service_get_all_by(context, topic, host)
|
||||
return self._manager.service_get_all_by(context, topic, host,
|
||||
binary=None)
|
||||
|
||||
def service_get_by_compute_host(self, context, host):
|
||||
result = self._manager.service_get_all_by(context, 'compute', host)
|
||||
result = self._manager.service_get_all_by(context, 'compute', host,
|
||||
binary=None)
|
||||
# FIXME(comstud): A major revision bump to 2.0 should return a
|
||||
# single entry, so we should just return 'result' at that point.
|
||||
return result[0]
|
||||
|
||||
def service_get_by_args(self, context, host, binary):
|
||||
return self._manager.service_get_all_by(context, host=host,
|
||||
binary=binary)
|
||||
binary=binary, topic=None)
|
||||
|
||||
def service_create(self, context, values):
|
||||
return self._manager.service_create(context, values)
|
||||
|
|
|
@ -39,7 +39,6 @@ from nova import notifications
|
|||
from nova import objects
|
||||
from nova.objects import base as nova_object
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova.objects import migration as migration_obj
|
||||
from nova.objects import quotas as quotas_obj
|
||||
from nova.openstack.common import excutils
|
||||
from nova.openstack.common.gettextutils import _
|
||||
|
@ -82,7 +81,7 @@ class ConductorManager(manager.Manager):
|
|||
namespace. See the ComputeTaskManager class for details.
|
||||
"""
|
||||
|
||||
target = messaging.Target(version='1.64')
|
||||
target = messaging.Target(version='2.0')
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ConductorManager, self).__init__(service_name='conductor',
|
||||
|
@ -94,7 +93,6 @@ class ConductorManager(manager.Manager):
|
|||
self.compute_task_mgr = ComputeTaskManager()
|
||||
self.cells_rpcapi = cells_rpcapi.CellsAPI()
|
||||
self.additional_endpoints.append(self.compute_task_mgr)
|
||||
self.additional_endpoints.append(_ConductorManagerV2Proxy(self))
|
||||
|
||||
@property
|
||||
def network_api(self):
|
||||
|
@ -121,7 +119,7 @@ class ConductorManager(manager.Manager):
|
|||
exception.InstanceNotFound,
|
||||
exception.UnexpectedTaskStateError)
|
||||
def instance_update(self, context, instance_uuid,
|
||||
updates, service=None):
|
||||
updates, service):
|
||||
for key, value in updates.iteritems():
|
||||
if key not in allowed_updates:
|
||||
LOG.error(_("Instance update attempted for "
|
||||
|
@ -136,26 +134,15 @@ class ConductorManager(manager.Manager):
|
|||
notifications.send_update(context, old_ref, instance_ref, service)
|
||||
return jsonutils.to_primitive(instance_ref)
|
||||
|
||||
# NOTE(russellb): This method is now deprecated and can be removed in
|
||||
# version 2.0 of the RPC API
|
||||
@messaging.expected_exceptions(exception.InstanceNotFound)
|
||||
def instance_get(self, context, instance_id):
|
||||
return jsonutils.to_primitive(
|
||||
self.db.instance_get(context, instance_id))
|
||||
|
||||
@messaging.expected_exceptions(exception.InstanceNotFound)
|
||||
def instance_get_by_uuid(self, context, instance_uuid,
|
||||
columns_to_join=None):
|
||||
columns_to_join):
|
||||
return jsonutils.to_primitive(
|
||||
self.db.instance_get_by_uuid(context, instance_uuid,
|
||||
columns_to_join))
|
||||
|
||||
# NOTE(hanlind): This method can be removed in v2.0 of the RPC API.
|
||||
def instance_get_all(self, context):
|
||||
return jsonutils.to_primitive(self.db.instance_get_all(context))
|
||||
|
||||
def instance_get_all_by_host(self, context, host, node=None,
|
||||
columns_to_join=None):
|
||||
def instance_get_all_by_host(self, context, host, node,
|
||||
columns_to_join):
|
||||
if node is not None:
|
||||
result = self.db.instance_get_all_by_host_and_node(
|
||||
context.elevated(), host, node)
|
||||
|
@ -164,46 +151,12 @@ class ConductorManager(manager.Manager):
|
|||
columns_to_join)
|
||||
return jsonutils.to_primitive(result)
|
||||
|
||||
# NOTE(comstud): This method is now deprecated and can be removed in
|
||||
# version v2.0 of the RPC API
|
||||
@messaging.expected_exceptions(exception.MigrationNotFound)
|
||||
def migration_get(self, context, migration_id):
|
||||
migration_ref = self.db.migration_get(context.elevated(),
|
||||
migration_id)
|
||||
return jsonutils.to_primitive(migration_ref)
|
||||
|
||||
# NOTE(comstud): This method is now deprecated and can be removed in
|
||||
# version v2.0 of the RPC API
|
||||
def migration_get_unconfirmed_by_dest_compute(self, context,
|
||||
confirm_window,
|
||||
dest_compute):
|
||||
migrations = self.db.migration_get_unconfirmed_by_dest_compute(
|
||||
context, confirm_window, dest_compute)
|
||||
return jsonutils.to_primitive(migrations)
|
||||
|
||||
def migration_get_in_progress_by_host_and_node(self, context,
|
||||
host, node):
|
||||
migrations = self.db.migration_get_in_progress_by_host_and_node(
|
||||
context, host, node)
|
||||
return jsonutils.to_primitive(migrations)
|
||||
|
||||
# NOTE(comstud): This method can be removed in v2.0 of the RPC API.
|
||||
def migration_create(self, context, instance, values):
|
||||
values.update({'instance_uuid': instance['uuid'],
|
||||
'source_compute': instance['host'],
|
||||
'source_node': instance['node']})
|
||||
migration_ref = self.db.migration_create(context.elevated(), values)
|
||||
return jsonutils.to_primitive(migration_ref)
|
||||
|
||||
# NOTE(russellb): This method is now deprecated and can be removed in
|
||||
# version 2.0 of the RPC API
|
||||
@messaging.expected_exceptions(exception.MigrationNotFound)
|
||||
def migration_update(self, context, migration, status):
|
||||
migration_ref = self.db.migration_update(context.elevated(),
|
||||
migration['id'],
|
||||
{'status': status})
|
||||
return jsonutils.to_primitive(migration_ref)
|
||||
|
||||
@messaging.expected_exceptions(exception.AggregateHostExists)
|
||||
def aggregate_host_add(self, context, aggregate, host):
|
||||
host_ref = self.db.aggregate_host_add(context.elevated(),
|
||||
|
@ -216,46 +169,14 @@ class ConductorManager(manager.Manager):
|
|||
self.db.aggregate_host_delete(context.elevated(),
|
||||
aggregate['id'], host)
|
||||
|
||||
# NOTE(russellb): This method is now deprecated and can be removed in
|
||||
# version 2.0 of the RPC API
|
||||
@messaging.expected_exceptions(exception.AggregateNotFound)
|
||||
def aggregate_get(self, context, aggregate_id):
|
||||
aggregate = self.db.aggregate_get(context.elevated(), aggregate_id)
|
||||
return jsonutils.to_primitive(aggregate)
|
||||
|
||||
# NOTE(russellb): This method is now deprecated and can be removed in
|
||||
# version 2.0 of the RPC API
|
||||
def aggregate_get_by_host(self, context, host, key=None):
|
||||
aggregates = self.db.aggregate_get_by_host(context.elevated(),
|
||||
host, key)
|
||||
return jsonutils.to_primitive(aggregates)
|
||||
|
||||
# NOTE(danms): This method is now deprecated and can be removed in
|
||||
# version 2.0 of the RPC API
|
||||
def aggregate_metadata_add(self, context, aggregate, metadata,
|
||||
set_delete=False):
|
||||
new_metadata = self.db.aggregate_metadata_add(context.elevated(),
|
||||
aggregate['id'],
|
||||
metadata, set_delete)
|
||||
return jsonutils.to_primitive(new_metadata)
|
||||
|
||||
# NOTE(danms): This method is now deprecated and can be removed in
|
||||
# version 2.0 of the RPC API
|
||||
@messaging.expected_exceptions(exception.AggregateMetadataNotFound)
|
||||
def aggregate_metadata_delete(self, context, aggregate, key):
|
||||
self.db.aggregate_metadata_delete(context.elevated(),
|
||||
aggregate['id'], key)
|
||||
|
||||
def aggregate_metadata_get_by_host(self, context, host,
|
||||
key='availability_zone'):
|
||||
result = self.db.aggregate_metadata_get_by_host(context, host, key)
|
||||
return jsonutils.to_primitive(result)
|
||||
|
||||
def bw_usage_update(self, context, uuid, mac, start_period,
|
||||
bw_in=None, bw_out=None,
|
||||
last_ctr_in=None, last_ctr_out=None,
|
||||
last_refreshed=None,
|
||||
update_cells=True):
|
||||
bw_in, bw_out, last_ctr_in, last_ctr_out,
|
||||
last_refreshed, update_cells):
|
||||
if [bw_in, bw_out, last_ctr_in, last_ctr_out].count(None) != 4:
|
||||
self.db.bw_usage_update(context, uuid, mac, start_period,
|
||||
bw_in, bw_out, last_ctr_in, last_ctr_out,
|
||||
|
@ -264,23 +185,6 @@ class ConductorManager(manager.Manager):
|
|||
usage = self.db.bw_usage_get(context, uuid, start_period, mac)
|
||||
return jsonutils.to_primitive(usage)
|
||||
|
||||
# NOTE(russellb) This method can be removed in 2.0 of this API. It is
|
||||
# deprecated in favor of the method in the base API.
|
||||
def get_backdoor_port(self, context):
|
||||
return self.backdoor_port
|
||||
|
||||
# NOTE(danms): This method can be removed in version 2.0 of this API.
|
||||
def security_group_get_by_instance(self, context, instance):
|
||||
group = self.db.security_group_get_by_instance(context,
|
||||
instance['uuid'])
|
||||
return jsonutils.to_primitive(group)
|
||||
|
||||
# NOTE(danms): This method can be removed in version 2.0 of this API.
|
||||
def security_group_rule_get_by_security_group(self, context, secgroup):
|
||||
rules = self.db.security_group_rule_get_by_security_group(
|
||||
context, secgroup['id'])
|
||||
return jsonutils.to_primitive(rules, max_depth=4)
|
||||
|
||||
def provider_fw_rule_get_all(self, context):
|
||||
rules = self.db.provider_fw_rule_get_all(context)
|
||||
return jsonutils.to_primitive(rules)
|
||||
|
@ -290,8 +194,7 @@ class ConductorManager(manager.Manager):
|
|||
architecture)
|
||||
return jsonutils.to_primitive(info)
|
||||
|
||||
def block_device_mapping_update_or_create(self, context, values,
|
||||
create=None):
|
||||
def block_device_mapping_update_or_create(self, context, values, create):
|
||||
if create is None:
|
||||
bdm = self.db.block_device_mapping_update_or_create(context,
|
||||
values)
|
||||
|
@ -307,78 +210,30 @@ class ConductorManager(manager.Manager):
|
|||
create=create)
|
||||
|
||||
def block_device_mapping_get_all_by_instance(self, context, instance,
|
||||
legacy=True):
|
||||
legacy):
|
||||
bdms = self.db.block_device_mapping_get_all_by_instance(
|
||||
context, instance['uuid'])
|
||||
if legacy:
|
||||
bdms = block_device.legacy_mapping(bdms)
|
||||
return jsonutils.to_primitive(bdms)
|
||||
|
||||
# NOTE(russellb) This method can be removed in 2.0 of this API. It is
|
||||
# deprecated in favor of the method in the base API.
|
||||
def block_device_mapping_destroy(self, context, bdms=None,
|
||||
instance=None, volume_id=None,
|
||||
device_name=None):
|
||||
if bdms is not None:
|
||||
for bdm in bdms:
|
||||
self.db.block_device_mapping_destroy(context, bdm['id'])
|
||||
# NOTE(comstud): bdm['id'] will be different in API cell,
|
||||
# so we must try to destroy by device_name or volume_id.
|
||||
# We need an instance_uuid in order to do this properly,
|
||||
# too.
|
||||
# I hope to clean a lot of this up in the object
|
||||
# implementation.
|
||||
instance_uuid = (bdm['instance_uuid'] or
|
||||
(instance and instance['uuid']))
|
||||
if not instance_uuid:
|
||||
continue
|
||||
# Better to be safe than sorry. device_name is not
|
||||
# NULLable, however it could be an empty string.
|
||||
if bdm['device_name']:
|
||||
self.cells_rpcapi.bdm_destroy_at_top(
|
||||
context, instance_uuid,
|
||||
device_name=bdm['device_name'])
|
||||
elif bdm['volume_id']:
|
||||
self.cells_rpcapi.bdm_destroy_at_top(
|
||||
context, instance_uuid,
|
||||
volume_id=bdm['volume_id'])
|
||||
elif instance is not None and volume_id is not None:
|
||||
self.db.block_device_mapping_destroy_by_instance_and_volume(
|
||||
context, instance['uuid'], volume_id)
|
||||
self.cells_rpcapi.bdm_destroy_at_top(
|
||||
context, instance['uuid'], volume_id=volume_id)
|
||||
elif instance is not None and device_name is not None:
|
||||
self.db.block_device_mapping_destroy_by_instance_and_device(
|
||||
context, instance['uuid'], device_name)
|
||||
self.cells_rpcapi.bdm_destroy_at_top(
|
||||
context, instance['uuid'], device_name=device_name)
|
||||
else:
|
||||
# NOTE(danms): This shouldn't happen
|
||||
raise exception.Invalid(_("Invalid block_device_mapping_destroy"
|
||||
" invocation"))
|
||||
|
||||
def instance_get_all_by_filters(self, context, filters, sort_key,
|
||||
sort_dir, columns_to_join=None,
|
||||
use_slave=False):
|
||||
sort_dir, columns_to_join,
|
||||
use_slave):
|
||||
result = self.db.instance_get_all_by_filters(
|
||||
context, filters, sort_key, sort_dir,
|
||||
columns_to_join=columns_to_join, use_slave=use_slave)
|
||||
return jsonutils.to_primitive(result)
|
||||
|
||||
# NOTE(hanlind): This method can be removed in v2.0 of the RPC API.
|
||||
def instance_get_all_hung_in_rebooting(self, context, timeout):
|
||||
result = self.db.instance_get_all_hung_in_rebooting(context, timeout)
|
||||
return jsonutils.to_primitive(result)
|
||||
|
||||
def instance_get_active_by_window(self, context, begin, end=None,
|
||||
project_id=None, host=None):
|
||||
def instance_get_active_by_window(self, context, begin, end,
|
||||
project_id, host):
|
||||
# Unused, but cannot remove until major RPC version bump
|
||||
result = self.db.instance_get_active_by_window(context, begin, end,
|
||||
project_id, host)
|
||||
return jsonutils.to_primitive(result)
|
||||
|
||||
def instance_get_active_by_window_joined(self, context, begin, end=None,
|
||||
project_id=None, host=None):
|
||||
def instance_get_active_by_window_joined(self, context, begin, end,
|
||||
project_id, host):
|
||||
result = self.db.instance_get_active_by_window_joined(
|
||||
context, begin, end, project_id, host)
|
||||
return jsonutils.to_primitive(result)
|
||||
|
@ -390,32 +245,14 @@ class ConductorManager(manager.Manager):
|
|||
def instance_info_cache_delete(self, context, instance):
|
||||
self.db.instance_info_cache_delete(context, instance['uuid'])
|
||||
|
||||
# NOTE(hanlind): This method is now deprecated and can be removed in
|
||||
# version v2.0 of the RPC API.
|
||||
def instance_info_cache_update(self, context, instance, values):
|
||||
self.db.instance_info_cache_update(context, instance['uuid'],
|
||||
values)
|
||||
|
||||
# NOTE(danms): This method is now deprecated and can be removed in
|
||||
# version v2.0 of the RPC API.
|
||||
def instance_type_get(self, context, instance_type_id):
|
||||
result = self.db.flavor_get(context, instance_type_id)
|
||||
return jsonutils.to_primitive(result)
|
||||
|
||||
def instance_fault_create(self, context, values):
|
||||
result = self.db.instance_fault_create(context, values)
|
||||
return jsonutils.to_primitive(result)
|
||||
|
||||
# NOTE(kerrin): This method can be removed in v2.0 of the RPC API.
|
||||
def vol_get_usage_by_time(self, context, start_time):
|
||||
result = self.db.vol_get_usage_by_time(context, start_time)
|
||||
return jsonutils.to_primitive(result)
|
||||
|
||||
# NOTE(kerrin): The last_refreshed argument is unused by this method
|
||||
# and can be removed in v2.0 of the RPC API.
|
||||
# and can be removed in v3.0 of the RPC API.
|
||||
def vol_usage_update(self, context, vol_id, rd_req, rd_bytes, wr_req,
|
||||
wr_bytes, instance, last_refreshed=None,
|
||||
update_totals=False):
|
||||
wr_bytes, instance, last_refreshed, update_totals):
|
||||
vol_usage = self.db.vol_usage_update(context, vol_id,
|
||||
rd_req, rd_bytes,
|
||||
wr_req, wr_bytes,
|
||||
|
@ -431,13 +268,13 @@ class ConductorManager(manager.Manager):
|
|||
|
||||
@messaging.expected_exceptions(exception.ComputeHostNotFound,
|
||||
exception.HostBinaryNotFound)
|
||||
def service_get_all_by(self, context, topic=None, host=None, binary=None):
|
||||
def service_get_all_by(self, context, topic, host, binary):
|
||||
if not any((topic, host, binary)):
|
||||
result = self.db.service_get_all(context)
|
||||
elif all((topic, host)):
|
||||
if topic == 'compute':
|
||||
result = self.db.service_get_by_compute_host(context, host)
|
||||
# FIXME(comstud) Potentially remove this on bump to v2.0
|
||||
# FIXME(comstud) Potentially remove this on bump to v3.0
|
||||
result = [result]
|
||||
else:
|
||||
result = self.db.service_get_by_host_and_topic(context,
|
||||
|
@ -474,16 +311,7 @@ class ConductorManager(manager.Manager):
|
|||
result = self.db.compute_node_create(context, values)
|
||||
return jsonutils.to_primitive(result)
|
||||
|
||||
def compute_node_update(self, context, node, values, prune_stats=False):
|
||||
# NOTE(belliott) prune_stats is no longer relevant and will be
|
||||
# ignored
|
||||
if isinstance(values.get('stats'), dict):
|
||||
# NOTE(danms): In Icehouse, the 'stats' was changed from a dict
|
||||
# to a JSON string. If we get a dict-based value, convert it to
|
||||
# JSON, which the lower layers now expect. This can be removed
|
||||
# in version 2.0 of the RPC API
|
||||
values['stats'] = jsonutils.dumps(values['stats'])
|
||||
|
||||
def compute_node_update(self, context, node, values):
|
||||
result = self.db.compute_node_update(context, node['id'], values)
|
||||
return jsonutils.to_primitive(result)
|
||||
|
||||
|
@ -496,27 +324,27 @@ class ConductorManager(manager.Manager):
|
|||
svc = self.db.service_update(context, service['id'], values)
|
||||
return jsonutils.to_primitive(svc)
|
||||
|
||||
def task_log_get(self, context, task_name, begin, end, host, state=None):
|
||||
def task_log_get(self, context, task_name, begin, end, host, state):
|
||||
result = self.db.task_log_get(context, task_name, begin, end, host,
|
||||
state)
|
||||
return jsonutils.to_primitive(result)
|
||||
|
||||
def task_log_begin_task(self, context, task_name, begin, end, host,
|
||||
task_items=None, message=None):
|
||||
task_items, message):
|
||||
result = self.db.task_log_begin_task(context.elevated(), task_name,
|
||||
begin, end, host, task_items,
|
||||
message)
|
||||
return jsonutils.to_primitive(result)
|
||||
|
||||
def task_log_end_task(self, context, task_name, begin, end, host,
|
||||
errors, message=None):
|
||||
errors, message):
|
||||
result = self.db.task_log_end_task(context.elevated(), task_name,
|
||||
begin, end, host, errors, message)
|
||||
return jsonutils.to_primitive(result)
|
||||
|
||||
def notify_usage_exists(self, context, instance, current_period=False,
|
||||
ignore_missing_network_data=True,
|
||||
system_metadata=None, extra_usage_info=None):
|
||||
def notify_usage_exists(self, context, instance, current_period,
|
||||
ignore_missing_network_data,
|
||||
system_metadata, extra_usage_info):
|
||||
compute_utils.notify_usage_exists(self.notifier, context, instance,
|
||||
current_period,
|
||||
ignore_missing_network_data,
|
||||
|
@ -560,32 +388,6 @@ class ConductorManager(manager.Manager):
|
|||
|
||||
return ec2_ids
|
||||
|
||||
# NOTE(danms): This method is now deprecated and can be removed in
|
||||
# version v2.0 of the RPC API
|
||||
def compute_stop(self, context, instance, do_cast=True):
|
||||
# NOTE(mriedem): Clients using an interface before 1.43 will be sending
|
||||
# dicts so we need to handle that here since compute/api::stop()
|
||||
# requires an object.
|
||||
if isinstance(instance, dict):
|
||||
instance = instance_obj.Instance._from_db_object(
|
||||
context, instance_obj.Instance(), instance)
|
||||
self.compute_api.stop(context, instance, do_cast)
|
||||
|
||||
# NOTE(comstud): This method is now deprecated and can be removed in
|
||||
# version v2.0 of the RPC API
|
||||
def compute_confirm_resize(self, context, instance, migration_ref):
|
||||
if isinstance(instance, dict):
|
||||
attrs = ['metadata', 'system_metadata', 'info_cache',
|
||||
'security_groups']
|
||||
instance = instance_obj.Instance._from_db_object(
|
||||
context, instance_obj.Instance(), instance,
|
||||
expected_attrs=attrs)
|
||||
if isinstance(migration_ref, dict):
|
||||
migration_ref = migration_obj.Migration._from_db_object(
|
||||
context.elevated(), migration_ref)
|
||||
self.compute_api.confirm_resize(context, instance,
|
||||
migration=migration_ref)
|
||||
|
||||
def compute_unrescue(self, context, instance):
|
||||
self.compute_api.unrescue(context, instance)
|
||||
|
||||
|
@ -637,11 +439,6 @@ class ConductorManager(manager.Manager):
|
|||
updates['obj_what_changed'] = objinst.obj_what_changed()
|
||||
return updates, result
|
||||
|
||||
# NOTE(danms): This method is now deprecated and can be removed in
|
||||
# v2.0 of the RPC API
|
||||
def compute_reboot(self, context, instance, reboot_type):
|
||||
self.compute_api.reboot(context, instance, reboot_type)
|
||||
|
||||
def object_backport(self, context, objinst, target_version):
|
||||
return objinst.obj_to_primitive(target_version=target_version)
|
||||
|
||||
|
@ -912,193 +709,3 @@ class ComputeTaskManager(base.Base):
|
|||
del(sys_meta[key])
|
||||
instance.system_metadata = sys_meta
|
||||
instance.save()
|
||||
|
||||
|
||||
class _ConductorManagerV2Proxy(object):
|
||||
|
||||
target = messaging.Target(version='2.0')
|
||||
|
||||
def __init__(self, manager):
|
||||
self.manager = manager
|
||||
|
||||
def instance_update(self, context, instance_uuid, updates,
|
||||
service):
|
||||
return self.manager.instance_update(context, instance_uuid, updates,
|
||||
service)
|
||||
|
||||
# TODO(danms): This can be removed in version 3.0 of the RPC API
|
||||
def instance_get_by_uuid(self, context, instance_uuid,
|
||||
columns_to_join):
|
||||
return self.manager.instance_get_by_uuid(context, instance_uuid,
|
||||
columns_to_join)
|
||||
|
||||
def migration_get_in_progress_by_host_and_node(self, context,
|
||||
host, node):
|
||||
return self.manager.migration_get_in_progress_by_host_and_node(context,
|
||||
host, node)
|
||||
|
||||
# TODO(danms): This can be removed in v3.0 of the RPC API
|
||||
def aggregate_host_add(self, context, aggregate, host):
|
||||
return self.manager.aggregate_host_add(context, aggregate, host)
|
||||
|
||||
# TODO(danms): This can be removed in v3.0 of the RPC API
|
||||
def aggregate_host_delete(self, context, aggregate, host):
|
||||
return self.manager.aggregate_host_delete(context, aggregate, host)
|
||||
|
||||
def aggregate_metadata_get_by_host(self, context, host, key):
|
||||
return self.manager.aggregate_metadata_get_by_host(context, host, key)
|
||||
|
||||
def bw_usage_update(self, context, uuid, mac, start_period,
|
||||
bw_in, bw_out, last_ctr_in, last_ctr_out,
|
||||
last_refreshed, update_cells):
|
||||
return self.manager.bw_usage_update(context, uuid, mac, start_period,
|
||||
bw_in, bw_out, last_ctr_in, last_ctr_out, last_refreshed,
|
||||
update_cells)
|
||||
|
||||
def provider_fw_rule_get_all(self, context):
|
||||
return self.manager.provider_fw_rule_get_all(context)
|
||||
|
||||
def agent_build_get_by_triple(self, context, hypervisor, os, architecture):
|
||||
return self.manager.agent_build_get_by_triple(context, hypervisor, os,
|
||||
architecture)
|
||||
|
||||
def block_device_mapping_update_or_create(self, context, values, create):
|
||||
return self.manager.block_device_mapping_update_or_create(context,
|
||||
values, create)
|
||||
|
||||
def block_device_mapping_get_all_by_instance(self, context, instance,
|
||||
legacy):
|
||||
return self.manager.block_device_mapping_get_all_by_instance(context,
|
||||
instance, legacy)
|
||||
|
||||
# TODO(danms): This can be removed in version 3.0 of the RPC API
|
||||
def instance_get_all_by_filters(self, context, filters, sort_key,
|
||||
sort_dir, columns_to_join, use_slave):
|
||||
return self.manager.instance_get_all_by_filters(context, filters,
|
||||
sort_key, sort_dir, columns_to_join, use_slave)
|
||||
|
||||
# TODO(danms): This can be removed in version 3.0 of the RPC API
|
||||
def instance_get_active_by_window_joined(self, context, begin, end,
|
||||
project_id, host):
|
||||
return self.manager.instance_get_active_by_window_joined(context,
|
||||
begin, end, project_id, host)
|
||||
|
||||
# TODO(danms): This can be removed in version 3.0 of the RPC API
|
||||
def instance_destroy(self, context, instance):
|
||||
return self.manager.instance_destroy(context, instance)
|
||||
|
||||
def instance_info_cache_delete(self, context, instance):
|
||||
return self.manager.instance_info_cache_delete(context, instance)
|
||||
|
||||
def vol_get_usage_by_time(self, context, start_time):
|
||||
return self.manager.vol_get_usage_by_time(context, start_time)
|
||||
|
||||
def vol_usage_update(self, context, vol_id, rd_req, rd_bytes, wr_req,
|
||||
wr_bytes, instance, last_refreshed, update_totals):
|
||||
return self.manager.vol_usage_update(context, vol_id, rd_req, rd_bytes,
|
||||
wr_req, wr_bytes, instance, last_refreshed, update_totals)
|
||||
|
||||
def service_get_all_by(self, context, topic, host, binary):
|
||||
return self.manager.service_get_all_by(context, topic, host, binary)
|
||||
|
||||
def instance_get_all_by_host(self, context, host, node, columns_to_join):
|
||||
return self.manager.instance_get_all_by_host(context, host, node,
|
||||
columns_to_join)
|
||||
|
||||
# TODO(danms): This can be removed in version 3.0 of the RPC API
|
||||
def instance_fault_create(self, context, values):
|
||||
return self.manager.instance_fault_create(context, values)
|
||||
|
||||
# TODO(danms): This can be removed in version 3.0 of the RPC API
|
||||
def action_event_start(self, context, values):
|
||||
return self.manager.action_event_start(context, values)
|
||||
|
||||
# TODO(danms): This can be removed in version 3.0 of the RPC API
|
||||
def action_event_finish(self, context, values):
|
||||
return self.manager.action_event_finish(context, values)
|
||||
|
||||
def service_create(self, context, values):
|
||||
return self.manager.service_create(context, values)
|
||||
|
||||
def service_destroy(self, context, service_id):
|
||||
return self.manager.service_destroy(context, service_id)
|
||||
|
||||
def compute_node_create(self, context, values):
|
||||
return self.manager.compute_node_create(context, values)
|
||||
|
||||
def compute_node_update(self, context, node, values):
|
||||
return self.manager.compute_node_update(context, node, values)
|
||||
|
||||
def compute_node_delete(self, context, node):
|
||||
return self.manager.compute_node_delete(context, node)
|
||||
|
||||
def service_update(self, context, service, values):
|
||||
return self.manager.service_update(context, service, values)
|
||||
|
||||
def task_log_get(self, context, task_name, begin, end, host, state):
|
||||
return self.manager.task_log_get(context, task_name, begin, end, host,
|
||||
state)
|
||||
|
||||
def task_log_begin_task(self, context, task_name, begin, end, host,
|
||||
task_items, message):
|
||||
return self.manager.task_log_begin_task(context, task_name, begin, end,
|
||||
host, task_items, message)
|
||||
|
||||
def task_log_end_task(self, context, task_name, begin, end, host, errors,
|
||||
message):
|
||||
return self.manager.task_log_end_task(context, task_name, begin, end,
|
||||
host, errors, message)
|
||||
|
||||
def notify_usage_exists(self, context, instance, current_period,
|
||||
ignore_missing_network_data,
|
||||
system_metadata, extra_usage_info):
|
||||
return self.manager.notify_usage_exists(context, instance,
|
||||
current_period, ignore_missing_network_data, system_metadata,
|
||||
extra_usage_info)
|
||||
|
||||
def security_groups_trigger_handler(self, context, event, args):
|
||||
return self.manager.security_groups_trigger_handler(context, event,
|
||||
args)
|
||||
|
||||
def security_groups_trigger_members_refresh(self, context, group_ids):
|
||||
return self.manager.security_groups_trigger_members_refresh(context,
|
||||
group_ids)
|
||||
|
||||
# TODO(danms): This can be removed in version 3.0 of the RPC API
|
||||
def network_migrate_instance_start(self, context, instance, migration):
|
||||
return self.manager.network_migrate_instance_start(context, instance,
|
||||
migration)
|
||||
|
||||
# TODO(danms): This can be removed in version 3.0 of the RPC API
|
||||
def network_migrate_instance_finish(self, context, instance, migration):
|
||||
return self.manager.network_migrate_instance_finish(context, instance,
|
||||
migration)
|
||||
|
||||
# TODO(comstud): This can be removed in version 3.0 of RPCAPI
|
||||
def quota_commit(self, context, reservations, project_id, user_id):
|
||||
return self.manager.quota_commit(context, reservations, project_id,
|
||||
user_id)
|
||||
|
||||
# TODO(comstud): This can be removed in version 3.0 of RPCAPI
|
||||
def quota_rollback(self, context, reservations, project_id, user_id):
|
||||
return self.manager.quota_rollback(context, reservations, project_id,
|
||||
user_id)
|
||||
|
||||
def get_ec2_ids(self, context, instance):
|
||||
return self.manager.get_ec2_ids(context, instance)
|
||||
|
||||
# TODO(danms): This can be removed in version 3.0 of the RPCAPI
|
||||
def compute_unrescue(self, context, instance):
|
||||
return self.manager.compute_unrescue(context, instance)
|
||||
|
||||
def object_class_action(self, context, objname, objmethod, objver,
|
||||
args, kwargs):
|
||||
return self.manager.object_class_action(context, objname, objmethod,
|
||||
objver, args, kwargs)
|
||||
|
||||
def object_action(self, context, objinst, objmethod, args, kwargs):
|
||||
return self.manager.object_action(context, objinst, objmethod, args,
|
||||
kwargs)
|
||||
|
||||
def object_backport(self, context, objinst, target_version):
|
||||
return self.manager.object_backport(context, objinst, target_version)
|
||||
|
|
|
@ -39,7 +39,6 @@ from nova import objects
|
|||
from nova.objects import base as obj_base
|
||||
from nova.objects import fields
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova.objects import migration as migration_obj
|
||||
from nova.objects import quotas as quotas_obj
|
||||
from nova.openstack.common import jsonutils
|
||||
from nova.openstack.common import timeutils
|
||||
|
@ -53,7 +52,6 @@ from nova.tests.compute import test_compute
|
|||
from nova.tests import fake_instance
|
||||
from nova.tests import fake_notifier
|
||||
from nova.tests import fake_server_actions
|
||||
from nova.tests.objects import test_migration
|
||||
from nova import utils
|
||||
|
||||
|
||||
|
@ -113,7 +111,7 @@ class _BaseTestCase(object):
|
|||
|
||||
def _do_update(self, instance_uuid, **updates):
|
||||
return self.conductor.instance_update(self.context, instance_uuid,
|
||||
updates)
|
||||
updates, None)
|
||||
|
||||
def test_instance_update(self):
|
||||
instance = self._create_fake_instance()
|
||||
|
@ -160,7 +158,8 @@ class _BaseTestCase(object):
|
|||
db.bw_usage_get(*get_args).AndReturn('foo')
|
||||
|
||||
self.mox.ReplayAll()
|
||||
result = self.conductor.bw_usage_update(*update_args)
|
||||
result = self.conductor.bw_usage_update(*update_args,
|
||||
update_cells=True)
|
||||
self.assertEqual(result, 'foo')
|
||||
|
||||
def test_provider_fw_rule_get_all(self):
|
||||
|
@ -200,15 +199,6 @@ class _BaseTestCase(object):
|
|||
self.conductor.instance_info_cache_delete(self.context,
|
||||
{'uuid': 'fake-uuid'})
|
||||
|
||||
def test_vol_get_usage_by_time(self):
|
||||
self.mox.StubOutWithMock(db, 'vol_get_usage_by_time')
|
||||
db.vol_get_usage_by_time(self.context, 'fake-time').AndReturn(
|
||||
'fake-usage')
|
||||
self.mox.ReplayAll()
|
||||
result = self.conductor.vol_get_usage_by_time(self.context,
|
||||
'fake-time')
|
||||
self.assertEqual(result, 'fake-usage')
|
||||
|
||||
def test_vol_usage_update(self):
|
||||
self.mox.StubOutWithMock(db, 'vol_usage_update')
|
||||
self.mox.StubOutWithMock(compute_utils, 'usage_volume_info')
|
||||
|
@ -230,8 +220,7 @@ class _BaseTestCase(object):
|
|||
self.mox.ReplayAll()
|
||||
|
||||
self.conductor.vol_usage_update(self.context, 'fake-vol',
|
||||
22, 33, 44, 55, fake_inst,
|
||||
'fake-update-time', False)
|
||||
22, 33, 44, 55, fake_inst, None, False)
|
||||
|
||||
self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
|
||||
msg = fake_notifier.NOTIFICATIONS[0]
|
||||
|
@ -260,17 +249,6 @@ class _BaseTestCase(object):
|
|||
{'fake': 'values'})
|
||||
self.assertEqual(result, 'fake-result')
|
||||
|
||||
def test_compute_node_update_with_non_json_stats(self):
|
||||
node = {'id': 'fake-id'}
|
||||
fake_input = {'stats': {'a': 'b'}}
|
||||
fake_vals = {'stats': jsonutils.dumps(fake_input['stats'])}
|
||||
self.mox.StubOutWithMock(db, 'compute_node_update')
|
||||
db.compute_node_update(self.context, node['id'], fake_vals
|
||||
).AndReturn('fake-result')
|
||||
self.mox.ReplayAll()
|
||||
self.conductor.compute_node_update(self.context, node,
|
||||
fake_input)
|
||||
|
||||
def test_compute_node_delete(self):
|
||||
node = {'id': 'fake-id'}
|
||||
self.mox.StubOutWithMock(db, 'compute_node_delete')
|
||||
|
@ -294,7 +272,7 @@ class _BaseTestCase(object):
|
|||
'host', None).AndReturn('result')
|
||||
self.mox.ReplayAll()
|
||||
result = self.conductor.task_log_get(self.context, 'task', 'begin',
|
||||
'end', 'host')
|
||||
'end', 'host', None)
|
||||
self.assertEqual(result, 'result')
|
||||
|
||||
def test_task_log_begin_task(self):
|
||||
|
@ -344,7 +322,7 @@ class _BaseTestCase(object):
|
|||
|
||||
self.mox.ReplayAll()
|
||||
|
||||
self.conductor.notify_usage_exists(self.context, instance,
|
||||
self.conductor.notify_usage_exists(self.context, instance, False, True,
|
||||
system_metadata={},
|
||||
extra_usage_info=dict(extra='info'))
|
||||
|
||||
|
@ -401,64 +379,10 @@ class ConductorTestCase(_BaseTestCase, test.TestCase):
|
|||
def test_instance_get_by_uuid(self):
|
||||
orig_instance = self._create_fake_instance()
|
||||
copy_instance = self.conductor.instance_get_by_uuid(
|
||||
self.context, orig_instance['uuid'])
|
||||
self.context, orig_instance['uuid'], None)
|
||||
self.assertEqual(orig_instance['name'],
|
||||
copy_instance['name'])
|
||||
|
||||
def test_instance_info_cache_update(self):
|
||||
fake_values = {'key1': 'val1', 'key2': 'val2'}
|
||||
fake_inst = {'uuid': 'fake-uuid'}
|
||||
self.mox.StubOutWithMock(db, 'instance_info_cache_update')
|
||||
db.instance_info_cache_update(self.context, 'fake-uuid',
|
||||
fake_values)
|
||||
self.mox.ReplayAll()
|
||||
self.conductor.instance_info_cache_update(self.context,
|
||||
fake_inst,
|
||||
fake_values)
|
||||
|
||||
def test_migration_get(self):
|
||||
migration = db.migration_create(self.context.elevated(),
|
||||
{'instance_uuid': 'fake-uuid',
|
||||
'status': 'migrating'})
|
||||
self.assertEqual(jsonutils.to_primitive(migration),
|
||||
self.conductor.migration_get(self.context,
|
||||
migration['id']))
|
||||
|
||||
def test_migration_get_unconfirmed_by_dest_compute(self):
|
||||
self.mox.StubOutWithMock(db,
|
||||
'migration_get_unconfirmed_by_dest_compute')
|
||||
db.migration_get_unconfirmed_by_dest_compute(self.context,
|
||||
'fake-window',
|
||||
'fake-host')
|
||||
self.mox.ReplayAll()
|
||||
self.conductor.migration_get_unconfirmed_by_dest_compute(self.context,
|
||||
'fake-window',
|
||||
'fake-host')
|
||||
|
||||
def test_compute_confirm_resize(self):
|
||||
self.mox.StubOutWithMock(self.conductor_manager.compute_api,
|
||||
'confirm_resize')
|
||||
self.conductor_manager.compute_api.confirm_resize(
|
||||
self.context, 'instance', migration='migration')
|
||||
self.mox.ReplayAll()
|
||||
self.conductor.compute_confirm_resize(self.context, 'instance',
|
||||
'migration')
|
||||
|
||||
def test_migration_create(self):
|
||||
inst = {'uuid': 'fake-uuid',
|
||||
'host': 'fake-host',
|
||||
'node': 'fake-node'}
|
||||
self.mox.StubOutWithMock(db, 'migration_create')
|
||||
db.migration_create(self.context.elevated(),
|
||||
{'instance_uuid': inst['uuid'],
|
||||
'source_compute': inst['host'],
|
||||
'source_node': inst['node'],
|
||||
'fake-key': 'fake-value'}).AndReturn('result')
|
||||
self.mox.ReplayAll()
|
||||
result = self.conductor.migration_create(self.context, inst,
|
||||
{'fake-key': 'fake-value'})
|
||||
self.assertEqual(result, 'result')
|
||||
|
||||
def test_block_device_mapping_update_or_create(self):
|
||||
fake_bdm = {'id': 'fake-id', 'device_name': 'foo'}
|
||||
fake_bdm2 = {'id': 'fake-id', 'device_name': 'foo2'}
|
||||
|
@ -477,11 +401,6 @@ class ConductorTestCase(_BaseTestCase, test.TestCase):
|
|||
cells_rpcapi.bdm_update_or_create_at_top(self.context,
|
||||
fake_bdm2,
|
||||
create=False)
|
||||
db.block_device_mapping_update_or_create(
|
||||
self.context, fake_bdm).AndReturn(fake_bdm2)
|
||||
cells_rpcapi.bdm_update_or_create_at_top(self.context,
|
||||
fake_bdm2,
|
||||
create=None)
|
||||
self.mox.ReplayAll()
|
||||
self.conductor.block_device_mapping_update_or_create(self.context,
|
||||
fake_bdm,
|
||||
|
@ -489,8 +408,29 @@ class ConductorTestCase(_BaseTestCase, test.TestCase):
|
|||
self.conductor.block_device_mapping_update_or_create(self.context,
|
||||
fake_bdm,
|
||||
create=False)
|
||||
self.conductor.block_device_mapping_update_or_create(self.context,
|
||||
fake_bdm)
|
||||
|
||||
def test_instance_get_all_by_filters(self):
|
||||
filters = {'foo': 'bar'}
|
||||
self.mox.StubOutWithMock(db, 'instance_get_all_by_filters')
|
||||
db.instance_get_all_by_filters(self.context, filters,
|
||||
'fake-key', 'fake-sort',
|
||||
columns_to_join=None, use_slave=False)
|
||||
self.mox.ReplayAll()
|
||||
self.conductor.instance_get_all_by_filters(self.context, filters,
|
||||
'fake-key', 'fake-sort',
|
||||
None, False)
|
||||
|
||||
def test_instance_get_all_by_filters_use_slave(self):
|
||||
filters = {'foo': 'bar'}
|
||||
self.mox.StubOutWithMock(db, 'instance_get_all_by_filters')
|
||||
db.instance_get_all_by_filters(self.context, filters,
|
||||
'fake-key', 'fake-sort',
|
||||
columns_to_join=None, use_slave=True)
|
||||
self.mox.ReplayAll()
|
||||
self.conductor.instance_get_all_by_filters(self.context, filters,
|
||||
'fake-key', 'fake-sort',
|
||||
columns_to_join=None,
|
||||
use_slave=True)
|
||||
|
||||
def test_instance_get_all_by_host(self):
|
||||
self.mox.StubOutWithMock(db, 'instance_get_all_by_host')
|
||||
|
@ -500,10 +440,11 @@ class ConductorTestCase(_BaseTestCase, test.TestCase):
|
|||
db.instance_get_all_by_host_and_node(self.context.elevated(), 'host',
|
||||
'node').AndReturn('result')
|
||||
self.mox.ReplayAll()
|
||||
result = self.conductor.instance_get_all_by_host(self.context, 'host')
|
||||
result = self.conductor.instance_get_all_by_host(self.context, 'host',
|
||||
None, None)
|
||||
self.assertEqual(result, 'result')
|
||||
result = self.conductor.instance_get_all_by_host(self.context, 'host',
|
||||
'node')
|
||||
'node', None)
|
||||
self.assertEqual(result, 'result')
|
||||
|
||||
def _test_stubbed(self, name, dbargs, condargs,
|
||||
|
@ -535,44 +476,45 @@ class ConductorTestCase(_BaseTestCase, test.TestCase):
|
|||
self.assertEqual('fake-result', result)
|
||||
|
||||
def test_service_get_all(self):
|
||||
self._test_stubbed('service_get_all', (), {})
|
||||
self._test_stubbed('service_get_all', (),
|
||||
dict(host=None, topic=None, binary=None))
|
||||
|
||||
def test_service_get_by_host_and_topic(self):
|
||||
self._test_stubbed('service_get_by_host_and_topic',
|
||||
('host', 'topic'),
|
||||
dict(topic='topic', host='host'))
|
||||
dict(topic='topic', host='host', binary=None))
|
||||
|
||||
def test_service_get_all_by_topic(self):
|
||||
self._test_stubbed('service_get_all_by_topic',
|
||||
('topic',),
|
||||
dict(topic='topic'))
|
||||
dict(topic='topic', host=None, binary=None))
|
||||
|
||||
def test_service_get_all_by_host(self):
|
||||
self._test_stubbed('service_get_all_by_host',
|
||||
('host',),
|
||||
dict(host='host'))
|
||||
dict(host='host', topic=None, binary=None))
|
||||
|
||||
def test_service_get_by_compute_host(self):
|
||||
self._test_stubbed('service_get_by_compute_host',
|
||||
('host',),
|
||||
dict(topic='compute', host='host'),
|
||||
dict(topic='compute', host='host', binary=None),
|
||||
db_result_listified=True)
|
||||
|
||||
def test_service_get_by_args(self):
|
||||
self._test_stubbed('service_get_by_args',
|
||||
('host', 'binary'),
|
||||
dict(host='host', binary='binary'))
|
||||
dict(host='host', binary='binary', topic=None))
|
||||
|
||||
def test_service_get_by_compute_host_not_found(self):
|
||||
self._test_stubbed('service_get_by_compute_host',
|
||||
('host',),
|
||||
dict(topic='compute', host='host'),
|
||||
dict(topic='compute', host='host', binary=None),
|
||||
db_exception=exc.ComputeHostNotFound(host='host'))
|
||||
|
||||
def test_service_get_by_args_not_found(self):
|
||||
self._test_stubbed('service_get_by_args',
|
||||
('host', 'binary'),
|
||||
dict(host='host', binary='binary'),
|
||||
dict(host='host', binary='binary', topic=None),
|
||||
db_exception=exc.HostBinaryNotFound(binary='binary',
|
||||
host='host'))
|
||||
|
||||
|
@ -586,23 +528,6 @@ class ConductorTestCase(_BaseTestCase, test.TestCase):
|
|||
self.conductor.security_groups_trigger_handler(self.context,
|
||||
'event', ['args'])
|
||||
|
||||
def test_compute_confirm_resize_with_objects(self):
|
||||
# use an instance object rather than a dict
|
||||
instance = self._create_fake_instance()
|
||||
inst_obj = instance_obj.Instance._from_db_object(
|
||||
self.context, instance_obj.Instance(), instance)
|
||||
migration = test_migration.fake_db_migration()
|
||||
mig_obj = migration_obj.Migration._from_db_object(
|
||||
self.context.elevated(), migration_obj.Migration(),
|
||||
migration)
|
||||
self.mox.StubOutWithMock(self.conductor_manager.compute_api,
|
||||
'confirm_resize')
|
||||
self.conductor_manager.compute_api.confirm_resize(
|
||||
self.context, inst_obj, migration=mig_obj)
|
||||
self.mox.ReplayAll()
|
||||
self.conductor.compute_confirm_resize(self.context, inst_obj,
|
||||
mig_obj)
|
||||
|
||||
def _test_object_action(self, is_classmethod, raise_exception):
|
||||
class TestObject(obj_base.NovaObject):
|
||||
def foo(self, context, raise_exception=False):
|
||||
|
@ -662,48 +587,6 @@ class ConductorTestCase(_BaseTestCase, test.TestCase):
|
|||
self.assertIn('dict', updates)
|
||||
self.assertEqual({'foo': 'bar'}, updates['dict'])
|
||||
|
||||
def test_aggregate_metadata_add(self):
|
||||
aggregate = {'name': 'fake aggregate', 'id': 'fake-id'}
|
||||
metadata = {'foo': 'bar'}
|
||||
self.mox.StubOutWithMock(db, 'aggregate_metadata_add')
|
||||
db.aggregate_metadata_add(
|
||||
mox.IgnoreArg(), aggregate['id'], metadata, False).AndReturn(
|
||||
metadata)
|
||||
self.mox.ReplayAll()
|
||||
result = self.conductor.aggregate_metadata_add(self.context,
|
||||
aggregate,
|
||||
metadata)
|
||||
self.assertEqual(result, metadata)
|
||||
|
||||
def test_aggregate_metadata_delete(self):
|
||||
aggregate = {'name': 'fake aggregate', 'id': 'fake-id'}
|
||||
self.mox.StubOutWithMock(db, 'aggregate_metadata_delete')
|
||||
db.aggregate_metadata_delete(mox.IgnoreArg(), aggregate['id'], 'fake')
|
||||
self.mox.ReplayAll()
|
||||
self.conductor.aggregate_metadata_delete(self.context, aggregate,
|
||||
'fake')
|
||||
|
||||
def test_security_group_get_by_instance(self):
|
||||
fake_inst = {'uuid': 'fake-instance'}
|
||||
self.mox.StubOutWithMock(db, 'security_group_get_by_instance')
|
||||
db.security_group_get_by_instance(
|
||||
self.context, fake_inst['uuid']).AndReturn('it worked')
|
||||
self.mox.ReplayAll()
|
||||
result = self.conductor.security_group_get_by_instance(self.context,
|
||||
fake_inst)
|
||||
self.assertEqual(result, 'it worked')
|
||||
|
||||
def test_security_group_rule_get_by_security_group(self):
|
||||
fake_secgroup = {'id': 'fake-secgroup'}
|
||||
self.mox.StubOutWithMock(db,
|
||||
'security_group_rule_get_by_security_group')
|
||||
db.security_group_rule_get_by_security_group(
|
||||
self.context, fake_secgroup['id']).AndReturn('it worked')
|
||||
self.mox.ReplayAll()
|
||||
result = self.conductor.security_group_rule_get_by_security_group(
|
||||
self.context, fake_secgroup)
|
||||
self.assertEqual(result, 'it worked')
|
||||
|
||||
def _test_expected_exceptions(self, db_method, conductor_method, errors,
|
||||
*args, **kwargs):
|
||||
# Tests that expected exceptions are handled properly.
|
||||
|
@ -734,31 +617,13 @@ class ConductorTestCase(_BaseTestCase, test.TestCase):
|
|||
actual='bar'))
|
||||
self._test_expected_exceptions(
|
||||
'instance_update', self.conductor.instance_update,
|
||||
errors, None, {'foo': 'bar'})
|
||||
|
||||
def test_instance_get_expected_exceptions(self):
|
||||
error = exc.InstanceNotFound(instance_id=1)
|
||||
self._test_expected_exceptions(
|
||||
'instance_get', self.conductor.instance_get,
|
||||
[error], None)
|
||||
errors, None, {'foo': 'bar'}, None)
|
||||
|
||||
def test_instance_get_by_uuid_expected_exceptions(self):
|
||||
error = exc.InstanceNotFound(instance_id=1)
|
||||
self._test_expected_exceptions(
|
||||
'instance_get_by_uuid', self.conductor.instance_get_by_uuid,
|
||||
[error], None)
|
||||
|
||||
def test_migration_get_expected_exceptions(self):
|
||||
error = exc.MigrationNotFound(migration_id=1)
|
||||
self._test_expected_exceptions(
|
||||
'migration_get', self.conductor.migration_get,
|
||||
[error], None)
|
||||
|
||||
def test_migration_update_expected_exceptions(self):
|
||||
error = exc.MigrationNotFound(migration_id=1)
|
||||
self._test_expected_exceptions(
|
||||
'migration_update', self.conductor.migration_update,
|
||||
[error], {'id': 1}, None)
|
||||
[error], None, [])
|
||||
|
||||
def test_aggregate_host_add_expected_exceptions(self):
|
||||
error = exc.AggregateHostExists(aggregate_id=1, host='foo')
|
||||
|
@ -772,20 +637,6 @@ class ConductorTestCase(_BaseTestCase, test.TestCase):
|
|||
'aggregate_host_delete', self.conductor.aggregate_host_delete,
|
||||
[error], {'id': 1}, None)
|
||||
|
||||
def test_aggregate_get_expected_exceptions(self):
|
||||
error = exc.AggregateNotFound(aggregate_id=1)
|
||||
self._test_expected_exceptions(
|
||||
'aggregate_get', self.conductor.aggregate_get,
|
||||
[error], None)
|
||||
|
||||
def test_aggregate_metadata_delete_expected_exceptions(self):
|
||||
error = exc.AggregateMetadataNotFound(aggregate_id=1,
|
||||
metadata_key='foo')
|
||||
self._test_expected_exceptions(
|
||||
'aggregate_metadata_delete',
|
||||
self.conductor.aggregate_metadata_delete,
|
||||
[error], {'id': 1}, None)
|
||||
|
||||
def test_service_update_expected_exceptions(self):
|
||||
error = exc.ServiceNotFound(service_id=1)
|
||||
self._test_expected_exceptions(
|
||||
|
@ -877,7 +728,8 @@ class ConductorTestCase(_BaseTestCase, test.TestCase):
|
|||
columns_to_join=None, use_slave=False)
|
||||
self.mox.ReplayAll()
|
||||
self.conductor.instance_get_all_by_filters(self.context, filters,
|
||||
'fake-key', 'fake-sort')
|
||||
'fake-key', 'fake-sort',
|
||||
None, False)
|
||||
|
||||
def test_instance_get_all_by_filters_use_slave(self):
|
||||
filters = {'foo': 'bar'}
|
||||
|
@ -888,7 +740,7 @@ class ConductorTestCase(_BaseTestCase, test.TestCase):
|
|||
self.mox.ReplayAll()
|
||||
self.conductor.instance_get_all_by_filters(self.context, filters,
|
||||
'fake-key', 'fake-sort',
|
||||
use_slave=True)
|
||||
None, use_slave=True)
|
||||
|
||||
def test_instance_get_active_by_window_joined(self):
|
||||
self.mox.StubOutWithMock(db, 'instance_get_active_by_window_joined')
|
||||
|
@ -969,44 +821,45 @@ class ConductorRPCAPITestCase(_BaseTestCase, test.TestCase):
|
|||
self.assertEqual('fake-result', result)
|
||||
|
||||
def test_service_get_all(self):
|
||||
self._test_stubbed('service_get_all', (), {})
|
||||
self._test_stubbed('service_get_all', (),
|
||||
dict(topic=None, host=None, binary=None))
|
||||
|
||||
def test_service_get_by_host_and_topic(self):
|
||||
self._test_stubbed('service_get_by_host_and_topic',
|
||||
('host', 'topic'),
|
||||
dict(topic='topic', host='host'))
|
||||
dict(topic='topic', host='host', binary=None))
|
||||
|
||||
def test_service_get_all_by_topic(self):
|
||||
self._test_stubbed('service_get_all_by_topic',
|
||||
('topic',),
|
||||
dict(topic='topic'))
|
||||
dict(topic='topic', host=None, binary=None))
|
||||
|
||||
def test_service_get_all_by_host(self):
|
||||
self._test_stubbed('service_get_all_by_host',
|
||||
('host',),
|
||||
dict(host='host'))
|
||||
dict(host='host', topic=None, binary=None))
|
||||
|
||||
def test_service_get_by_compute_host(self):
|
||||
self._test_stubbed('service_get_by_compute_host',
|
||||
('host',),
|
||||
dict(topic='compute', host='host'),
|
||||
dict(topic='compute', host='host', binary=None),
|
||||
db_result_listified=True)
|
||||
|
||||
def test_service_get_by_args(self):
|
||||
self._test_stubbed('service_get_by_args',
|
||||
('host', 'binary'),
|
||||
dict(host='host', binary='binary'))
|
||||
dict(host='host', binary='binary', topic=None))
|
||||
|
||||
def test_service_get_by_compute_host_not_found(self):
|
||||
self._test_stubbed('service_get_by_compute_host',
|
||||
('host',),
|
||||
dict(topic='compute', host='host'),
|
||||
dict(topic='compute', host='host', binary=None),
|
||||
db_exception=exc.ComputeHostNotFound(host='host'))
|
||||
|
||||
def test_service_get_by_args_not_found(self):
|
||||
self._test_stubbed('service_get_by_args',
|
||||
('host', 'binary'),
|
||||
dict(host='host', binary='binary'),
|
||||
dict(host='host', binary='binary', topic=None),
|
||||
db_exception=exc.HostBinaryNotFound(binary='binary',
|
||||
host='host'))
|
||||
|
||||
|
@ -1144,7 +997,7 @@ class ConductorAPITestCase(_BaseTestCase, test.TestCase):
|
|||
None).AndReturn('fake-result')
|
||||
self.mox.ReplayAll()
|
||||
result = self.conductor.instance_get_all_by_host(self.context,
|
||||
'host')
|
||||
'host', None)
|
||||
self.assertEqual(result, 'fake-result')
|
||||
|
||||
def test_wait_until_ready(self):
|
||||
|
@ -2068,65 +1921,3 @@ class ConductorLocalComputeTaskAPITestCase(ConductorTaskAPITestCase):
|
|||
super(ConductorLocalComputeTaskAPITestCase, self).setUp()
|
||||
self.conductor = conductor_api.LocalComputeTaskAPI()
|
||||
self.conductor_manager = self.conductor._manager._target
|
||||
|
||||
|
||||
class ConductorV2ManagerProxyTestCase(test.NoDBTestCase):
|
||||
def test_v2_manager_proxy(self):
|
||||
manager = conductor_manager.ConductorManager()
|
||||
proxy = conductor_manager._ConductorManagerV2Proxy(manager)
|
||||
ctxt = context.get_admin_context()
|
||||
|
||||
methods = [
|
||||
# (method, number_of_args)
|
||||
('instance_update', 3),
|
||||
('instance_get_by_uuid', 2),
|
||||
('migration_get_in_progress_by_host_and_node', 2),
|
||||
('aggregate_host_add', 2),
|
||||
('aggregate_host_delete', 2),
|
||||
('aggregate_metadata_get_by_host', 2),
|
||||
('bw_usage_update', 9),
|
||||
('provider_fw_rule_get_all', 0),
|
||||
('agent_build_get_by_triple', 3),
|
||||
('block_device_mapping_update_or_create', 2),
|
||||
('block_device_mapping_get_all_by_instance', 2),
|
||||
('instance_get_all_by_filters', 5),
|
||||
('instance_get_active_by_window_joined', 4),
|
||||
('instance_destroy', 1),
|
||||
('instance_info_cache_delete', 1),
|
||||
('vol_get_usage_by_time', 1),
|
||||
('vol_usage_update', 8),
|
||||
('service_get_all_by', 3),
|
||||
('instance_get_all_by_host', 3),
|
||||
('instance_fault_create', 1),
|
||||
('action_event_start', 1),
|
||||
('action_event_finish', 1),
|
||||
('service_create', 1),
|
||||
('service_destroy', 1),
|
||||
('compute_node_create', 1),
|
||||
('compute_node_update', 2),
|
||||
('compute_node_delete', 1),
|
||||
('service_update', 2),
|
||||
('task_log_get', 5),
|
||||
('task_log_begin_task', 6),
|
||||
('task_log_end_task', 6),
|
||||
('notify_usage_exists', 5),
|
||||
('security_groups_trigger_handler', 2),
|
||||
('security_groups_trigger_members_refresh', 1),
|
||||
('network_migrate_instance_start', 2),
|
||||
('network_migrate_instance_finish', 2),
|
||||
('quota_commit', 3),
|
||||
('quota_rollback', 3),
|
||||
('get_ec2_ids', 1),
|
||||
('compute_unrescue', 1),
|
||||
('object_class_action', 5),
|
||||
('object_action', 4),
|
||||
('object_backport', 2),
|
||||
]
|
||||
|
||||
for method, num_args in methods:
|
||||
args = []
|
||||
for _i in xrange(num_args):
|
||||
args.append(None)
|
||||
with mock.patch.object(manager, method) as mock_method:
|
||||
getattr(proxy, method)(ctxt, *args)
|
||||
mock_method.assert_called_once_with(mock.ANY, *args)
|
||||
|
|
Loading…
Reference in New Issue