Transform instance.shelve notifications
Instance.shelve.start and instance.shelve.end notifications are transformed to the new versioned framework. Change-Id: Ibb52f4c9d8ec10810916a6ccb2bb494db7300d05 Implements: bp versioned-notification-transformation-newton
This commit is contained in:
parent
3e96b0fde0
commit
1d0326cce1
62
doc/notification_samples/instance-shelve-end.json
Normal file
62
doc/notification_samples/instance-shelve-end.json
Normal file
@ -0,0 +1,62 @@
|
||||
{
|
||||
"event_type":"instance.shelve.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":"shelved",
|
||||
"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-shelve-start.json
Normal file
62
doc/notification_samples/instance-shelve-start.json
Normal file
@ -0,0 +1,62 @@
|
||||
{
|
||||
"event_type":"instance.shelve.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":"active",
|
||||
"task_state":"shelving",
|
||||
"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"
|
||||
}
|
@ -4138,6 +4138,9 @@ class ComputeManager(manager.Manager):
|
||||
compute_utils.notify_usage_exists(self.notifier, context, instance,
|
||||
current_period=True)
|
||||
self._notify_about_instance_usage(context, instance, 'shelve.start')
|
||||
compute_utils.notify_about_instance_action(context, instance,
|
||||
self.host, action=fields.NotificationAction.SHELVE,
|
||||
phase=fields.NotificationPhase.START)
|
||||
|
||||
def update_task_state(task_state, expected_state=task_states.SHELVING):
|
||||
shelving_state_map = {
|
||||
@ -4167,6 +4170,9 @@ class ComputeManager(manager.Manager):
|
||||
task_states.SHELVING_IMAGE_UPLOADING])
|
||||
|
||||
self._notify_about_instance_usage(context, instance, 'shelve.end')
|
||||
compute_utils.notify_about_instance_action(context, instance,
|
||||
self.host, action=fields.NotificationAction.SHELVE,
|
||||
phase=fields.NotificationPhase.END)
|
||||
|
||||
if CONF.shelved_offload_time == 0:
|
||||
self.shelve_offload_instance(context, instance,
|
||||
|
@ -243,8 +243,8 @@ class InstanceStateUpdatePayload(base.NotificationPayloadBase):
|
||||
# @base.notification_sample('instance-snapshot-end.json')
|
||||
# @base.notification_sample('instance-add_fixed_ip-start.json')
|
||||
# @base.notification_sample('instance-add_fixed_ip-end.json')
|
||||
# @base.notification_sample('instance-shelve-start.json')
|
||||
# @base.notification_sample('instance-shelve-end.json')
|
||||
@base.notification_sample('instance-shelve-start.json')
|
||||
@base.notification_sample('instance-shelve-end.json')
|
||||
# @base.notification_sample('instance-resume-start.json')
|
||||
# @base.notification_sample('instance-resume-end.json')
|
||||
# @base.notification_sample('instance-restore-start.json')
|
||||
|
@ -217,6 +217,32 @@ class TestInstanceNotificationSample(
|
||||
'uuid': server['id']},
|
||||
actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
|
||||
|
||||
def test_create_shelve_server(self):
|
||||
server = self._boot_a_server(
|
||||
extra_params={'networks': [{'port': self.neutron.port_1['id']}]})
|
||||
|
||||
self.flags(shelved_offload_time = -1)
|
||||
|
||||
self.api.post_server_action(server['id'], {'shelve': {}})
|
||||
self._wait_for_state_change(self.api, server,
|
||||
expected_status='SHELVED')
|
||||
|
||||
self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS))
|
||||
self._verify_notification(
|
||||
'instance-shelve-start',
|
||||
replacements={
|
||||
'reservation_id':
|
||||
notification_sample_base.NotificationSampleTestBase.ANY,
|
||||
'uuid': server['id']},
|
||||
actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
|
||||
self._verify_notification(
|
||||
'instance-shelve-end',
|
||||
replacements={
|
||||
'reservation_id':
|
||||
notification_sample_base.NotificationSampleTestBase.ANY,
|
||||
'uuid': server['id']},
|
||||
actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
|
||||
|
||||
|
||||
def test_create_suspend_server(self):
|
||||
server = self._boot_a_server(
|
||||
|
@ -43,7 +43,9 @@ def _fake_resources():
|
||||
|
||||
|
||||
class ShelveComputeManagerTestCase(test_compute.BaseTestCase):
|
||||
def _shelve_instance(self, shelved_offload_time, clean_shutdown=True):
|
||||
@mock.patch('nova.compute.utils.notify_about_instance_action')
|
||||
def _shelve_instance(self, shelved_offload_time,
|
||||
mock_notify, clean_shutdown=True):
|
||||
CONF.set_override('shelved_offload_time', shelved_offload_time)
|
||||
host = 'fake-mini'
|
||||
instance = self._create_fake_instance_obj(params={'host': host})
|
||||
@ -129,6 +131,11 @@ class ShelveComputeManagerTestCase(test_compute.BaseTestCase):
|
||||
mock_save.side_effect = check_save
|
||||
self.compute.shelve_instance(self.context, instance,
|
||||
image_id=image_id, clean_shutdown=clean_shutdown)
|
||||
mock_notify.assert_has_calls([
|
||||
mock.call(self.context, instance, 'fake-mini',
|
||||
action='shelve', phase='start'),
|
||||
mock.call(self.context, instance, 'fake-mini',
|
||||
action='shelve', phase='end')])
|
||||
|
||||
def test_shelve(self):
|
||||
self._shelve_instance(-1)
|
||||
|
Loading…
Reference in New Issue
Block a user