diff --git a/doc/ext/versioned_notifications.py b/doc/ext/versioned_notifications.py index 7972b8727709..09a7621c8a24 100644 --- a/doc/ext/versioned_notifications.py +++ b/doc/ext/versioned_notifications.py @@ -61,6 +61,10 @@ jQuery(document).ready(function(){ pkgutil.iter_modules(nova.notifications.objects.__path__)))) def _collect_notifications(self): + # If you do not see your notification sample showing up in the docs + # be sure that the sample filename matches what is registered on the + # versioned notification object class using the + # @base.notification_sample decorator. self._import_all_notification_packages() base.NovaObjectRegistry.register_notification_objects() notifications = {} diff --git a/doc/notification_samples/aggregate-cache_images-end.json b/doc/notification_samples/aggregate-cache_images-end.json new file mode 100644 index 000000000000..4c41e0add2f6 --- /dev/null +++ b/doc/notification_samples/aggregate-cache_images-end.json @@ -0,0 +1,11 @@ +{ + "priority": "INFO", + "payload": { + "$ref": "common_payloads/AggregatePayload.json#", + "nova_object.data": { + "hosts": ["compute"] + } + }, + "event_type": "aggregate.cache_images.end", + "publisher_id": "nova-api:fake-mini" +} diff --git a/doc/notification_samples/aggregate-cache_images-start.json b/doc/notification_samples/aggregate-cache_images-start.json new file mode 100644 index 000000000000..98f38c976643 --- /dev/null +++ b/doc/notification_samples/aggregate-cache_images-start.json @@ -0,0 +1,11 @@ +{ + "priority": "INFO", + "payload": { + "$ref": "common_payloads/AggregatePayload.json#", + "nova_object.data": { + "hosts": ["compute"] + } + }, + "event_type": "aggregate.cache_images.start", + "publisher_id": "nova-api:fake-mini" +} diff --git a/nova/conductor/manager.py b/nova/conductor/manager.py index 7531a2eacdd1..6ff940419e72 100644 --- a/nova/conductor/manager.py +++ b/nova/conductor/manager.py @@ -1640,7 +1640,8 @@ class ComputeTaskManager(base.Base): :param image_id: The IDs of the image to cache """ - # TODO(danms): Fix notification sample for IMAGE_CACHE action + # TODO(mriedem): Consider including the list of images in the + # notification payload. compute_utils.notify_about_aggregate_action( context, aggregate, fields.NotificationAction.IMAGE_CACHE, diff --git a/nova/notifications/objects/aggregate.py b/nova/notifications/objects/aggregate.py index 38871dd6805c..fed8a2035786 100644 --- a/nova/notifications/objects/aggregate.py +++ b/nova/notifications/objects/aggregate.py @@ -54,6 +54,8 @@ class AggregatePayload(base.NotificationPayloadBase): @base.notification_sample('aggregate-update_metadata-end.json') @base.notification_sample('aggregate-update_prop-start.json') @base.notification_sample('aggregate-update_prop-end.json') +@base.notification_sample('aggregate-cache_images-start.json') +@base.notification_sample('aggregate-cache_images-end.json') @nova_base.NovaObjectRegistry.register_notification class AggregateNotification(base.NotificationBase): # Version 1.0: Initial version diff --git a/nova/tests/functional/notification_sample_tests/test_aggregate.py b/nova/tests/functional/notification_sample_tests/test_aggregate.py index ca6a701b294e..56823316626b 100644 --- a/nova/tests/functional/notification_sample_tests/test_aggregate.py +++ b/nova/tests/functional/notification_sample_tests/test_aggregate.py @@ -166,3 +166,45 @@ class TestAggregateNotificationSample( 'uuid': aggregate['uuid'], 'id': aggregate['id']}, actual=fake_notifier.VERSIONED_NOTIFICATIONS[3]) + + def test_aggregate_cache_images(self): + aggregate_req = { + "aggregate": { + "name": "my-aggregate", + "availability_zone": "nova"}} + aggregate = self.admin_api.post_aggregate(aggregate_req) + add_host_req = { + "add_host": { + "host": "compute" + } + } + self.admin_api.post_aggregate_action(aggregate['id'], add_host_req) + + fake_notifier.reset() + + cache_images_req = { + 'cache': [ + {'id': '155d900f-4e14-4e4c-a73d-069cbf4541e6'} + ] + } + self.admin_api.api_post('/os-aggregates/%s/images' % aggregate['id'], + cache_images_req) + # Since the operation is asynchronous we have to wait for the end + # notification. + fake_notifier.wait_for_versioned_notifications( + 'aggregate.cache_images.end') + + self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS), + fake_notifier.VERSIONED_NOTIFICATIONS) + self._verify_notification( + 'aggregate-cache_images-start', + replacements={ + 'uuid': aggregate['uuid'], + 'id': aggregate['id']}, + actual=fake_notifier.VERSIONED_NOTIFICATIONS[0]) + self._verify_notification( + 'aggregate-cache_images-end', + replacements={ + 'uuid': aggregate['uuid'], + 'id': aggregate['id']}, + actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])