diff --git a/doc/notification_samples/aggregate-add_host-end.json b/doc/notification_samples/aggregate-add_host-end.json new file mode 100644 index 000000000..ae1676960 --- /dev/null +++ b/doc/notification_samples/aggregate-add_host-end.json @@ -0,0 +1,19 @@ +{ + "priority": "INFO", + "payload": { + "nova_object.version": "1.1", + "nova_object.namespace": "nova", + "nova_object.name": "AggregatePayload", + "nova_object.data": { + "name": "my-aggregate", + "metadata": { + "availability_zone": "nova" + }, + "hosts": ["compute"], + "id": 1, + "uuid": "788608ec-ebdc-45c5-bc7f-e5f24ab92c80" + } + }, + "event_type": "aggregate.add_host.end", + "publisher_id": "nova-api:fake-mini" +} diff --git a/doc/notification_samples/aggregate-add_host-start.json b/doc/notification_samples/aggregate-add_host-start.json new file mode 100644 index 000000000..4e82af3d7 --- /dev/null +++ b/doc/notification_samples/aggregate-add_host-start.json @@ -0,0 +1,19 @@ +{ + "priority": "INFO", + "payload": { + "nova_object.version": "1.1", + "nova_object.namespace": "nova", + "nova_object.name": "AggregatePayload", + "nova_object.data": { + "name": "my-aggregate", + "metadata": { + "availability_zone": "nova" + }, + "hosts": [], + "id": 1, + "uuid": "788608ec-ebdc-45c5-bc7f-e5f24ab92c80" + } + }, + "event_type": "aggregate.add_host.start", + "publisher_id": "nova-api:fake-mini" +} diff --git a/nova/notifications/objects/aggregate.py b/nova/notifications/objects/aggregate.py index d94516090..a71a63503 100644 --- a/nova/notifications/objects/aggregate.py +++ b/nova/notifications/objects/aggregate.py @@ -46,6 +46,8 @@ class AggregatePayload(base.NotificationPayloadBase): @base.notification_sample('aggregate-create-end.json') @base.notification_sample('aggregate-delete-start.json') @base.notification_sample('aggregate-delete-end.json') +@base.notification_sample('aggregate-add_host-start.json') +@base.notification_sample('aggregate-add_host-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 0d376fb48..5f045642a 100644 --- a/nova/tests/functional/notification_sample_tests/test_aggregate.py +++ b/nova/tests/functional/notification_sample_tests/test_aggregate.py @@ -52,3 +52,33 @@ class TestAggregateNotificationSample( 'uuid': aggregate['uuid'], 'id': aggregate['id']}, actual=fake_notifier.VERSIONED_NOTIFICATIONS[3]) + + def test_aggregate_add_host(self): + aggregate_req = { + "aggregate": { + "name": "my-aggregate", + "availability_zone": "nova"}} + aggregate = self.admin_api.post_aggregate(aggregate_req) + + fake_notifier.reset() + + add_host_req = { + "add_host": { + "host": "compute" + } + } + self.admin_api.post_aggregate_action(aggregate['id'], add_host_req) + + self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS)) + self._verify_notification( + 'aggregate-add_host-start', + replacements={ + 'uuid': aggregate['uuid'], + 'id': aggregate['id']}, + actual=fake_notifier.VERSIONED_NOTIFICATIONS[0]) + self._verify_notification( + 'aggregate-add_host-end', + replacements={ + 'uuid': aggregate['uuid'], + 'id': aggregate['id']}, + actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])