Transform instance.reboot notifications
instance.reboot notifications is transformed to the new versioned framework. Co-Authored-By: Gábor Antal <antal@inf.u-szeged.hu> Change-Id: Ie58365b9fea9e6d061cbcf1b59e61e276e3ff775 Implements: bp versioned-notification-transformation-pike
This commit is contained in:
committed by
Gábor Antal
parent
edf51119fa
commit
391a0483e0
@@ -0,0 +1,74 @@
|
||||
{
|
||||
"event_type":"instance.reboot.end",
|
||||
"payload":{
|
||||
"nova_object.data":{
|
||||
"architecture":null,
|
||||
"availability_zone":null,
|
||||
"created_at":"2012-10-29T13:42:11Z",
|
||||
"deleted_at":null,
|
||||
"display_name":"some-server",
|
||||
"display_description":"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": "a2459075-d96c-40d5-893e-577ff92e721c",
|
||||
"metadata":{},
|
||||
"locked":false,
|
||||
"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",
|
||||
"name": "test_flavor",
|
||||
"projects": null,
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"extra_specs": {
|
||||
"hw:watchdog_action": "disabled"
|
||||
},
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.3",
|
||||
"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.1"
|
||||
},
|
||||
"priority":"INFO",
|
||||
"publisher_id":"nova-compute:compute"
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
{
|
||||
"event_type":"instance.reboot.start",
|
||||
"payload":{
|
||||
"nova_object.data":{
|
||||
"architecture":null,
|
||||
"availability_zone":null,
|
||||
"created_at":"2012-10-29T13:42:11Z",
|
||||
"deleted_at":null,
|
||||
"display_name":"some-server",
|
||||
"display_description":"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": "a2459075-d96c-40d5-893e-577ff92e721c",
|
||||
"metadata":{},
|
||||
"locked":false,
|
||||
"node":"fake-mini",
|
||||
"os_type":null,
|
||||
"progress":0,
|
||||
"ramdisk_id":"",
|
||||
"reservation_id":"r-npxv0e40",
|
||||
"state":"active",
|
||||
"task_state":"reboot_pending_hard",
|
||||
"power_state":"running",
|
||||
"tenant_id":"6f70656e737461636b20342065766572",
|
||||
"terminated_at":null,
|
||||
"flavor": {
|
||||
"nova_object.name": "FlavorPayload",
|
||||
"nova_object.data": {
|
||||
"flavorid": "a22d5517-147c-4147-a0d1-e698df5cd4e3",
|
||||
"name": "test_flavor",
|
||||
"projects": null,
|
||||
"root_gb": 1,
|
||||
"vcpus": 1,
|
||||
"ephemeral_gb": 0,
|
||||
"memory_mb": 512,
|
||||
"disabled": false,
|
||||
"rxtx_factor": 1.0,
|
||||
"extra_specs": {
|
||||
"hw:watchdog_action": "disabled"
|
||||
},
|
||||
"swap": 0,
|
||||
"is_public": true,
|
||||
"vcpu_weight": 0
|
||||
},
|
||||
"nova_object.version": "1.3",
|
||||
"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.1"
|
||||
},
|
||||
"priority":"INFO",
|
||||
"publisher_id":"nova-compute:compute"
|
||||
}
|
||||
@@ -2990,6 +2990,11 @@ class ComputeManager(manager.Manager):
|
||||
network_info = self.network_api.get_instance_nw_info(context, instance)
|
||||
|
||||
self._notify_about_instance_usage(context, instance, "reboot.start")
|
||||
compute_utils.notify_about_instance_action(
|
||||
context, instance, self.host,
|
||||
action=fields.NotificationAction.REBOOT,
|
||||
phase=fields.NotificationPhase.START
|
||||
)
|
||||
|
||||
instance.power_state = self._get_power_state(context, instance)
|
||||
instance.save(expected_task_state=expected_states)
|
||||
@@ -3057,6 +3062,11 @@ class ComputeManager(manager.Manager):
|
||||
instance=instance)
|
||||
|
||||
self._notify_about_instance_usage(context, instance, "reboot.end")
|
||||
compute_utils.notify_about_instance_action(
|
||||
context, instance, self.host,
|
||||
action=fields.NotificationAction.REBOOT,
|
||||
phase=fields.NotificationPhase.END
|
||||
)
|
||||
|
||||
@delete_image_on_error
|
||||
def _do_snapshot_instance(self, context, image_id, instance):
|
||||
|
||||
@@ -239,8 +239,8 @@ class InstanceStateUpdatePayload(base.NotificationPayloadBase):
|
||||
@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')
|
||||
# @base.notification_sample('instance-reboot-end.json')
|
||||
@base.notification_sample('instance-reboot-start.json')
|
||||
@base.notification_sample('instance-reboot-end.json')
|
||||
@base.notification_sample('instance-shutdown-start.json')
|
||||
@base.notification_sample('instance-shutdown-end.json')
|
||||
@base.notification_sample('instance-snapshot-start.json')
|
||||
|
||||
@@ -76,6 +76,7 @@ class TestInstanceNotificationSample(
|
||||
self._test_resize_server,
|
||||
self._test_snapshot_server,
|
||||
self._test_rebuild_server,
|
||||
self._test_reboot_server,
|
||||
]
|
||||
|
||||
for action in actions:
|
||||
@@ -626,6 +627,26 @@ class TestInstanceNotificationSample(
|
||||
|
||||
self.flags(reclaim_instance_interval=0)
|
||||
|
||||
def _test_reboot_server(self, server):
|
||||
post = {'reboot': {'type': 'HARD'}}
|
||||
self.api.post_server_action(server['id'], post)
|
||||
self._wait_for_notification('instance.reboot.start')
|
||||
self._wait_for_notification('instance.reboot.end')
|
||||
|
||||
self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS))
|
||||
self._verify_notification(
|
||||
'instance-reboot-start',
|
||||
replacements={
|
||||
'reservation_id': server['reservation_id'],
|
||||
'uuid': server['id']},
|
||||
actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
|
||||
self._verify_notification(
|
||||
'instance-reboot-end',
|
||||
replacements={
|
||||
'reservation_id': server['reservation_id'],
|
||||
'uuid': server['id']},
|
||||
actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
|
||||
|
||||
def _attach_volume_to_server(self, server, volume_id):
|
||||
self.api.post_server_volume(
|
||||
server['id'], {"volumeAttachment": {"volumeId": volume_id}})
|
||||
|
||||
@@ -2852,10 +2852,12 @@ class ComputeTestCase(BaseTestCase):
|
||||
@mock.patch.object(compute_manager.ComputeManager, '_instance_update')
|
||||
@mock.patch.object(db, 'instance_update_and_get_original')
|
||||
@mock.patch.object(compute_manager.ComputeManager, '_get_power_state')
|
||||
def _test_reboot(self, soft, mock_get_power, mock_get_orig,
|
||||
mock_update, mock_notify, mock_get_blk,
|
||||
test_delete=False, test_unrescue=False,
|
||||
fail_reboot=False, fail_running=False):
|
||||
@mock.patch('nova.compute.utils.notify_about_instance_action')
|
||||
def _test_reboot(self, soft, mock_notify_action, mock_get_power,
|
||||
mock_get_orig, mock_update, mock_notify_usage,
|
||||
mock_get_blk, test_delete=False,
|
||||
test_unrescue=False, fail_reboot=False,
|
||||
fail_running=False):
|
||||
reboot_type = soft and 'SOFT' or 'HARD'
|
||||
task_pending = (soft and task_states.REBOOT_PENDING
|
||||
or task_states.REBOOT_PENDING_HARD)
|
||||
@@ -2927,6 +2929,10 @@ class ComputeTestCase(BaseTestCase):
|
||||
mock_get_orig.side_effect = [(None, updated_dbinstance1),
|
||||
(None, updated_dbinstance1)]
|
||||
notify_call_list = [mock.call(econtext, instance, 'reboot.start')]
|
||||
notify_action_call_list = [
|
||||
mock.call(econtext, instance, 'fake-mini', action='reboot',
|
||||
phase='start')]
|
||||
|
||||
ps_call_list = [mock.call(econtext, instance)]
|
||||
db_call_list = [mock.call(econtext, instance['uuid'],
|
||||
{'task_state': task_pending,
|
||||
@@ -2990,6 +2996,9 @@ class ComputeTestCase(BaseTestCase):
|
||||
columns_to_join=['system_metadata']))
|
||||
notify_call_list.append(mock.call(econtext, instance,
|
||||
'reboot.end'))
|
||||
notify_action_call_list.append(
|
||||
mock.call(econtext, instance, 'fake-mini',
|
||||
action='reboot', phase='end'))
|
||||
elif fail_reboot and not fail_running:
|
||||
mock_get_orig.side_effect = chain(mock_get_orig.side_effect,
|
||||
[fault])
|
||||
@@ -3011,6 +3020,9 @@ class ComputeTestCase(BaseTestCase):
|
||||
'reboot.error', fault=fault))
|
||||
notify_call_list.append(mock.call(econtext, instance,
|
||||
'reboot.end'))
|
||||
notify_action_call_list.append(
|
||||
mock.call(econtext, instance, 'fake-mini',
|
||||
action='reboot', phase='end'))
|
||||
|
||||
if not fail_reboot or fail_running:
|
||||
self.compute.reboot_instance(self.context, instance=instance,
|
||||
@@ -3026,7 +3038,8 @@ class ComputeTestCase(BaseTestCase):
|
||||
self.assertEqual(expected_call_info, reboot_call_info)
|
||||
mock_get_blk.assert_called_once_with(econtext, instance)
|
||||
mock_get_nw.assert_called_once_with(econtext, instance)
|
||||
mock_notify.assert_has_calls(notify_call_list)
|
||||
mock_notify_usage.assert_has_calls(notify_call_list)
|
||||
mock_notify_action.assert_has_calls(notify_action_call_list)
|
||||
mock_get_power.assert_has_calls(ps_call_list)
|
||||
mock_get_orig.assert_has_calls(db_call_list)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user