Merge "Add some notifications to the evacuate path"
This commit is contained in:
commit
8fd7b44d1a
|
@ -3286,6 +3286,9 @@ class API(base.Base):
|
|||
migration.dest_compute = host
|
||||
migration.create()
|
||||
|
||||
compute_utils.notify_about_instance_usage(
|
||||
self.notifier, context, instance, "evacuate")
|
||||
|
||||
return self.compute_task_api.rebuild_instance(context,
|
||||
instance=instance,
|
||||
new_pass=admin_password,
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
import copy
|
||||
import itertools
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging as messaging
|
||||
from oslo_serialization import jsonutils
|
||||
|
@ -43,11 +44,13 @@ from nova.network.security_group import openstack_driver
|
|||
from nova import objects
|
||||
from nova.objects import base as nova_object
|
||||
from nova import quota
|
||||
from nova import rpc
|
||||
from nova.scheduler import client as scheduler_client
|
||||
from nova.scheduler import utils as scheduler_utils
|
||||
from nova import utils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
CONF = cfg.CONF
|
||||
|
||||
# Instead of having a huge list of arguments to instance_update(), we just
|
||||
# accept a dict of fields to update and use this whitelist to validate it.
|
||||
|
@ -488,6 +491,7 @@ class ComputeTaskManager(base.Base):
|
|||
self.compute_rpcapi = compute_rpcapi.ComputeAPI()
|
||||
self.image_api = image.API()
|
||||
self.scheduler_client = scheduler_client.SchedulerClient()
|
||||
self.notifier = rpc.get_notifier('compute', CONF.host)
|
||||
|
||||
@messaging.expected_exceptions(exception.NoValidHost,
|
||||
exception.ComputeServiceUnavailable,
|
||||
|
@ -853,6 +857,9 @@ class ComputeTaskManager(base.Base):
|
|||
"cannot be rebuilt"),
|
||||
instance=instance)
|
||||
|
||||
compute_utils.notify_about_instance_usage(
|
||||
self.notifier, context, instance, "rebuild.scheduled")
|
||||
|
||||
self.compute_rpcapi.rebuild_instance(context,
|
||||
instance=instance,
|
||||
new_pass=new_pass,
|
||||
|
|
|
@ -9820,6 +9820,8 @@ class ComputeAPITestCase(BaseTestCase):
|
|||
self.assertEqual(1, len(migs))
|
||||
self.assertEqual('fake_host', migs[0].source_compute)
|
||||
self.assertEqual('accepted', migs[0].status)
|
||||
self.assertEqual('compute.instance.evacuate',
|
||||
fake_notifier.NOTIFICATIONS[0].event_type)
|
||||
|
||||
def test_fail_evacuate_from_non_existing_host(self):
|
||||
inst = {}
|
||||
|
|
|
@ -1436,6 +1436,8 @@ class _BaseTaskTestCase(object):
|
|||
rebuild_mock.assert_called_once_with(self.context,
|
||||
instance=inst_obj,
|
||||
**rebuild_args)
|
||||
self.assertEqual('compute.instance.rebuild.scheduled',
|
||||
fake_notifier.NOTIFICATIONS[0].event_type)
|
||||
|
||||
def test_rebuild_instance_with_scheduler_no_host(self):
|
||||
inst_obj = self._create_fake_instance_obj()
|
||||
|
|
Loading…
Reference in New Issue