Add action initiator attribute to the instance payload
The instance action notifications contain the user id and the project id of the owner of the instance. However an instance action might be initiated by another user. It could be another user from the same project or can be an admin from the admin project. To be able to distinguish between the user who initiated the instance action from the user owning the instance we need to add two new fields to the instance action notifications, action_initiator_user and action_initiator_project Change-Id: I649d8a27baa8840bc1bb567fef027c749c663432 Closes-bug: #1744658 Blueprint: add-action-initiator-to-instance-action-notifications
This commit is contained in:
parent
9382b78542
commit
2bca6431e6
@ -5,5 +5,5 @@
|
||||
},
|
||||
"nova_object.name":"InstanceActionPayload",
|
||||
"nova_object.namespace":"nova",
|
||||
"nova_object.version":"1.6"
|
||||
"nova_object.version":"1.7"
|
||||
}
|
||||
|
@ -7,5 +7,5 @@
|
||||
]
|
||||
},
|
||||
"nova_object.name": "InstanceActionRebuildPayload",
|
||||
"nova_object.version": "1.7"
|
||||
"nova_object.version": "1.8"
|
||||
}
|
||||
|
@ -4,5 +4,5 @@
|
||||
"rescue_image_ref": "a2459075-d96c-40d5-893e-577ff92e721c"
|
||||
},
|
||||
"nova_object.name": "InstanceActionRescuePayload",
|
||||
"nova_object.version": "1.1"
|
||||
"nova_object.version": "1.2"
|
||||
}
|
||||
|
@ -27,5 +27,5 @@
|
||||
"task_state": "resize_prep"
|
||||
},
|
||||
"nova_object.name": "InstanceActionResizePrepPayload",
|
||||
"nova_object.version": "1.1"
|
||||
"nova_object.version": "1.2"
|
||||
}
|
||||
|
@ -5,5 +5,5 @@
|
||||
},
|
||||
"nova_object.name":"InstanceActionSnapshotPayload",
|
||||
"nova_object.namespace":"nova",
|
||||
"nova_object.version":"1.7"
|
||||
"nova_object.version":"1.8"
|
||||
}
|
||||
|
@ -5,5 +5,5 @@
|
||||
},
|
||||
"nova_object.name": "InstanceActionVolumePayload",
|
||||
"nova_object.namespace": "nova",
|
||||
"nova_object.version": "1.4"
|
||||
"nova_object.version": "1.5"
|
||||
}
|
@ -6,5 +6,5 @@
|
||||
},
|
||||
"nova_object.name": "InstanceActionVolumeSwapPayload",
|
||||
"nova_object.namespace": "nova",
|
||||
"nova_object.version": "1.6"
|
||||
"nova_object.version": "1.7"
|
||||
}
|
||||
|
@ -23,5 +23,5 @@
|
||||
]
|
||||
},
|
||||
"nova_object.name":"InstanceCreatePayload",
|
||||
"nova_object.version": "1.9"
|
||||
"nova_object.version": "1.10"
|
||||
}
|
||||
|
@ -8,5 +8,5 @@
|
||||
},
|
||||
"nova_object.name":"InstanceExistsPayload",
|
||||
"nova_object.namespace":"nova",
|
||||
"nova_object.version":"1.0"
|
||||
"nova_object.version":"1.1"
|
||||
}
|
||||
|
@ -35,9 +35,11 @@
|
||||
"updated_at": "2012-10-29T13:42:11Z",
|
||||
"user_id":"fake",
|
||||
"uuid":"178b0921-8f85-4257-88b6-2e743b5a975c",
|
||||
"request_id": "req-5b6c791d-5709-4f36-8fbe-c3e02869e35d"
|
||||
"request_id": "req-5b6c791d-5709-4f36-8fbe-c3e02869e35d",
|
||||
"action_initiator_user": "fake",
|
||||
"action_initiator_project": "6f70656e737461636b20342065766572"
|
||||
},
|
||||
"nova_object.name":"InstancePayload",
|
||||
"nova_object.namespace":"nova",
|
||||
"nova_object.version":"1.6"
|
||||
"nova_object.version":"1.7"
|
||||
}
|
||||
|
@ -29,5 +29,5 @@
|
||||
},
|
||||
"nova_object.name": "InstanceUpdatePayload",
|
||||
"nova_object.namespace": "nova",
|
||||
"nova_object.version": "1.7"
|
||||
"nova_object.version": "1.8"
|
||||
}
|
@ -6,7 +6,8 @@
|
||||
"host": "host2",
|
||||
"node": "host2",
|
||||
"power_state": "pending",
|
||||
"task_state": "rebuilding"
|
||||
"task_state": "rebuilding",
|
||||
"action_initiator_user": "admin"
|
||||
}
|
||||
},
|
||||
"priority": "INFO",
|
||||
|
@ -3,7 +3,8 @@
|
||||
"payload":{
|
||||
"$ref": "common_payloads/InstanceActionPayload.json#",
|
||||
"nova_object.data":{
|
||||
"task_state": "migrating"
|
||||
"task_state": "migrating",
|
||||
"action_initiator_user": "admin"
|
||||
}
|
||||
},
|
||||
"priority":"INFO",
|
||||
|
@ -3,7 +3,8 @@
|
||||
"payload":{
|
||||
"$ref": "common_payloads/InstanceActionPayload.json#",
|
||||
"nova_object.data":{
|
||||
"task_state": "migrating"
|
||||
"task_state": "migrating",
|
||||
"action_initiator_user": "admin"
|
||||
}
|
||||
},
|
||||
"priority":"INFO",
|
||||
|
@ -5,7 +5,8 @@
|
||||
"nova_object.data":{
|
||||
"host": "host2",
|
||||
"node": "host2",
|
||||
"power_state": "pending"
|
||||
"power_state": "pending",
|
||||
"action_initiator_user": "admin"
|
||||
}
|
||||
},
|
||||
"priority":"INFO",
|
||||
|
@ -3,7 +3,8 @@
|
||||
"payload":{
|
||||
"$ref": "common_payloads/InstanceActionPayload.json#",
|
||||
"nova_object.data":{
|
||||
"task_state": "migrating"
|
||||
"task_state": "migrating",
|
||||
"action_initiator_user": "admin"
|
||||
}
|
||||
},
|
||||
"priority":"INFO",
|
||||
|
@ -3,7 +3,8 @@
|
||||
"payload": {
|
||||
"$ref": "common_payloads/InstanceActionPayload.json#",
|
||||
"nova_object.data": {
|
||||
"task_state": "migrating"
|
||||
"task_state": "migrating",
|
||||
"action_initiator_user": "admin"
|
||||
}
|
||||
},
|
||||
"priority": "INFO",
|
||||
|
@ -3,7 +3,8 @@
|
||||
"payload": {
|
||||
"$ref": "common_payloads/InstanceActionPayload.json#",
|
||||
"nova_object.data": {
|
||||
"task_state": "migrating"
|
||||
"task_state": "migrating",
|
||||
"action_initiator_user": "admin"
|
||||
}
|
||||
},
|
||||
"priority": "INFO",
|
||||
|
@ -1,6 +1,11 @@
|
||||
{
|
||||
"event_type":"instance.live_migration_rollback.end",
|
||||
"payload":{"$ref":"common_payloads/InstanceActionPayload.json#"},
|
||||
"payload":{
|
||||
"$ref":"common_payloads/InstanceActionPayload.json#",
|
||||
"nova_object.data":{
|
||||
"action_initiator_user": "admin"
|
||||
}
|
||||
},
|
||||
"priority":"INFO",
|
||||
"publisher_id":"nova-compute:compute"
|
||||
}
|
||||
|
@ -1,6 +1,11 @@
|
||||
{
|
||||
"event_type":"instance.live_migration_rollback.start",
|
||||
"payload":{"$ref":"common_payloads/InstanceActionPayload.json#"},
|
||||
"payload":{
|
||||
"$ref":"common_payloads/InstanceActionPayload.json#",
|
||||
"nova_object.data":{
|
||||
"action_initiator_user": "admin"
|
||||
}
|
||||
},
|
||||
"priority":"INFO",
|
||||
"publisher_id":"nova-compute:compute"
|
||||
}
|
||||
|
@ -66,7 +66,9 @@ class InstancePayload(base.NotificationPayloadBase):
|
||||
# Version 1.4: Add BDM related data
|
||||
# Version 1.5: Add updated_at field
|
||||
# Version 1.6: Add request_id field
|
||||
VERSION = '1.6'
|
||||
# Version 1.7: Added action_initiator_user and action_initiator_project to
|
||||
# InstancePayload
|
||||
VERSION = '1.7'
|
||||
fields = {
|
||||
'uuid': fields.UUIDField(),
|
||||
'user_id': fields.StringField(nullable=True),
|
||||
@ -109,6 +111,8 @@ class InstancePayload(base.NotificationPayloadBase):
|
||||
'auto_disk_config': fields.DiskConfigField(),
|
||||
|
||||
'request_id': fields.StringField(nullable=True),
|
||||
'action_initiator_user': fields.StringField(nullable=True),
|
||||
'action_initiator_project': fields.StringField(nullable=True),
|
||||
}
|
||||
|
||||
def __init__(self, context, instance, bdms=None):
|
||||
@ -126,7 +130,8 @@ class InstancePayload(base.NotificationPayloadBase):
|
||||
# consistent request_id.
|
||||
self.request_id = context.request_id if (context.project_id and
|
||||
context.user_id) else None
|
||||
|
||||
self.action_initiator_user = context.user_id
|
||||
self.action_initiator_project = context.project_id
|
||||
self.populate_schema(instance=instance)
|
||||
|
||||
|
||||
@ -140,7 +145,9 @@ class InstanceActionPayload(InstancePayload):
|
||||
# Version 1.4: Add BDM related data
|
||||
# Version 1.5: Added updated_at field to InstancePayload
|
||||
# Version 1.6: Added request_id field to InstancePayload
|
||||
VERSION = '1.6'
|
||||
# Version 1.7: Added action_initiator_user and action_initiator_project to
|
||||
# InstancePayload
|
||||
VERSION = '1.7'
|
||||
fields = {
|
||||
'fault': fields.ObjectField('ExceptionPayload', nullable=True),
|
||||
'request_id': fields.StringField(nullable=True),
|
||||
@ -160,8 +167,9 @@ class InstanceActionVolumePayload(InstanceActionPayload):
|
||||
# Version 1.2: Add BDM related data
|
||||
# Version 1.3: Added updated_at field to InstancePayload
|
||||
# Version 1.4: Added request_id field to InstancePayload
|
||||
|
||||
VERSION = '1.4'
|
||||
# Version 1.5: Added action_initiator_user and action_initiator_project to
|
||||
# InstancePayload
|
||||
VERSION = '1.5'
|
||||
fields = {
|
||||
'volume_id': fields.UUIDField()
|
||||
}
|
||||
@ -184,7 +192,9 @@ class InstanceActionVolumeSwapPayload(InstanceActionPayload):
|
||||
# Version 1.4: Add BDM related data
|
||||
# Version 1.5: Added updated_at field to InstancePayload
|
||||
# Version 1.6: Added request_id field to InstancePayload
|
||||
VERSION = '1.6'
|
||||
# Version 1.7: Added action_initiator_user and action_initiator_project to
|
||||
# InstancePayload
|
||||
VERSION = '1.7'
|
||||
fields = {
|
||||
'old_volume_id': fields.UUIDField(),
|
||||
'new_volume_id': fields.UUIDField(),
|
||||
@ -216,7 +226,9 @@ class InstanceCreatePayload(InstanceActionPayload):
|
||||
# 1.8: Added request_id field to InstancePayload
|
||||
# 1.9: Add trusted_image_certificates field to
|
||||
# InstanceCreatePayload
|
||||
VERSION = '1.9'
|
||||
# 1.10: Added action_initiator_user and action_initiator_project to
|
||||
# InstancePayload
|
||||
VERSION = '1.10'
|
||||
|
||||
fields = {
|
||||
'keypairs': fields.ListOfObjectsField('KeypairPayload'),
|
||||
@ -246,7 +258,9 @@ class InstanceActionResizePrepPayload(InstanceActionPayload):
|
||||
|
||||
# Version 1.0: Initial version
|
||||
# Version 1.1: Added request_id field to InstancePayload
|
||||
VERSION = '1.1'
|
||||
# Version 1.2: Added action_initiator_user and action_initiator_project to
|
||||
# InstancePayload
|
||||
VERSION = '1.2'
|
||||
fields = {
|
||||
'new_flavor': fields.ObjectField('FlavorPayload', nullable=True)
|
||||
}
|
||||
@ -269,7 +283,9 @@ class InstanceUpdatePayload(InstancePayload):
|
||||
# Version 1.5: Add BDM related data
|
||||
# Version 1.6: Added updated_at field to InstancePayload
|
||||
# Version 1.7: Added request_id field to InstancePayload
|
||||
VERSION = '1.7'
|
||||
# Version 1.8: Added action_initiator_user and action_initiator_project to
|
||||
# InstancePayload
|
||||
VERSION = '1.8'
|
||||
fields = {
|
||||
'state_update': fields.ObjectField('InstanceStateUpdatePayload'),
|
||||
'audit_period': fields.ObjectField('AuditPeriodPayload'),
|
||||
@ -294,7 +310,9 @@ class InstanceUpdatePayload(InstancePayload):
|
||||
class InstanceActionRescuePayload(InstanceActionPayload):
|
||||
# Version 1.0: Initial version
|
||||
# Version 1.1: Added request_id field to InstancePayload
|
||||
VERSION = '1.1'
|
||||
# Version 1.2: Added action_initiator_user and action_initiator_project to
|
||||
# InstancePayload
|
||||
VERSION = '1.2'
|
||||
fields = {
|
||||
'rescue_image_ref': fields.UUIDField(nullable=True)
|
||||
}
|
||||
@ -316,7 +334,9 @@ class InstanceActionRebuildPayload(InstanceActionPayload):
|
||||
# when this specific payload is created so that the
|
||||
# instance.rebuild.* notifications using this new payload
|
||||
# signal the change of nova_object.name.
|
||||
VERSION = '1.7'
|
||||
# Version 1.8: Added action_initiator_user and action_initiator_project to
|
||||
# InstancePayload
|
||||
VERSION = '1.8'
|
||||
fields = {
|
||||
'trusted_image_certificates': fields.ListOfStringsField(
|
||||
nullable=True)
|
||||
@ -661,7 +681,9 @@ class InstanceActionSnapshotPayload(InstanceActionPayload):
|
||||
# also it added a new field so we wanted to keep the version
|
||||
# number increasing to signal the change.
|
||||
# Version 1.7: Added request_id field to InstancePayload
|
||||
VERSION = '1.7'
|
||||
# Version 1.8: Added action_initiator_user and action_initiator_project to
|
||||
# InstancePayload
|
||||
VERSION = '1.8'
|
||||
fields = {
|
||||
'snapshot_image_id': fields.UUIDField(),
|
||||
}
|
||||
@ -677,7 +699,9 @@ class InstanceActionSnapshotPayload(InstanceActionPayload):
|
||||
@nova_base.NovaObjectRegistry.register_notification
|
||||
class InstanceExistsPayload(InstancePayload):
|
||||
# Version 1.0: Initial version
|
||||
VERSION = '1.0'
|
||||
# Version 1.1: Added action_initiator_user and action_initiator_project to
|
||||
# InstancePayload
|
||||
VERSION = '1.1'
|
||||
fields = {
|
||||
'audit_period': fields.ObjectField('AuditPeriodPayload'),
|
||||
'bandwidth': fields.ListOfObjectsField('BandwidthPayload'),
|
||||
|
@ -375,31 +375,31 @@ notification_object_data = {
|
||||
'FlavorNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
|
||||
'FlavorPayload': '1.4-2e7011b8b4e59167fe8b7a0a81f0d452',
|
||||
'InstanceActionNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
|
||||
'InstanceActionPayload': '1.6-e9e4cbb94e07d3bcaa22743f41e094c8',
|
||||
'InstanceActionPayload': '1.7-8c77f0c85a83d325fded152376ca809a',
|
||||
'InstanceActionRebuildNotification':
|
||||
'1.0-a73147b93b520ff0061865849d3dfa56',
|
||||
'InstanceActionRebuildPayload': '1.7-db0d6d549a7932428cdc0c7ca78859b5',
|
||||
'InstanceActionRebuildPayload': '1.8-ab76ecbf73b82bc010ab82bdc2792e1d',
|
||||
'InstanceActionRescueNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
|
||||
'InstanceActionRescuePayload': '1.1-99b9b25574b77abf6d3e5a0cea341b06',
|
||||
'InstanceActionRescuePayload': '1.2-b82aa24a966713dce26de3126716e8ef',
|
||||
'InstanceActionResizePrepNotification':
|
||||
'1.0-a73147b93b520ff0061865849d3dfa56',
|
||||
'InstanceActionResizePrepPayload': '1.1-9dd5cd4124c660a86e3f00a2df222b8e',
|
||||
'InstanceActionResizePrepPayload': '1.2-1b41bec00f2b679e77a906b1df0c1d5a',
|
||||
'InstanceActionVolumeNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
|
||||
'InstanceActionVolumePayload': '1.4-83fcb4c12327da998116844ef4a16235',
|
||||
'InstanceActionVolumePayload': '1.5-3027aae42ee85155b2c378fad1f3b678',
|
||||
'InstanceActionVolumeSwapNotification':
|
||||
'1.0-a73147b93b520ff0061865849d3dfa56',
|
||||
'InstanceActionVolumeSwapPayload': '1.6-bb322fd649d3626c7a83d5f2d9a866d4',
|
||||
'InstanceActionVolumeSwapPayload': '1.7-d3252403a9437bcdc80f1075214f8b45',
|
||||
'InstanceCreateNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
|
||||
'InstanceCreatePayload': '1.9-1c9f722bf51ddae910fb7e50fff8edd1',
|
||||
'InstancePayload': '1.6-b1e7818c7adf158e8a6e87e0944b0b21',
|
||||
'InstanceCreatePayload': '1.10-291b44932569b8ff864d911814293cfc',
|
||||
'InstancePayload': '1.7-78354572f699b9a6ad9996b199d03375',
|
||||
'InstanceActionSnapshotNotification':
|
||||
'1.0-a73147b93b520ff0061865849d3dfa56',
|
||||
'InstanceActionSnapshotPayload': '1.7-73f96d93ca47750bb6a45e4ab1d268fd',
|
||||
'InstanceActionSnapshotPayload': '1.8-6a3a66f823b56268ea4b759c83e38c31',
|
||||
'InstanceExistsNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
|
||||
'InstanceExistsPayload': '1.0-9b0c1232136e6c850647dfabb63cff07',
|
||||
'InstanceExistsPayload': '1.1-b7095abb18f5b75f39dc1aa59942535d',
|
||||
'InstanceStateUpdatePayload': '1.0-07e111c0fa0f6db0f79b0726d593e3da',
|
||||
'InstanceUpdateNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
|
||||
'InstanceUpdatePayload': '1.7-d48dd2cf8310c8f250dfeb65fd9df97a',
|
||||
'InstanceUpdatePayload': '1.8-375131acb12e612a460f68211a2b3a35',
|
||||
'IpPayload': '1.0-8ecf567a99e516d4af094439a7632d34',
|
||||
'KeypairNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
|
||||
'KeypairPayload': '1.0-6daebbbde0e1bf35c1556b1ecd9385c1',
|
||||
|
@ -465,6 +465,21 @@ class NotificationsTestCase(test.TestCase):
|
||||
fake_notifier.VERSIONED_NOTIFICATIONS[0]
|
||||
['payload']['nova_object.data']['tags'])
|
||||
|
||||
def test_send_versioned_action_initiator_update(self):
|
||||
notifications.send_update(self.context, self.instance, self.instance)
|
||||
action_initiator_user = self.context.user_id
|
||||
action_initiator_project = self.context.project_id
|
||||
self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
|
||||
|
||||
self.assertEqual(action_initiator_user,
|
||||
fake_notifier.VERSIONED_NOTIFICATIONS[0]
|
||||
['payload']['nova_object.data']
|
||||
['action_initiator_user'])
|
||||
self.assertEqual(action_initiator_project,
|
||||
fake_notifier.VERSIONED_NOTIFICATIONS[0]
|
||||
['payload']['nova_object.data']
|
||||
['action_initiator_project'])
|
||||
|
||||
def test_send_no_state_change(self):
|
||||
called = [False]
|
||||
|
||||
|
@ -0,0 +1,8 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Instance action versioned notifications now contain
|
||||
``action_initiator_user`` and ``action_initiator_project``
|
||||
fields to distinguish between the owner of the instance and
|
||||
who initiated the action upon the instance, for example an
|
||||
administrator or another user within the same project.
|
Loading…
x
Reference in New Issue
Block a user