Skip to content

Commit

Permalink
Closes-Bug: #1491217
Browse files Browse the repository at this point in the history
If a tenant is disabled and getting tokens API to keystones throws error,
so handled the null case before accessing variable.

Change-Id: I03021444f9ed36135bd85b0129bbb3e4e0c5a86f
  • Loading branch information
biswajit-mandal committed Sep 2, 2015
1 parent 8e7241c commit db0e962
Showing 1 changed file with 44 additions and 11 deletions.
55 changes: 44 additions & 11 deletions src/serverroot/orchestration/plugins/openstack/keystone.api.js
Expand Up @@ -956,11 +956,14 @@ function getUserRoleByAllTenants (username, password, tenantlist, callback)
var dataLen = data.length;
var tokenObjs = {};
for (var i = 0; i < dataLen; i++) {
var project = data[i]['tokenObj']['token']['tenant']['name'];
tokenObjs[project] = data[i]['tokenObj'];
if (null == data[i]) {
var project =
commonUtils.getValueByJsonPath(data[i],
'tokenObj;token;tenant;name',
null);
if (null == project) {
continue;
}
tokenObjs[project] = data[i]['tokenObj'];
userRoles =
getUserRoleByAuthResponse(data[i]['roles']);
var userRolesCnt = userRoles.length;
Expand Down Expand Up @@ -1117,10 +1120,24 @@ function getProjectDetails (projects, userObj, callback)
var tokenObjs = {};
var tokenCnt = tokenList.length;
for (var i = 0; i < tokenCnt; i++) {
var project = tokenList[i]['tenant']['name'];
var project =
commonUtils.getValueByJsonPath(tokenList[i], 'tenant;name',
null);
if (null == project) {
continue;
}
tokenObjs[project] = {};
tokenObjs[project]['token'] = tokenList[i];
tokenObjs[project]['token']['id'] =
var tokenID =
commonUtils.getValueByJsonPath(tokenObjs[project],
'token;id', null);
if (null == tokenID) {
logutils.logger.error('We did not get valid token id for ' +
'project: ' + project);
delete tokenObjs[project];
continue;
}
tokenObjs[project]['token']['id'] = removeSpecialChars(tokenID);
removeSpecialChars(tokenObjs[project]['token']['id'] );
}
callback(err, data, tokenObjs);
Expand All @@ -1140,7 +1157,13 @@ function getUserRoleByProjectList (projects, userObj, callback)
var projCnt = projs.length;
for (var i = 0; i < projCnt; i++) {
try {
var projName = projs[i]['token']['project']['name'];
var projName =
commonUtils.getValueByJsonPath(projs[i],
'token;project;name',
null);
if (null == projName) {
continue;
}
resTokenObjs[projName] = projs[i];
if (null != tokenObjs[projName]) {
resTokenObjs[projName]['token']['id'] =
Expand All @@ -1158,7 +1181,10 @@ function getUserRoleByProjectList (projects, userObj, callback)
}
var resCnt = projs.length;
for (var i = 0; i < resCnt; i++) {
var userRole = getUserRoleByAuthResponse(projs[i]['token']['roles']);
var roles =
commonUtils.getValueByJsonPath(projs[i],
'token;roles', null);
var userRole = getUserRoleByAuthResponse(roles);
if (global.STR_ROLE_ADMIN == userRole) {
callback(userRole, resTokenObjs);
return;
Expand Down Expand Up @@ -1640,13 +1666,20 @@ function getProjectList (req, appData, callback)
async.map(tenantObjArr, getUserRoleByTenant, function(err, data) {
var dataLen = data.length;
for (var i = 0; i < dataLen; i++) {
if (null == data[i]) {
var project =
commonUtils.getValueByJsonPath(data[i],
'tokenObj;token;tenant;name',
null);
if (null == project) {
continue;
}
var project =
data[i]['tokenObj']['token']['tenant']['name'];
var projectUUID =
data[i]['tokenObj']['token']['tenant']['id'];
commonUtils.getValueByJsonPath(data[i],
'tokenObj;token;tenant;id',
null);
if (null == projectUUID) {
continue;
}
req.session.tokenObjs[project] = data[i]['tokenObj'];
var userRoles = getUserRoleByAuthResponse(data[i]['roles']);
var rolesCnt = data[i]['roles'].length;
Expand Down

0 comments on commit db0e962

Please sign in to comment.