Merge "Transform servergroup.delete notification"
This commit is contained in:
commit
c40eb08f64
19
doc/notification_samples/server_group-delete.json
Normal file
19
doc/notification_samples/server_group-delete.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"priority": "INFO",
|
||||
"payload": {
|
||||
"nova_object.version": "1.0",
|
||||
"nova_object.namespace": "nova",
|
||||
"nova_object.name": "ServerGroupPayload",
|
||||
"nova_object.data": {
|
||||
"uuid": "788608ec-ebdc-45c5-bc7f-e5f24ab92c80",
|
||||
"name": "test-server-group",
|
||||
"project_id": "6f70656e737461636b20342065766572",
|
||||
"user_id": "fake",
|
||||
"policies": ["anti-affinity"],
|
||||
"members": [],
|
||||
"hosts": null
|
||||
}
|
||||
},
|
||||
"event_type": "server_group.delete",
|
||||
"publisher_id": "nova-api:fake-mini"
|
||||
}
|
@ -50,6 +50,7 @@ class ServerGroupPayload(base.NotificationPayloadBase):
|
||||
|
||||
|
||||
@base.notification_sample('server_group-create.json')
|
||||
@base.notification_sample('server_group-delete.json')
|
||||
@nova_base.NovaObjectRegistry.register_notification
|
||||
class ServerGroupNotification(base.NotificationBase):
|
||||
# Version 1.0: Initial version
|
||||
|
@ -436,6 +436,10 @@ class InstanceGroup(base.NovaPersistentObject, base.NovaObject,
|
||||
self.obj_reset_changes()
|
||||
compute_utils.notify_about_server_group_update(self._context,
|
||||
"delete", payload)
|
||||
compute_utils.notify_about_server_group_action(
|
||||
context=self._context,
|
||||
group=self,
|
||||
action=fields.NotificationAction.DELETE)
|
||||
|
||||
@base.remotable_classmethod
|
||||
def add_members(cls, context, group_uuid, instance_uuids):
|
||||
|
@ -17,7 +17,7 @@ from nova.tests.unit import fake_notifier
|
||||
class TestServerGroupNotificationSample(
|
||||
notification_sample_base.NotificationSampleTestBase):
|
||||
|
||||
def test_server_group_create(self):
|
||||
def test_server_group_create_delete(self):
|
||||
group_req = {
|
||||
"name": "test-server-group",
|
||||
"policies": ["anti-affinity"]}
|
||||
@ -28,3 +28,12 @@ class TestServerGroupNotificationSample(
|
||||
'server_group-create',
|
||||
replacements={'uuid': group['id']},
|
||||
actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
|
||||
|
||||
fake_notifier.reset()
|
||||
self.api.delete_server_group(group['id'])
|
||||
|
||||
self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
|
||||
self._verify_notification(
|
||||
'server_group-delete',
|
||||
replacements={'uuid': group['id']},
|
||||
actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
|
||||
|
@ -189,12 +189,20 @@ class _TestInstanceGroupObject(object):
|
||||
group=group_matcher,
|
||||
action='create')
|
||||
|
||||
@mock.patch('nova.compute.utils.notify_about_server_group_action')
|
||||
@mock.patch('nova.compute.utils.notify_about_server_group_update')
|
||||
@mock.patch('nova.objects.InstanceGroup._destroy_in_db')
|
||||
def test_destroy(self, mock_db_delete, mock_notify):
|
||||
def test_destroy(self, mock_db_delete, mock_notify, mock_notify_action):
|
||||
obj = objects.InstanceGroup(context=self.context)
|
||||
obj.uuid = _DB_UUID
|
||||
obj.destroy()
|
||||
|
||||
group_matcher = test_utils.CustomMockCallMatcher(
|
||||
lambda group: group.uuid == _DB_UUID)
|
||||
|
||||
mock_notify_action.assert_called_once_with(context=obj._context,
|
||||
group=group_matcher,
|
||||
action='delete')
|
||||
mock_db_delete.assert_called_once_with(self.context, _DB_UUID)
|
||||
mock_notify.assert_called_once_with(self.context, "delete",
|
||||
{'server_group_id': _DB_UUID})
|
||||
|
Loading…
x
Reference in New Issue
Block a user