Use user id instead of user name in notification body

Change-Id: I65186c637a1fc8b4c2f28e079e761d6a3994defd
Closes-Bug: #1518400
This commit is contained in:
Pratik Mallya 2015-11-20 11:26:52 -06:00
parent 887e5da00f
commit 31537eefe3
3 changed files with 16 additions and 2 deletions

View File

@ -380,6 +380,10 @@ def format_notification_body(stack):
result = {
rpc_api.NOTIFY_TENANT_ID: stack.context.tenant_id,
rpc_api.NOTIFY_USER_ID: stack.context.user,
# deprecated: please use rpc_api.NOTIFY_USERID for user id or
# rpc_api.NOTIFY_USERNAME for user name.
rpc_api.NOTIFY_USERID: stack.context.user_id,
rpc_api.NOTIFY_USERNAME: stack.context.user,
rpc_api.NOTIFY_STACK_ID: stack.id,
rpc_api.NOTIFY_STACK_NAME: stack.name,
rpc_api.NOTIFY_STATE: state,

View File

@ -100,6 +100,8 @@ EVENT_KEYS = (
NOTIFY_KEYS = (
NOTIFY_TENANT_ID,
NOTIFY_USER_ID,
NOTIFY_USERID,
NOTIFY_USERNAME,
NOTIFY_STACK_ID,
NOTIFY_STACK_NAME,
NOTIFY_STATE,
@ -108,6 +110,8 @@ NOTIFY_KEYS = (
) = (
'tenant_id',
'user_id',
'user_identity',
'username',
STACK_ID,
STACK_NAME,
'state',

View File

@ -23,7 +23,7 @@ class StackTest(common.HeatTestCase):
def setUp(self):
super(StackTest, self).setUp()
self.ctx = utils.dummy_context()
self.ctx = utils.dummy_context(user_id='test_user_id')
def test_send(self):
created_time = timeutils.utcnow()
@ -44,6 +44,8 @@ class StackTest(common.HeatTestCase):
self.ctx, 'stack.f.error', 'ERROR',
{'state_reason': 'this is why',
'user_id': 'test_username',
'username': 'test_username',
'user_identity': 'test_user_id',
'stack_identity': 'hay-are-en',
'stack_name': 'fred',
'tenant_id': 'test_tenant_id',
@ -54,7 +56,7 @@ class StackTest(common.HeatTestCase):
class AutoScaleTest(common.HeatTestCase):
def setUp(self):
super(AutoScaleTest, self).setUp()
self.ctx = utils.dummy_context()
self.ctx = utils.dummy_context(user_id='test_user_id')
def test_send(self):
created_time = timeutils.utcnow()
@ -80,6 +82,8 @@ class AutoScaleTest(common.HeatTestCase):
self.ctx, 'autoscaling.the-end', 'INFO',
{'state_reason': 'this is why',
'user_id': 'test_username',
'username': 'test_username',
'user_identity': 'test_user_id',
'stack_identity': 'hay-are-en',
'stack_name': 'fred',
'tenant_id': 'test_tenant_id',
@ -111,6 +115,8 @@ class AutoScaleTest(common.HeatTestCase):
self.ctx, 'autoscaling.error', 'ERROR',
{'state_reason': 'this is why',
'user_id': 'test_username',
'username': 'test_username',
'user_identity': 'test_user_id',
'stack_identity': 'hay-are-en',
'stack_name': 'fred',
'tenant_id': 'test_tenant_id',