Transform instance.power_on notifications
The instance.power_on.start and instance.power_on.end notifications are transformed to the versioned framework. Change-Id: I4e4fd701a59064b89e38b50dcc01c9d8846a09b0 Implements: bp versioned-notification-transformation-newton
This commit is contained in:
parent
4e62960722
commit
2a99eb1f3a
62
doc/notification_samples/instance-power_on-end.json
Normal file
62
doc/notification_samples/instance-power_on-end.json
Normal file
@ -0,0 +1,62 @@
|
||||
{
|
||||
"event_type":"instance.power_on.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-power_on-start.json
Normal file
62
doc/notification_samples/instance-power_on-start.json
Normal file
@ -0,0 +1,62 @@
|
||||
{
|
||||
"event_type":"instance.power_on.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":"stopped",
|
||||
"task_state":"powering-on",
|
||||
"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"
|
||||
}
|
@ -2456,6 +2456,9 @@ class ComputeManager(manager.Manager):
|
||||
def start_instance(self, context, instance):
|
||||
"""Starting an instance on this host."""
|
||||
self._notify_about_instance_usage(context, instance, "power_on.start")
|
||||
compute_utils.notify_about_instance_action(context, instance,
|
||||
self.host, action=fields.NotificationAction.POWER_ON,
|
||||
phase=fields.NotificationPhase.START)
|
||||
self._power_on(context, instance)
|
||||
instance.power_state = self._get_power_state(context, instance)
|
||||
instance.vm_state = vm_states.ACTIVE
|
||||
@ -2472,6 +2475,9 @@ class ComputeManager(manager.Manager):
|
||||
|
||||
instance.save(expected_task_state=task_states.POWERING_ON)
|
||||
self._notify_about_instance_usage(context, instance, "power_on.end")
|
||||
compute_utils.notify_about_instance_action(context, instance,
|
||||
self.host, action=fields.NotificationAction.POWER_ON,
|
||||
phase=fields.NotificationPhase.END)
|
||||
|
||||
@messaging.expected_exceptions(NotImplementedError,
|
||||
exception.TriggerCrashDumpNotSupported,
|
||||
|
@ -231,8 +231,8 @@ class InstanceStateUpdatePayload(base.NotificationPayloadBase):
|
||||
# @base.notification_sample('instance-resize-end.json')
|
||||
# @base.notification_sample('instance-suspend-start.json')
|
||||
# @base.notification_sample('instance-suspend-end.json')
|
||||
# @base.notification_sample('instance-power_on-start.json')
|
||||
# @base.notification_sample('instance-power_on-end.json')
|
||||
@base.notification_sample('instance-power_on-start.json')
|
||||
@base.notification_sample('instance-power_on-end.json')
|
||||
# @base.notification_sample('instance-power_off-start.json')
|
||||
# @base.notification_sample('instance-power_off-end.json')
|
||||
# @base.notification_sample('instance-reboot-start.json')
|
||||
|
@ -190,3 +190,29 @@ class TestInstanceNotificationSample(
|
||||
|
||||
self._verify_instance_update_steps(delete_steps, instance_updates,
|
||||
initial=replacements)
|
||||
|
||||
def test_create_poweron_server(self):
|
||||
server = self._boot_a_server(
|
||||
extra_params={'networks': [{'port': self.neutron.port_1['id']}]})
|
||||
self.api.post_server_action(server['id'], {'os-stop': {}})
|
||||
self._wait_for_state_change(self.api, server,
|
||||
expected_status='SHUTOFF')
|
||||
self.api.post_server_action(server['id'], {'os-start': {}})
|
||||
self._wait_for_state_change(self.api, server,
|
||||
expected_status='ACTIVE')
|
||||
|
||||
self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS))
|
||||
self._verify_notification(
|
||||
'instance-power_on-start',
|
||||
replacements={
|
||||
'reservation_id':
|
||||
notification_sample_base.NotificationSampleTestBase.ANY,
|
||||
'uuid': server['id']},
|
||||
actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
|
||||
self._verify_notification(
|
||||
'instance-power_on-end',
|
||||
replacements={
|
||||
'reservation_id':
|
||||
notification_sample_base.NotificationSampleTestBase.ANY,
|
||||
'uuid': server['id']},
|
||||
actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
|
||||
|
@ -1984,7 +1984,8 @@ class ComputeTestCase(BaseTestCase):
|
||||
clean_shutdown=True)
|
||||
self.compute.terminate_instance(self.context, instance, [], [])
|
||||
|
||||
def test_start(self):
|
||||
@mock.patch('nova.compute.utils.notify_about_instance_action')
|
||||
def test_start(self, mock_notify):
|
||||
# Ensure instance can be started.
|
||||
instance = self._create_fake_instance_obj()
|
||||
self.compute.build_and_run_instance(self.context, instance, {}, {}, {},
|
||||
@ -2001,7 +2002,11 @@ class ComputeTestCase(BaseTestCase):
|
||||
inst_obj.task_state = task_states.POWERING_ON
|
||||
inst_obj.save()
|
||||
self.compute.start_instance(self.context, instance=inst_obj)
|
||||
|
||||
mock_notify.assert_has_calls([
|
||||
mock.call(self.context, inst_obj, 'fake-mini', action='power_on',
|
||||
phase='start'),
|
||||
mock.call(self.context, inst_obj, 'fake-mini', action='power_on',
|
||||
phase='end')])
|
||||
self.compute.terminate_instance(self.context, instance, [], [])
|
||||
|
||||
def test_start_shelved_instance(self):
|
||||
|
Loading…
Reference in New Issue
Block a user