Transform instance.finish_resize notifications

The instance.finish_resize.start and instance.finish_resize.end
notifications are transformed to the versioned framework.

Change-Id: I2ca79040a91368212fdf50593ef012a669a4a12a
Implements: bp versioned-notification-transformation-ocata
This commit is contained in:
Julian Sy 2016-10-19 15:51:45 +00:00 committed by Matt Riedemann
parent e9a20fdfb9
commit 4f75a50682
6 changed files with 169 additions and 16 deletions

View File

@ -0,0 +1,62 @@
{
"event_type":"instance.resize_finish.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":"resized",
"task_state":null,
"power_state":"running",
"tenant_id":"6f70656e737461636b20342065766572",
"terminated_at":null,
"flavor": {
"nova_object.name": "FlavorPayload",
"nova_object.data": {
"flavorid": "d5a8bb54-365a-45ae-abdb-38d249df7845",
"root_gb": 1,
"vcpus": 1,
"ephemeral_gb": 0,
"memory_mb": 256
},
"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"
}

View File

@ -0,0 +1,62 @@
{
"event_type":"instance.resize_finish.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":"resize_finish",
"power_state":"running",
"tenant_id":"6f70656e737461636b20342065766572",
"terminated_at":null,
"flavor": {
"nova_object.name": "FlavorPayload",
"nova_object.data": {
"flavorid": "d5a8bb54-365a-45ae-abdb-38d249df7845",
"root_gb": 1,
"vcpus": 1,
"ephemeral_gb": 0,
"memory_mb": 256
},
"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"
}

View File

@ -3907,6 +3907,9 @@ class ComputeManager(manager.Manager):
self._notify_about_instance_usage(
context, instance, "finish_resize.start",
network_info=network_info)
compute_utils.notify_about_instance_action(context, instance,
self.host, action=fields.NotificationAction.RESIZE_FINISH,
phase=fields.NotificationPhase.START)
block_device_info = self._get_instance_block_device_info(
context, instance, refresh_conn_info=True)
@ -3940,6 +3943,9 @@ class ComputeManager(manager.Manager):
self._notify_about_instance_usage(
context, instance, "finish_resize.end",
network_info=network_info)
compute_utils.notify_about_instance_action(context, instance,
self.host, action=fields.NotificationAction.RESIZE_FINISH,
phase=fields.NotificationPhase.END)
@wrap_exception()
@reverts_task_state

View File

@ -272,8 +272,8 @@ class InstanceStateUpdatePayload(base.NotificationPayloadBase):
@base.notification_sample('instance-restore-start.json')
@base.notification_sample('instance-restore-end.json')
# @base.notification_sample('instance-evacuate.json')
# @base.notification_sample('instance-resize_finish-start.json')
# @base.notification_sample('instance-resize_finish-end.json')
@base.notification_sample('instance-resize_finish-start.json')
@base.notification_sample('instance-resize_finish-end.json')
# @base.notification_sample('instance-live_migration_pre-start.json')
# @base.notification_sample('instance-live_migration_pre-end.json')
# @base.notification_sample('instance-live_migration_abort-start.json')

View File

@ -451,23 +451,40 @@ class TestInstanceNotificationSample(
def _test_resize_server(self, server):
self.flags(allow_resize_to_same_host=True)
post = {'resize': {'flavorRef': '2'}}
other_flavor_body = {
'flavor': {
'name': 'other_flavor',
'ram': 256,
'vcpus': 1,
'disk': 1,
'id': 'd5a8bb54-365a-45ae-abdb-38d249df7845'
}
}
other_flavor_id = self.api.post_flavor(other_flavor_body)['id']
post = {
'resize': {
'flavorRef': other_flavor_id
}
}
self.api.post_server_action(server['id'], post)
self._wait_for_state_change(self.api, server, 'VERIFY_RESIZE')
self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS))
self._verify_notification(
self.assertEqual(4, len(fake_notifier.VERSIONED_NOTIFICATIONS))
# This list needs to be in order.
expected_notifications = [
'instance-resize-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
self._verify_notification(
'instance-resize-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
'instance-resize_finish-start',
'instance-resize_finish-end'
]
for idx, notification in enumerate(expected_notifications):
self._verify_notification(
notification,
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
actual=fake_notifier.VERSIONED_NOTIFICATIONS[idx])
post = {'revertResize': None}
self.api.post_server_action(server['id'], post)

View File

@ -4450,14 +4450,15 @@ class ComputeTestCase(BaseTestCase):
mock.patch.object(self.compute.network_api,
'get_instance_nw_info'),
mock.patch.object(self.compute, '_notify_about_instance_usage'),
mock.patch.object(compute_utils, 'notify_about_instance_action'),
mock.patch.object(self.compute.driver, 'finish_migration'),
mock.patch.object(self.compute, '_get_instance_block_device_info'),
mock.patch.object(migration, 'save'),
mock.patch.object(instance, 'save'),
mock.patch.object(nova.quota.QUOTAS, 'commit')
) as (mock_setup, mock_net_mig, mock_get_nw, mock_notify,
mock_virt_mig, mock_get_blk, mock_mig_save, mock_inst_save,
mock_commit):
mock_notify_action, mock_virt_mig, mock_get_blk, mock_mig_save,
mock_inst_save, mock_commit):
def _mig_save():
self.assertEqual(migration.status, 'finished')
self.assertEqual(vm_state, instance.vm_state)
@ -4516,6 +4517,11 @@ class ComputeTestCase(BaseTestCase):
network_info='fake-nwinfo1'),
mock.call(self.context, instance, 'finish_resize.end',
network_info='fake-nwinfo1')])
mock_notify_action.assert_has_calls([
mock.call(self.context, instance, 'fake-mini',
action='resize_finish', phase='start'),
mock.call(self.context, instance, 'fake-mini',
action='resize_finish', phase='end')])
# nova.conf sets the default flavor to m1.small and the test
# sets the default flavor to m1.tiny so they should be different
# which makes this a resize