Merge "Remove unused scheduler driver methods"
This commit is contained in:
commit
0fd9995e37
|
@ -19,24 +19,13 @@
|
|||
Scheduler base class that all Schedulers should inherit from
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
from oslo.config import cfg
|
||||
from oslo.utils import importutils
|
||||
from oslo.utils import timeutils
|
||||
|
||||
from nova.compute import utils as compute_utils
|
||||
from nova.compute import vm_states
|
||||
from nova import db
|
||||
from nova import exception
|
||||
from nova.i18n import _, _LE, _LW
|
||||
from nova import notifications
|
||||
from nova.openstack.common import log as logging
|
||||
from nova import rpc
|
||||
from nova.i18n import _
|
||||
from nova import servicegroup
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
scheduler_driver_opts = [
|
||||
cfg.StrOpt('scheduler_host_manager',
|
||||
default='nova.scheduler.host_manager.HostManager',
|
||||
|
@ -47,54 +36,6 @@ CONF = cfg.CONF
|
|||
CONF.register_opts(scheduler_driver_opts)
|
||||
|
||||
|
||||
def handle_schedule_error(context, ex, instance_uuid, request_spec):
|
||||
"""On run_instance failure, update instance state and
|
||||
send notifications.
|
||||
"""
|
||||
|
||||
if isinstance(ex, exception.NoValidHost):
|
||||
LOG.warning(_LW("NoValidHost exception with message: \'%s\'"),
|
||||
ex.format_message().strip(),
|
||||
instance_uuid=instance_uuid)
|
||||
else:
|
||||
LOG.exception(_LE("Exception during scheduler.run_instance"))
|
||||
state = vm_states.ERROR.upper()
|
||||
LOG.warning(_LW('Setting instance to %s state.'), state,
|
||||
instance_uuid=instance_uuid)
|
||||
|
||||
(old_ref, new_ref) = db.instance_update_and_get_original(context,
|
||||
instance_uuid, {'vm_state': vm_states.ERROR,
|
||||
'task_state': None})
|
||||
notifications.send_update(context, old_ref, new_ref,
|
||||
service="scheduler")
|
||||
compute_utils.add_instance_fault_from_exc(context,
|
||||
new_ref, ex, sys.exc_info())
|
||||
|
||||
properties = request_spec.get('instance_properties', {})
|
||||
payload = dict(request_spec=request_spec,
|
||||
instance_properties=properties,
|
||||
instance_id=instance_uuid,
|
||||
state=vm_states.ERROR,
|
||||
method='run_instance',
|
||||
reason=ex)
|
||||
|
||||
rpc.get_notifier('scheduler').error(context,
|
||||
'scheduler.run_instance', payload)
|
||||
|
||||
|
||||
def instance_update_db(context, instance_uuid, extra_values=None):
|
||||
"""Clear the host and node - set the scheduled_at field of an Instance.
|
||||
|
||||
:returns: An Instance with the updated fields set properly.
|
||||
"""
|
||||
now = timeutils.utcnow()
|
||||
values = {'host': None, 'node': None, 'scheduled_at': now}
|
||||
if extra_values:
|
||||
values.update(extra_values)
|
||||
|
||||
return db.instance_update(context, instance_uuid, values)
|
||||
|
||||
|
||||
class Scheduler(object):
|
||||
"""The base class that all Scheduler classes should inherit from."""
|
||||
|
||||
|
|
|
@ -48,7 +48,6 @@ from nova.objects import fields
|
|||
from nova.objects import quotas as quotas_obj
|
||||
from nova import quota
|
||||
from nova import rpc
|
||||
from nova.scheduler import driver as scheduler_driver
|
||||
from nova.scheduler import utils as scheduler_utils
|
||||
from nova import test
|
||||
from nova.tests.unit import cast_as_call
|
||||
|
@ -2042,7 +2041,6 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
|
|||
'instance_properties': instances[0]}
|
||||
self.mox.StubOutWithMock(scheduler_utils, 'build_request_spec')
|
||||
self.mox.StubOutWithMock(scheduler_utils, 'setup_instance_group')
|
||||
self.mox.StubOutWithMock(scheduler_driver, 'handle_schedule_error')
|
||||
self.mox.StubOutWithMock(self.conductor_manager.scheduler_client,
|
||||
'select_destinations')
|
||||
self.mox.StubOutWithMock(self.conductor_manager.compute_rpcapi,
|
||||
|
|
|
@ -18,7 +18,6 @@ Tests For Scheduler
|
|||
"""
|
||||
|
||||
import mock
|
||||
from mox3 import mox
|
||||
from oslo.config import cfg
|
||||
|
||||
from nova.compute import api as compute_api
|
||||
|
@ -26,14 +25,12 @@ from nova import context
|
|||
from nova import db
|
||||
from nova import exception
|
||||
from nova.image import glance
|
||||
from nova import rpc
|
||||
from nova.scheduler import driver
|
||||
from nova.scheduler import manager
|
||||
from nova import servicegroup
|
||||
from nova import test
|
||||
from nova.tests.unit import fake_server_actions
|
||||
from nova.tests.unit.image import fake as fake_image
|
||||
from nova.tests.unit.objects import test_instance_fault
|
||||
from nova.tests.unit.scheduler import fakes
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
@ -139,25 +136,6 @@ class SchedulerTestCase(test.NoDBTestCase):
|
|||
result = self.driver.hosts_up(self.context, self.topic)
|
||||
self.assertEqual(result, ['host2'])
|
||||
|
||||
def test_handle_schedule_error_adds_instance_fault(self):
|
||||
instance = {'uuid': 'fake-uuid'}
|
||||
self.mox.StubOutWithMock(db, 'instance_update_and_get_original')
|
||||
self.mox.StubOutWithMock(db, 'instance_fault_create')
|
||||
db.instance_update_and_get_original(self.context, instance['uuid'],
|
||||
mox.IgnoreArg()).AndReturn(
|
||||
(None, instance))
|
||||
db.instance_fault_create(self.context, mox.IgnoreArg()).AndReturn(
|
||||
test_instance_fault.fake_faults['fake-uuid'][0])
|
||||
self.mox.StubOutWithMock(rpc, 'get_notifier')
|
||||
notifier = self.mox.CreateMockAnything()
|
||||
rpc.get_notifier('scheduler').AndReturn(notifier)
|
||||
notifier.error(self.context, 'scheduler.run_instance', mox.IgnoreArg())
|
||||
self.mox.ReplayAll()
|
||||
|
||||
driver.handle_schedule_error(self.context,
|
||||
exception.NoValidHost('test'),
|
||||
instance['uuid'], {})
|
||||
|
||||
|
||||
class SchedulerDriverBaseTestCase(SchedulerTestCase):
|
||||
"""Test cases for base scheduler driver class methods
|
||||
|
|
Loading…
Reference in New Issue