Transform instance.restore notifications
The instance.restore.start and instance.restore.end notifications are transformed to the versioned framework. Change-Id: I4459ec05a7153af7a0f04adcccb9d99cb5f661e5 Implements: bp versioned-notification-transformation-newton
This commit is contained in:
parent
d3c1ce2635
commit
bd0ba826e4
62
doc/notification_samples/instance-restore-end.json
Normal file
62
doc/notification_samples/instance-restore-end.json
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
{
|
||||||
|
"event_type":"instance.restore.end",
|
||||||
|
"payload":{
|
||||||
|
"nova_object.data":{
|
||||||
|
"architecture":"x86_64",
|
||||||
|
"availability_zone":null,
|
||||||
|
"created_at":"2012-10-29T13:42:11Z",
|
||||||
|
"deleted_at":null,
|
||||||
|
"display_name":"some-server",
|
||||||
|
"fault":null,
|
||||||
|
"host":"compute",
|
||||||
|
"host_name":"some-server",
|
||||||
|
"ip_addresses": [{
|
||||||
|
"nova_object.name": "IpPayload",
|
||||||
|
"nova_object.namespace": "nova",
|
||||||
|
"nova_object.version": "1.0",
|
||||||
|
"nova_object.data": {
|
||||||
|
"mac": "fa:16:3e:4c:2c:30",
|
||||||
|
"address": "192.168.1.3",
|
||||||
|
"port_uuid": "ce531f90-199f-48c0-816c-13e38010b442",
|
||||||
|
"meta": {},
|
||||||
|
"version": 4,
|
||||||
|
"label": "private-network",
|
||||||
|
"device_name": "tapce531f90-19"
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
"kernel_id":"",
|
||||||
|
"launched_at":"2012-10-29T13:42:11Z",
|
||||||
|
"image_uuid": "155d900f-4e14-4e4c-a73d-069cbf4541e6",
|
||||||
|
"metadata":{},
|
||||||
|
"node":"fake-mini",
|
||||||
|
"os_type":null,
|
||||||
|
"progress":0,
|
||||||
|
"ramdisk_id":"",
|
||||||
|
"reservation_id":"r-npxv0e40",
|
||||||
|
"state":"active",
|
||||||
|
"task_state":null,
|
||||||
|
"power_state":"running",
|
||||||
|
"tenant_id":"6f70656e737461636b20342065766572",
|
||||||
|
"terminated_at":null,
|
||||||
|
"flavor": {
|
||||||
|
"nova_object.name": "FlavorPayload",
|
||||||
|
"nova_object.data": {
|
||||||
|
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||||
|
"root_gb": 1,
|
||||||
|
"vcpus": 1,
|
||||||
|
"ephemeral_gb": 0,
|
||||||
|
"memory_mb": 512
|
||||||
|
},
|
||||||
|
"nova_object.version": "1.0",
|
||||||
|
"nova_object.namespace": "nova"
|
||||||
|
},
|
||||||
|
"user_id":"fake",
|
||||||
|
"uuid":"178b0921-8f85-4257-88b6-2e743b5a975c"
|
||||||
|
},
|
||||||
|
"nova_object.name":"InstanceActionPayload",
|
||||||
|
"nova_object.namespace":"nova",
|
||||||
|
"nova_object.version":"1.0"
|
||||||
|
},
|
||||||
|
"priority":"INFO",
|
||||||
|
"publisher_id":"nova-compute:compute"
|
||||||
|
}
|
62
doc/notification_samples/instance-restore-start.json
Normal file
62
doc/notification_samples/instance-restore-start.json
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
{
|
||||||
|
"event_type":"instance.restore.start",
|
||||||
|
"payload":{
|
||||||
|
"nova_object.data":{
|
||||||
|
"architecture":"x86_64",
|
||||||
|
"availability_zone":null,
|
||||||
|
"created_at":"2012-10-29T13:42:11Z",
|
||||||
|
"deleted_at":null,
|
||||||
|
"display_name":"some-server",
|
||||||
|
"fault":null,
|
||||||
|
"host":"compute",
|
||||||
|
"host_name":"some-server",
|
||||||
|
"ip_addresses": [{
|
||||||
|
"nova_object.name": "IpPayload",
|
||||||
|
"nova_object.namespace": "nova",
|
||||||
|
"nova_object.version": "1.0",
|
||||||
|
"nova_object.data": {
|
||||||
|
"mac": "fa:16:3e:4c:2c:30",
|
||||||
|
"address": "192.168.1.3",
|
||||||
|
"port_uuid": "ce531f90-199f-48c0-816c-13e38010b442",
|
||||||
|
"meta": {},
|
||||||
|
"version": 4,
|
||||||
|
"label": "private-network",
|
||||||
|
"device_name": "tapce531f90-19"
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
"kernel_id":"",
|
||||||
|
"launched_at":"2012-10-29T13:42:11Z",
|
||||||
|
"image_uuid": "155d900f-4e14-4e4c-a73d-069cbf4541e6",
|
||||||
|
"metadata":{},
|
||||||
|
"node":"fake-mini",
|
||||||
|
"os_type":null,
|
||||||
|
"progress":0,
|
||||||
|
"ramdisk_id":"",
|
||||||
|
"reservation_id":"r-npxv0e40",
|
||||||
|
"state":"soft-delete",
|
||||||
|
"task_state":"restoring",
|
||||||
|
"power_state":"running",
|
||||||
|
"tenant_id":"6f70656e737461636b20342065766572",
|
||||||
|
"terminated_at":null,
|
||||||
|
"flavor": {
|
||||||
|
"nova_object.name": "FlavorPayload",
|
||||||
|
"nova_object.data": {
|
||||||
|
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||||
|
"root_gb": 1,
|
||||||
|
"vcpus": 1,
|
||||||
|
"ephemeral_gb": 0,
|
||||||
|
"memory_mb": 512
|
||||||
|
},
|
||||||
|
"nova_object.version": "1.0",
|
||||||
|
"nova_object.namespace": "nova"
|
||||||
|
},
|
||||||
|
"user_id":"fake",
|
||||||
|
"uuid":"178b0921-8f85-4257-88b6-2e743b5a975c"
|
||||||
|
},
|
||||||
|
"nova_object.name":"InstanceActionPayload",
|
||||||
|
"nova_object.namespace":"nova",
|
||||||
|
"nova_object.version":"1.0"
|
||||||
|
},
|
||||||
|
"priority":"INFO",
|
||||||
|
"publisher_id":"nova-compute:compute"
|
||||||
|
}
|
@ -2534,6 +2534,9 @@ class ComputeManager(manager.Manager):
|
|||||||
def restore_instance(self, context, instance):
|
def restore_instance(self, context, instance):
|
||||||
"""Restore a soft-deleted instance on this host."""
|
"""Restore a soft-deleted instance on this host."""
|
||||||
self._notify_about_instance_usage(context, instance, "restore.start")
|
self._notify_about_instance_usage(context, instance, "restore.start")
|
||||||
|
compute_utils.notify_about_instance_action(context, instance,
|
||||||
|
self.host, action=fields.NotificationAction.RESTORE,
|
||||||
|
phase=fields.NotificationPhase.START)
|
||||||
try:
|
try:
|
||||||
self.driver.restore(instance)
|
self.driver.restore(instance)
|
||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
@ -2545,6 +2548,9 @@ class ComputeManager(manager.Manager):
|
|||||||
instance.task_state = None
|
instance.task_state = None
|
||||||
instance.save(expected_task_state=task_states.RESTORING)
|
instance.save(expected_task_state=task_states.RESTORING)
|
||||||
self._notify_about_instance_usage(context, instance, "restore.end")
|
self._notify_about_instance_usage(context, instance, "restore.end")
|
||||||
|
compute_utils.notify_about_instance_action(context, instance,
|
||||||
|
self.host, action=fields.NotificationAction.RESTORE,
|
||||||
|
phase=fields.NotificationPhase.END)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _set_migration_status(migration, status):
|
def _set_migration_status(migration, status):
|
||||||
|
@ -247,8 +247,8 @@ class InstanceStateUpdatePayload(base.NotificationPayloadBase):
|
|||||||
@base.notification_sample('instance-shelve-end.json')
|
@base.notification_sample('instance-shelve-end.json')
|
||||||
# @base.notification_sample('instance-resume-start.json')
|
# @base.notification_sample('instance-resume-start.json')
|
||||||
# @base.notification_sample('instance-resume-end.json')
|
# @base.notification_sample('instance-resume-end.json')
|
||||||
# @base.notification_sample('instance-restore-start.json')
|
@base.notification_sample('instance-restore-start.json')
|
||||||
# @base.notification_sample('instance-restore-end.json')
|
@base.notification_sample('instance-restore-end.json')
|
||||||
@nova_base.NovaObjectRegistry.register_notification
|
@nova_base.NovaObjectRegistry.register_notification
|
||||||
class InstanceActionNotification(base.NotificationBase):
|
class InstanceActionNotification(base.NotificationBase):
|
||||||
# Version 1.0: Initial version
|
# Version 1.0: Initial version
|
||||||
|
@ -314,3 +314,28 @@ class TestInstanceNotificationSample(
|
|||||||
notification_sample_base.NotificationSampleTestBase.ANY,
|
notification_sample_base.NotificationSampleTestBase.ANY,
|
||||||
'uuid': server['id']},
|
'uuid': server['id']},
|
||||||
actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
|
actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
|
||||||
|
|
||||||
|
def test_delete_restore_server(self):
|
||||||
|
self.flags(reclaim_instance_interval=30)
|
||||||
|
server = self._boot_a_server(
|
||||||
|
extra_params={'networks': [{'port': self.neutron.port_1['id']}]})
|
||||||
|
self.api.delete_server(server['id'])
|
||||||
|
self._wait_for_state_change(self.api, server, 'SOFT_DELETED')
|
||||||
|
self.api.post_server_action(server['id'], {'restore': {}})
|
||||||
|
self._wait_for_state_change(self.api, server, 'ACTIVE')
|
||||||
|
|
||||||
|
self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS))
|
||||||
|
self._verify_notification(
|
||||||
|
'instance-restore-start',
|
||||||
|
replacements={
|
||||||
|
'reservation_id':
|
||||||
|
notification_sample_base.NotificationSampleTestBase.ANY,
|
||||||
|
'uuid': server['id']},
|
||||||
|
actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
|
||||||
|
self._verify_notification(
|
||||||
|
'instance-restore-end',
|
||||||
|
replacements={
|
||||||
|
'reservation_id':
|
||||||
|
notification_sample_base.NotificationSampleTestBase.ANY,
|
||||||
|
'uuid': server['id']},
|
||||||
|
actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
|
||||||
|
@ -3214,6 +3214,23 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
|||||||
self.assertIsNone(instance.task_state)
|
self.assertIsNone(instance.task_state)
|
||||||
self.assertEqual(vm_states.ACTIVE, instance.vm_state)
|
self.assertEqual(vm_states.ACTIVE, instance.vm_state)
|
||||||
|
|
||||||
|
def test_instance_restore_notification(self):
|
||||||
|
inst_obj = fake_instance.fake_instance_obj(self.context,
|
||||||
|
vm_state=vm_states.SOFT_DELETED)
|
||||||
|
with test.nested(
|
||||||
|
mock.patch.object(nova.compute.utils,
|
||||||
|
'notify_about_instance_action'),
|
||||||
|
mock.patch.object(self.compute, '_notify_about_instance_usage'),
|
||||||
|
mock.patch.object(objects.Instance, 'save'),
|
||||||
|
mock.patch.object(self.compute.driver, 'restore')
|
||||||
|
) as (fake_notify, fake_notify_usage, fake_save, fake_restore):
|
||||||
|
self.compute.restore_instance(self.context, inst_obj)
|
||||||
|
fake_notify.assert_has_calls([
|
||||||
|
mock.call(self.context, inst_obj, 'fake-mini',
|
||||||
|
action='restore', phase='start'),
|
||||||
|
mock.call(self.context, inst_obj, 'fake-mini',
|
||||||
|
action='restore', phase='end')])
|
||||||
|
|
||||||
|
|
||||||
class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase):
|
class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user