Merge "Deprecate run_instance and remove unnecessary code"

This commit is contained in:
Jenkins
2014-05-30 09:41:48 +00:00
committed by Gerrit Code Review
20 changed files with 64 additions and 317 deletions
+2 -5
View File
@@ -64,11 +64,8 @@ class TargetCellFilter(filters.BaseCellFilter):
return [scheduler.state_manager.get_my_state()]
ctxt = filter_properties['context']
# NOTE(belliott) Remove after deprecated schedule_run_instance
# code goes away:
schedule = filter_properties['cell_scheduler_method']
schedule = getattr(scheduler.msg_runner, schedule)
schedule(ctxt, cell_name, filter_properties['host_sched_kwargs'])
scheduler.msg_runner.build_instances(ctxt, cell_name,
filter_properties['host_sched_kwargs'])
# Returning None means to skip further scheduling, because we
# handled it.
-9
View File
@@ -191,15 +191,6 @@ class CellsManager(manager.Manager):
else:
self.instance_update_at_top(ctxt, instance)
def schedule_run_instance(self, ctxt, host_sched_kwargs):
"""Pick a cell (possibly ourselves) to build new instance(s)
and forward the request accordingly.
"""
# Target is ourselves first.
our_cell = self.state_manager.get_my_state()
self.msg_runner.schedule_run_instance(ctxt, our_cell,
host_sched_kwargs)
def build_instances(self, ctxt, build_inst_kwargs):
"""Pick a cell (possibly ourselves) to build new instance(s) and
forward the request accordingly.
-13
View File
@@ -653,10 +653,6 @@ class _TargetedMessageMethods(_BaseMessageMethods):
def __init__(self, *args, **kwargs):
super(_TargetedMessageMethods, self).__init__(*args, **kwargs)
def schedule_run_instance(self, message, host_sched_kwargs):
"""Parent cell told us to schedule new instance creation."""
self.msg_runner.scheduler.run_instance(message, host_sched_kwargs)
def build_instances(self, message, build_inst_kwargs):
"""Parent cell told us to schedule new instance creation."""
self.msg_runner.scheduler.build_instances(message, build_inst_kwargs)
@@ -1412,15 +1408,6 @@ class MessageRunner(object):
method_kwargs, 'up', cell, fanout=True)
message.process()
def schedule_run_instance(self, ctxt, target_cell, host_sched_kwargs):
"""Called by the scheduler to tell a child cell to schedule
a new instance for build.
"""
method_kwargs = dict(host_sched_kwargs=host_sched_kwargs)
message = _TargetedMessage(self, ctxt, 'schedule_run_instance',
method_kwargs, 'down', target_cell)
message.process()
def build_instances(self, ctxt, target_cell, build_inst_kwargs):
"""Called by the cell scheduler to tell a child cell to build
instance(s).
-6
View File
@@ -134,12 +134,6 @@ class CellsAPI(object):
method_info=method_info,
call=True)
# NOTE(alaski): Deprecated and should be removed later.
def schedule_run_instance(self, ctxt, **kwargs):
"""Schedule a new instance for creation."""
self.client.cast(ctxt, 'schedule_run_instance',
host_sched_kwargs=kwargs)
def build_instances(self, ctxt, **kwargs):
"""Build instances."""
build_inst_kwargs = kwargs
-61
View File
@@ -35,7 +35,6 @@ from nova.objects import instance as instance_obj
from nova.objects import instance_action as instance_action_obj
from nova.openstack.common.gettextutils import _
from nova.openstack.common import log as logging
from nova.scheduler import rpcapi as scheduler_rpcapi
from nova.scheduler import utils as scheduler_utils
from nova import utils
@@ -73,7 +72,6 @@ class CellsScheduler(base.Base):
self.msg_runner = msg_runner
self.state_manager = msg_runner.state_manager
self.compute_api = compute.API()
self.scheduler_rpcapi = scheduler_rpcapi.SchedulerAPI()
self.compute_task_api = conductor.ComputeTaskAPI()
self.filter_handler = filters.CellFilterHandler()
self.filter_classes = self.filter_handler.get_matching_classes(
@@ -158,46 +156,6 @@ class CellsScheduler(base.Base):
target_cells = [cell.obj for cell in weighted_cells]
return target_cells
def _run_instance(self, message, target_cells, instance_uuids,
host_sched_kwargs):
"""Attempt to schedule instance(s)."""
ctxt = message.ctxt
request_spec = host_sched_kwargs['request_spec']
instance_properties = request_spec['instance_properties']
instance_type = request_spec['instance_type']
image = request_spec['image']
security_groups = request_spec['security_group']
block_device_mapping = request_spec['block_device_mapping']
LOG.debug("Scheduling with routing_path=%(routing_path)s",
{'routing_path': message.routing_path})
for target_cell in target_cells:
try:
if target_cell.is_me:
# Need to create instance DB entries as the host scheduler
# expects that the instance(s) already exists.
self._create_instances_here(ctxt, instance_uuids,
instance_properties, instance_type, image,
security_groups, block_device_mapping)
# Need to record the create action in the db as the
# scheduler expects it to already exist.
self._create_action_here(ctxt, instance_uuids)
self.scheduler_rpcapi.run_instance(ctxt,
**host_sched_kwargs)
return
self.msg_runner.schedule_run_instance(ctxt, target_cell,
host_sched_kwargs)
return
except Exception:
LOG.exception(_("Couldn't communicate with cell '%s'") %
target_cell.name)
# FIXME(comstud): Would be nice to kick this back up so that
# the parent cell could retry, if we had a parent.
msg = _("Couldn't communicate with any cells")
LOG.error(msg)
raise exception.NoCellsAvailable()
def _build_instances(self, message, target_cells, instance_uuids,
build_inst_kwargs):
"""Attempt to build instance(s) or send msg to child cell."""
@@ -252,29 +210,10 @@ class CellsScheduler(base.Base):
'routing_path': message.routing_path,
'host_sched_kwargs': build_inst_kwargs,
'request_spec': request_spec})
# NOTE(belliott) remove when deprecated schedule_run_instance
# code gets removed.
filter_properties['cell_scheduler_method'] = 'build_instances'
self._schedule_build_to_cells(message, instance_uuids,
filter_properties, self._build_instances, build_inst_kwargs)
def run_instance(self, message, host_sched_kwargs):
request_spec = host_sched_kwargs['request_spec']
instance_uuids = request_spec['instance_uuids']
filter_properties = copy.copy(host_sched_kwargs['filter_properties'])
filter_properties.update({'context': message.ctxt,
'scheduler': self,
'routing_path': message.routing_path,
'host_sched_kwargs': host_sched_kwargs,
'request_spec': request_spec})
# NOTE(belliott) remove when deprecated schedule_run_instance
# code gets removed.
filter_properties['cell_scheduler_method'] = 'schedule_run_instance'
self._schedule_build_to_cells(message, instance_uuids,
filter_properties, self._run_instance, host_sched_kwargs)
def _schedule_build_to_cells(self, message, instance_uuids,
filter_properties, method, method_kwargs):
"""Pick a cell where we should create a new instance(s)."""
-12
View File
@@ -64,16 +64,6 @@ class ComputeRPCAPIRedirect(object):
return _noop_rpc_wrapper
class SchedulerRPCAPIRedirect(object):
def __init__(self, cells_rpcapi_obj):
self.cells_rpcapi = cells_rpcapi_obj
def __getattr__(self, key):
def _noop_rpc_wrapper(*args, **kwargs):
return None
return _noop_rpc_wrapper
class ConductorTaskRPCAPIRedirect(object):
# NOTE(comstud): These are a list of methods where the cells_rpcapi
# and the compute_task_rpcapi methods have the same signatures. This
@@ -175,8 +165,6 @@ class ComputeCellsAPI(compute_api.API):
self.cells_rpcapi = cells_rpcapi.CellsAPI()
# Avoid casts/calls directly to compute
self.compute_rpcapi = ComputeRPCAPIRedirect(self.cells_rpcapi)
# Redirect scheduler run_instance to cells.
self.scheduler_rpcapi = SchedulerRPCAPIRedirect(self.cells_rpcapi)
# Redirect conductor build_instances to cells
self._compute_task_api = ConductorTaskRPCAPIRedirect(self.cells_rpcapi)
self._cell_type = 'api'
+3
View File
@@ -2107,6 +2107,9 @@ class ComputeManager(manager.Manager):
filter_properties, requested_networks,
injected_files, admin_password,
is_first_time, node, legacy_bdm_in_spec):
# NOTE(alaski) This method should be deprecated when the scheduler and
# compute rpc interfaces are bumped to 4.x, and slated for removal in
# 5.x as it is no longer used.
if filter_properties is None:
filter_properties = {}
+2
View File
@@ -767,6 +767,8 @@ class ComputeAPI(object):
cctxt.cast(ctxt, 'rollback_live_migration_at_destination',
instance=instance)
# NOTE(alaski): Remove this method when the scheduler rpc interface is
# bumped to 4.x as the only callers of this method will be removed.
def run_instance(self, ctxt, instance, host, request_spec,
filter_properties, requested_networks,
injected_files, admin_password,
+2
View File
@@ -78,6 +78,8 @@ class ChanceScheduler(driver.Scheduler):
raise exception.NoValidHost(reason='')
return dests
# NOTE(alaski): Remove this method when the scheduler rpc interface is
# bumped to 4.x as it is no longer used.
def schedule_run_instance(self, context, request_spec,
admin_password, injected_files,
requested_networks, is_first_time,
+2
View File
@@ -114,6 +114,8 @@ class Scheduler(object):
for service in services
if self.servicegroup_api.service_is_up(service)]
# NOTE(alaski): Remove this method when the scheduler rpc interface is
# bumped to 4.x as it is no longer used.
def schedule_run_instance(self, context, request_spec,
admin_password, injected_files,
requested_networks, is_first_time,
+2
View File
@@ -62,6 +62,8 @@ class FilterScheduler(driver.Scheduler):
self.compute_rpcapi = compute_rpcapi.ComputeAPI()
self.notifier = rpc.get_notifier('scheduler')
# NOTE(alaski): Remove this method when the scheduler rpc interface is
# bumped to 4.x as it is no longer used.
def schedule_run_instance(self, context, request_spec,
admin_password, injected_files,
requested_networks, is_first_time,
+2
View File
@@ -123,6 +123,8 @@ class SchedulerManager(manager.Manager):
dest, block_migration, disk_over_commit)
return task.execute()
# NOTE(alaski): Remove this method when the scheduler rpc interface is
# bumped to 4.x as it is no longer used.
def run_instance(self, context, request_spec, admin_password,
injected_files, requested_networks, is_first_time,
filter_properties, legacy_bdm_in_spec=True):
-13
View File
@@ -106,19 +106,6 @@ class SchedulerAPI(object):
return cctxt.call(ctxt, 'select_destinations',
request_spec=request_spec, filter_properties=filter_properties)
def run_instance(self, ctxt, request_spec, admin_password,
injected_files, requested_networks, is_first_time,
filter_properties, legacy_bdm_in_spec=True):
msg_kwargs = {'request_spec': request_spec,
'admin_password': admin_password,
'injected_files': injected_files,
'requested_networks': requested_networks,
'is_first_time': is_first_time,
'filter_properties': filter_properties,
'legacy_bdm_in_spec': legacy_bdm_in_spec}
cctxt = self.client.prepare()
cctxt.cast(ctxt, 'run_instance', **msg_kwargs)
def prep_resize(self, ctxt, instance, instance_type, image,
request_spec, filter_properties, reservations):
instance_p = jsonutils.to_primitive(instance)
+4 -4
View File
@@ -140,13 +140,13 @@ class TestTargetCellFilter(_FilterTestClass):
def test_target_cell_specified_not_me(self):
info = {}
def _fake_sched_run_instance(ctxt, cell, sched_kwargs):
def _fake_build_instances(ctxt, cell, sched_kwargs):
info['ctxt'] = ctxt
info['cell'] = cell
info['sched_kwargs'] = sched_kwargs
self.stubs.Set(self.msg_runner, 'schedule_run_instance',
_fake_sched_run_instance)
self.stubs.Set(self.msg_runner, 'build_instances',
_fake_build_instances)
cells = [1, 2, 3]
target_cell = 'fake!cell!path'
current_cell = 'not!the!same'
@@ -155,7 +155,7 @@ class TestTargetCellFilter(_FilterTestClass):
'scheduler': self.scheduler,
'context': self.context,
'host_sched_kwargs': 'meow',
'cell_scheduler_method': 'schedule_run_instance'}
'cell_scheduler_method': 'build_instances'}
# None is returned to bypass further scheduling.
self.assertIsNone(self._filter_cells(cells, filter_props))
# The filter should have re-scheduled to the child cell itself.
-10
View File
@@ -113,16 +113,6 @@ class CellsManagerClassTestCase(test.NoDBTestCase):
self.mox.ReplayAll()
self.cells_manager._update_our_parents(self.ctxt)
def test_schedule_run_instance(self):
host_sched_kwargs = 'fake_host_sched_kwargs_silently_passed'
self.mox.StubOutWithMock(self.msg_runner, 'schedule_run_instance')
our_cell = self.msg_runner.state_manager.get_my_state()
self.msg_runner.schedule_run_instance(self.ctxt, our_cell,
host_sched_kwargs)
self.mox.ReplayAll()
self.cells_manager.schedule_run_instance(self.ctxt,
host_sched_kwargs=host_sched_kwargs)
def test_build_instances(self):
build_inst_kwargs = {'instances': [1, 2]}
self.mox.StubOutWithMock(self.msg_runner, 'build_instances')
-11
View File
@@ -648,17 +648,6 @@ class CellsTargetedMethodsTestCase(test.TestCase):
self.tgt_db_inst = methods_cls.db
self.tgt_c_rpcapi = methods_cls.compute_rpcapi
def test_schedule_run_instance(self):
host_sched_kwargs = {'filter_properties': {},
'key1': 'value1',
'key2': 'value2'}
self.mox.StubOutWithMock(self.tgt_scheduler, 'run_instance')
self.tgt_scheduler.run_instance(self.ctxt, host_sched_kwargs)
self.mox.ReplayAll()
self.src_msg_runner.schedule_run_instance(self.ctxt,
self.tgt_cell_name,
host_sched_kwargs)
def test_build_instances(self):
build_inst_kwargs = {'filter_properties': {},
'key1': 'value1',
-12
View File
@@ -122,18 +122,6 @@ class CellsAPITestCase(test.NoDBTestCase):
expected_args)
self.assertEqual(fake_response, result)
def test_schedule_run_instance(self):
call_info = self._stub_rpc_method('cast', None)
self.cells_rpcapi.schedule_run_instance(
self.fake_context, arg1=1, arg2=2, arg3=3)
expected_args = {'host_sched_kwargs': {'arg1': 1,
'arg2': 2,
'arg3': 3}}
self._check_result(call_info, 'schedule_run_instance',
expected_args)
def test_build_instances(self):
call_info = self._stub_rpc_method('cast', None)
+45 -142
View File
@@ -81,11 +81,9 @@ class CellsSchedulerTestCase(test.TestCase):
self.instances = [{'uuid': uuid} for uuid in instance_uuids]
self.request_spec = {
'instance_uuids': instance_uuids,
'instance_properties': 'fake_properties',
'instance_properties': self.instances[0],
'instance_type': 'fake_type',
'image': 'fake_image',
'security_group': 'fake_sec_groups',
'block_device_mapping': 'fake_bdm'}
'image': 'fake_image'}
self.build_inst_kwargs = {
'instances': self.instances,
'image': 'fake_image',
@@ -137,42 +135,6 @@ class CellsSchedulerTestCase(test.TestCase):
instance['display_name'])
self.assertEqual('fake_image_ref', instance['image_ref'])
def test_run_instance_selects_child_cell(self):
# Make sure there's no capacity info so we're sure to
# select a child cell
our_cell_info = self.state_manager.get_my_state()
our_cell_info.capacities = {}
call_info = {'times': 0}
orig_fn = self.msg_runner.schedule_run_instance
def msg_runner_schedule_run_instance(ctxt, target_cell,
host_sched_kwargs):
# This gets called twice. Once for our running it
# in this cell.. and then it'll get called when the
# child cell is picked. So, first time.. just run it
# like normal.
if not call_info['times']:
call_info['times'] += 1
return orig_fn(ctxt, target_cell, host_sched_kwargs)
call_info['ctxt'] = ctxt
call_info['target_cell'] = target_cell
call_info['host_sched_kwargs'] = host_sched_kwargs
self.stubs.Set(self.msg_runner, 'schedule_run_instance',
msg_runner_schedule_run_instance)
host_sched_kwargs = {'request_spec': self.request_spec,
'filter_properties': {}}
self.msg_runner.schedule_run_instance(self.ctxt,
self.my_cell_state, host_sched_kwargs)
self.assertEqual(self.ctxt, call_info['ctxt'])
self.assertEqual(host_sched_kwargs, call_info['host_sched_kwargs'])
child_cells = self.state_manager.get_child_cells()
self.assertIn(call_info['target_cell'], child_cells)
def test_build_instances_selects_child_cell(self):
# Make sure there's no capacity info so we're sure to
# select a child cell
@@ -215,51 +177,6 @@ class CellsSchedulerTestCase(test.TestCase):
child_cells = self.state_manager.get_child_cells()
self.assertIn(call_info['target_cell'], child_cells)
def test_run_instance_selects_current_cell(self):
# Make sure there's no child cells so that we will be
# selected
self.state_manager.child_cells = {}
call_info = {}
def fake_create_instances_here(ctxt, instance_uuids,
instance_properties, instance_type, image, security_groups,
block_device_mapping):
call_info['ctxt'] = ctxt
call_info['instance_uuids'] = instance_uuids
call_info['instance_properties'] = instance_properties
call_info['instance_type'] = instance_type
call_info['image'] = image
call_info['security_groups'] = security_groups
call_info['block_device_mapping'] = block_device_mapping
def fake_rpc_run_instance(ctxt, **host_sched_kwargs):
call_info['host_sched_kwargs'] = host_sched_kwargs
self.stubs.Set(self.scheduler, '_create_instances_here',
fake_create_instances_here)
self.stubs.Set(self.scheduler.scheduler_rpcapi,
'run_instance', fake_rpc_run_instance)
host_sched_kwargs = {'request_spec': self.request_spec,
'filter_properties': {},
'other': 'stuff'}
self.msg_runner.schedule_run_instance(self.ctxt,
self.my_cell_state, host_sched_kwargs)
self.assertEqual(self.ctxt, call_info['ctxt'])
self.assertEqual(host_sched_kwargs, call_info['host_sched_kwargs'])
self.assertEqual(self.instance_uuids, call_info['instance_uuids'])
self.assertEqual(self.request_spec['instance_properties'],
call_info['instance_properties'])
self.assertEqual(self.request_spec['instance_type'],
call_info['instance_type'])
self.assertEqual(self.request_spec['image'], call_info['image'])
self.assertEqual(self.request_spec['security_group'],
call_info['security_groups'])
self.assertEqual(self.request_spec['block_device_mapping'],
call_info['block_device_mapping'])
def test_build_instances_selects_current_cell(self):
# Make sure there's no child cells so that we will be
# selected
@@ -317,36 +234,6 @@ class CellsSchedulerTestCase(test.TestCase):
call_info['build_inst_kwargs'])
self.assertEqual(self.instance_uuids, call_info['instance_uuids'])
def test_run_instance_retries_when_no_cells_avail(self):
self.flags(scheduler_retries=7, group='cells')
host_sched_kwargs = {'request_spec': self.request_spec,
'filter_properties': {}}
call_info = {'num_tries': 0, 'errored_uuids': []}
def fake_grab_target_cells(filter_properties):
call_info['num_tries'] += 1
raise exception.NoCellsAvailable()
def fake_sleep(_secs):
return
def fake_instance_update(ctxt, instance_uuid, values):
self.assertEqual(vm_states.ERROR, values['vm_state'])
call_info['errored_uuids'].append(instance_uuid)
self.stubs.Set(self.scheduler, '_grab_target_cells',
fake_grab_target_cells)
self.stubs.Set(time, 'sleep', fake_sleep)
self.stubs.Set(db, 'instance_update', fake_instance_update)
self.msg_runner.schedule_run_instance(self.ctxt,
self.my_cell_state, host_sched_kwargs)
self.assertEqual(8, call_info['num_tries'])
self.assertEqual(self.instance_uuids, call_info['errored_uuids'])
def test_build_instances_retries_when_no_cells_avail(self):
self.flags(scheduler_retries=7, group='cells')
@@ -470,7 +357,7 @@ class CellsSchedulerTestCase(test.TestCase):
call_info['security_groups'] = security_groups
call_info['block_device_mapping'] = block_device_mapping
def fake_rpc_run_instance(ctxt, **host_sched_kwargs):
def fake_rpc_build_instances(ctxt, **host_sched_kwargs):
call_info['host_sched_kwargs'] = host_sched_kwargs
def fake_get_filtered_objs(filter_classes, cells, filt_properties):
@@ -479,19 +366,32 @@ class CellsSchedulerTestCase(test.TestCase):
call_info['filt_props'] = filt_properties
return cells
def fake_build_request_spec(ctxt, image, instances):
request_spec = {
'instance_uuids': [inst['uuid'] for inst in instances],
'instance_properties': instances[0],
'image': image,
'instance_type': 'fake_type'}
return request_spec
self.stubs.Set(self.scheduler, '_create_instances_here',
fake_create_instances_here)
self.stubs.Set(self.scheduler.scheduler_rpcapi,
'run_instance', fake_rpc_run_instance)
self.stubs.Set(self.scheduler.compute_task_api,
'build_instances', fake_rpc_build_instances)
self.stubs.Set(scheduler_utils, 'build_request_spec',
fake_build_request_spec)
filter_handler = self.scheduler.filter_handler
self.stubs.Set(filter_handler, 'get_filtered_objects',
fake_get_filtered_objs)
host_sched_kwargs = {'request_spec': self.request_spec,
'filter_properties': {},
'other': 'stuff'}
host_sched_kwargs = {'image': 'fake_image',
'instances': self.instances,
'filter_properties':
{'instance_type': 'fake_type'},
'security_groups': 'fake_sec_groups',
'block_device_mapping': 'fake_bdm'}
self.msg_runner.schedule_run_instance(self.ctxt,
self.msg_runner.build_instances(self.ctxt,
self.my_cell_state, host_sched_kwargs)
# Our cell was selected.
self.assertEqual(self.ctxt, call_info['ctxt'])
@@ -501,10 +401,6 @@ class CellsSchedulerTestCase(test.TestCase):
self.assertEqual(self.request_spec['instance_type'],
call_info['instance_type'])
self.assertEqual(self.request_spec['image'], call_info['image'])
self.assertEqual(self.request_spec['security_group'],
call_info['security_groups'])
self.assertEqual(self.request_spec['block_device_mapping'],
call_info['block_device_mapping'])
self.assertEqual(host_sched_kwargs, call_info['host_sched_kwargs'])
# Filter args are correct
expected_filt_props = {'context': self.ctxt,
@@ -512,8 +408,7 @@ class CellsSchedulerTestCase(test.TestCase):
'routing_path': self.my_cell_state.name,
'host_sched_kwargs': host_sched_kwargs,
'request_spec': self.request_spec,
'cell_scheduler_method':
'schedule_run_instance'}
'instance_type': 'fake_type'}
self.assertEqual(expected_filt_props, call_info['filt_props'])
self.assertEqual([FakeFilterClass1, FakeFilterClass2],
call_info['filt_classes'])
@@ -548,7 +443,7 @@ class CellsSchedulerTestCase(test.TestCase):
self.stubs.Set(filter_handler, 'get_filtered_objects',
fake_get_filtered_objs)
self.msg_runner.schedule_run_instance(self.ctxt,
self.msg_runner.build_instances(self.ctxt,
self.my_cell_state, {})
self.assertFalse(call_info['scheduled'])
@@ -577,7 +472,7 @@ class CellsSchedulerTestCase(test.TestCase):
call_info['security_groups'] = security_groups
call_info['block_device_mapping'] = block_device_mapping
def fake_rpc_run_instance(ctxt, **host_sched_kwargs):
def fake_rpc_build_instances(ctxt, **host_sched_kwargs):
call_info['host_sched_kwargs'] = host_sched_kwargs
def fake_get_weighed_objs(weight_classes, cells, filt_properties):
@@ -586,19 +481,32 @@ class CellsSchedulerTestCase(test.TestCase):
call_info['weight_props'] = filt_properties
return [weights.WeightedCell(cells[0], 0.0)]
def fake_build_request_spec(ctxt, image, instances):
request_spec = {
'instance_uuids': [inst['uuid'] for inst in instances],
'instance_properties': instances[0],
'image': image,
'instance_type': 'fake_type'}
return request_spec
self.stubs.Set(self.scheduler, '_create_instances_here',
fake_create_instances_here)
self.stubs.Set(self.scheduler.scheduler_rpcapi,
'run_instance', fake_rpc_run_instance)
self.stubs.Set(scheduler_utils, 'build_request_spec',
fake_build_request_spec)
self.stubs.Set(self.scheduler.compute_task_api,
'build_instances', fake_rpc_build_instances)
weight_handler = self.scheduler.weight_handler
self.stubs.Set(weight_handler, 'get_weighed_objects',
fake_get_weighed_objs)
host_sched_kwargs = {'request_spec': self.request_spec,
'filter_properties': {},
'other': 'stuff'}
host_sched_kwargs = {'image': 'fake_image',
'instances': self.instances,
'filter_properties':
{'instance_type': 'fake_type'},
'security_groups': 'fake_sec_groups',
'block_device_mapping': 'fake_bdm'}
self.msg_runner.schedule_run_instance(self.ctxt,
self.msg_runner.build_instances(self.ctxt,
self.my_cell_state, host_sched_kwargs)
# Our cell was selected.
self.assertEqual(self.ctxt, call_info['ctxt'])
@@ -608,10 +516,6 @@ class CellsSchedulerTestCase(test.TestCase):
self.assertEqual(self.request_spec['instance_type'],
call_info['instance_type'])
self.assertEqual(self.request_spec['image'], call_info['image'])
self.assertEqual(self.request_spec['security_group'],
call_info['security_groups'])
self.assertEqual(self.request_spec['block_device_mapping'],
call_info['block_device_mapping'])
self.assertEqual(host_sched_kwargs, call_info['host_sched_kwargs'])
# Weight args are correct
expected_filt_props = {'context': self.ctxt,
@@ -619,8 +523,7 @@ class CellsSchedulerTestCase(test.TestCase):
'routing_path': self.my_cell_state.name,
'host_sched_kwargs': host_sched_kwargs,
'request_spec': self.request_spec,
'cell_scheduler_method':
'schedule_run_instance'}
'instance_type': 'fake_type'}
self.assertEqual(expected_filt_props, call_info['weight_props'])
self.assertEqual([FakeWeightClass1, FakeWeightClass2],
call_info['weight_classes'])
-8
View File
@@ -63,14 +63,6 @@ class SchedulerRpcAPITestCase(test.NoDBTestCase):
retval = getattr(rpcapi, method)(ctxt, **kwargs)
self.assertEqual(retval, expected_retval)
def test_run_instance(self):
self._test_scheduler_api('run_instance', rpc_method='cast',
request_spec='fake_request_spec',
admin_password='pw', injected_files='fake_injected_files',
requested_networks='fake_requested_networks',
is_first_time=True, filter_properties='fake_filter_properties',
legacy_bdm_in_spec=False)
def test_prep_resize(self):
self._test_scheduler_api('prep_resize', rpc_method='cast',
instance='fake_instance',
-11
View File
@@ -27,8 +27,6 @@ from nova.db.sqlalchemy import models as sqa_models
from nova import exception
from nova.openstack.common import timeutils
from nova import quota
from nova.scheduler import driver as scheduler_driver
from nova.scheduler import rpcapi as scheduler_rpcapi
from nova import test
import nova.tests.image.fake
@@ -59,15 +57,6 @@ class QuotaIntegrationTestCase(test.TestCase):
self.compute_api = compute.API()
def fake_run_instance(self, ctxt, request_spec, *args):
"""Stub out the scheduler creating the instance entry."""
instance = scheduler_driver.Scheduler().create_instance_db_entry(
context, request_spec, None)
return [scheduler_driver.encode_instance(instance)]
self.stubs.Set(scheduler_rpcapi.SchedulerAPI, 'run_instance',
fake_run_instance)
def tearDown(self):
super(QuotaIntegrationTestCase, self).tearDown()
nova.tests.image.fake.FakeImageService_reset()