summaryrefslogtreecommitdiffstats
path: root/vid-app-common
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/services/CloudOwnerServiceImpl.java12
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js9
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/services/creationService.js62
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/services/deleteResumeService.js98
4 files changed, 101 insertions, 80 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/services/CloudOwnerServiceImpl.java b/vid-app-common/src/main/java/org/onap/vid/services/CloudOwnerServiceImpl.java
index d885f205e..4213255e1 100644
--- a/vid-app-common/src/main/java/org/onap/vid/services/CloudOwnerServiceImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/services/CloudOwnerServiceImpl.java
@@ -73,22 +73,24 @@ public class CloudOwnerServiceImpl implements CloudOwnerService {
}
}
- protected void enrichRequestWithCloudOwnerByAdditionalProperties(RequestDetails msoRequest) {
- String lcpCloudRegionId = null;
+ private void enrichRequestWithCloudOwnerByAdditionalProperties(RequestDetails msoRequest) {
+ final Map cloudConfiguration;
+ final String lcpCloudRegionId;
try {
+ cloudConfiguration = msoRequest.extractValueByPathUsingAdditionalProperties(CLOUD_CONFIGURATION_PATH, Map.class);
lcpCloudRegionId = msoRequest.extractValueByPathUsingAdditionalProperties(LCP_CLOUD_REGION_ID_PATH, String.class);
}
catch (NotFoundException exception) {
LOGGER.debug("Can't find lcp region in RequestDetails. Assume no cloudOwner enrichment is needed. Reason: ", exception);
return;
}
- String cloudOwner = aaiClient.getCloudOwnerByCloudRegionId(lcpCloudRegionId);
- msoRequest.extractValueByPathUsingAdditionalProperties(CLOUD_CONFIGURATION_PATH, Map.class).put("cloudOwner", cloudOwner);
+
+ cloudConfiguration.computeIfAbsent("cloudOwner", k -> aaiClient.getCloudOwnerByCloudRegionId(lcpCloudRegionId));
}
@Override
public void enrichCloudConfigurationWithCloudOwner(CloudConfiguration cloudConfiguration, String lcpCloudRegionId) {
- if (featureManager.isActive(Features.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST)) {
+ if (StringUtils.isEmpty(cloudConfiguration.getCloudOwner()) && featureManager.isActive(Features.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST)) {
String cloudOwner = aaiClient.getCloudOwnerByCloudRegionId(lcpCloudRegionId);
cloudConfiguration.setCloudOwner(cloudOwner);
}
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js
index 030faf524..af2483b68 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js
@@ -445,9 +445,14 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE
var aaiLcpCloudRegionTenants = response.data;
for (var i = 0; i < aaiLcpCloudRegionTenants.length; i++) {
+ var cloudOwner = aaiLcpCloudRegionTenants[i][COMPONENT.CLOUD_OWNER];
+ var cloudRegionId = aaiLcpCloudRegionTenants[i][COMPONENT.CLOUD_REGION_ID];
+ var cloudRegionOptionId = 'option-' + cloudOwner + '-' + cloudRegionId;
+
lcpCloudRegionTenants.push({
- "cloudRegionId": aaiLcpCloudRegionTenants[i][COMPONENT.CLOUD_REGION_ID],
- "cloudOwner": aaiLcpCloudRegionTenants[i][COMPONENT.CLOUD_OWNER],
+ "cloudOwner": cloudOwner,
+ "cloudRegionId": cloudRegionId,
+ "cloudRegionOptionId": cloudRegionOptionId.toLowerCase(),
"tenantName": aaiLcpCloudRegionTenants[i][COMPONENT.TENANT_NAME],
"tenantId": aaiLcpCloudRegionTenants[i][COMPONENT.TENANT_ID],
"isPermitted": aaiLcpCloudRegionTenants[i][COMPONENT.IS_PERMITTED]});
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/creationService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/creationService.js
index d5fd32001..83710ce16 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/services/creationService.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/creationService.js
@@ -541,14 +541,9 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON
var modelInfo = DataService.getModelInfo(_this.componentId);
//region id
- var lcpRegion = getValueFromList(FIELD.ID.LCP_REGION, parameterList);
- if (lcpRegion === FIELD.KEY.LCP_REGION_TEXT) {
- lcpRegion = getValueFromList(FIELD.ID.LCP_REGION_TEXT,
- parameterList);
- }
- var cloudOwner = _.find(DataService.getCloudRegionTenantList(), function(region){
- return region.cloudRegionId === lcpRegion;
- }).cloudOwner;
+ let cloudConfiguration = buildCloudConfiguration(parameterList);
+ var lcpRegion = cloudConfiguration.lcpCloudRegionId;
+ var cloudOwner = cloudConfiguration.cloudOwner;
var params = [];
var displayInputs = modelInfo.displayInputs;
@@ -666,15 +661,7 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON
}
if ( (_this.componentId != COMPONENT.SERVICE) || ( !DataService.getALaCarte() ) ) {
// include cloud region for everything but service create alacarte
- var lcpRegion = getValueFromList(FIELD.ID.LCP_REGION, parameterList);
- if (lcpRegion === FIELD.KEY.LCP_REGION_TEXT) {
- lcpRegion = getValueFromList(FIELD.ID.LCP_REGION_TEXT,
- parameterList);
- }
- requestDetails.cloudConfiguration = {
- lcpCloudRegionId : lcpRegion,
- tenantId : getValueFromList(FIELD.ID.TENANT, parameterList)
- };
+ requestDetails.cloudConfiguration = buildCloudConfiguration(parameterList);
}
switch (_this.componentId) {
@@ -775,6 +762,30 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON
return requestDetails;
};
+ var buildCloudConfiguration = function (parameterList) {
+ var lcpRegion;
+ var cloudOwner;
+
+ var lcpRegionOptionId = getValueFromList(FIELD.ID.LCP_REGION, parameterList);
+
+ if (lcpRegionOptionId === FIELD.KEY.LCP_REGION_TEXT) {
+ lcpRegion = getValueFromList(FIELD.ID.LCP_REGION_TEXT,
+ parameterList);
+ cloudOwner = undefined;
+ } else {
+ var cloudOwnerAndLcpCloudRegion = getCloudOwnerAndLcpCloudRegionFromOptionId(lcpRegionOptionId);
+ lcpRegion = cloudOwnerAndLcpCloudRegion.cloudRegionId;
+ cloudOwner = cloudOwnerAndLcpCloudRegion.cloudOwner;
+ }
+
+ return {
+ lcpCloudRegionId: lcpRegion,
+ cloudOwner: featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST) ? cloudOwner : undefined,
+ tenantId: getValueFromList(FIELD.ID.TENANT, parameterList)
+ };
+ };
+
+
var getRelatedInstanceList = function(parameterList) {
var relatedInstanceList = new Array();
switch (_this.componentId) {
@@ -1108,7 +1119,7 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON
parameter.optionList = new Array();
for (var i = 0; i < cloudRegionTenantList.length; i++) {
for (var j = 0; j < parameter.optionList.length; j++) {
- if (parameter.optionList[j].id === cloudRegionTenantList[i].cloudRegionId) {
+ if (parameter.optionList[j].id === cloudRegionTenantList[i].cloudRegionOptionId) {
parameter.optionList[j].isPermitted =
parameter.optionList[j].isPermitted || cloudRegionTenantList[i].isPermitted;
break;
@@ -1123,7 +1134,7 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON
cloudRegionTenantList[i].cloudRegionId;
parameter.optionList.push({
- id : cloudRegionTenantList[i].cloudRegionId,
+ id : cloudRegionTenantList[i].cloudRegionOptionId,
name: optionName,
isPermitted : cloudRegionTenantList[i].isPermitted
});
@@ -1132,14 +1143,23 @@ var CreationService = function($log, AaiService, AsdcService, DataService,VIDCON
return parameter;
};
- var getTenantList = function(cloudRegionId) {
+ var getCloudOwnerAndLcpCloudRegionFromOptionId = function (cloudRegionOptionId) {
+ var cloudRegionTenantList = DataService.getCloudRegionTenantList();
+ var cloudRegionTenant = _.find(cloudRegionTenantList, {"cloudRegionOptionId": cloudRegionOptionId});
+ return {
+ cloudOwner: cloudRegionTenant.cloudOwner,
+ cloudRegionId: cloudRegionTenant.cloudRegionId
+ }
+ };
+
+ var getTenantList = function(cloudRegionOptionId) {
var cloudRegionTenantList = DataService.getCloudRegionTenantList();
var parameter = "";
if ( UtilityService.hasContents (cloudRegionTenantList) ) {
parameter = FIELD.PARAMETER.TENANT_ENABLED;
parameter.optionList = new Array();
for (var i = 0; i < cloudRegionTenantList.length; i++) {
- if (cloudRegionTenantList[i].cloudRegionId === cloudRegionId) {
+ if (cloudRegionTenantList[i].cloudRegionOptionId === cloudRegionOptionId) {
parameter.optionList.push({
id : cloudRegionTenantList[i].tenantId,
name : cloudRegionTenantList[i].tenantName,
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/deleteResumeService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/deleteResumeService.js
index 6163184c2..36e962b73 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/services/deleteResumeService.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/deleteResumeService.js
@@ -294,6 +294,29 @@ var DeleteResumeService = function($log, AaiService, AsdcService, DataService,
});
};
+ var buildCloudConfiguration = function(parameterList) {
+ var lcpRegion;
+ var cloudOwner;
+
+ var lcpRegionOptionId = getValueFromList(FIELD.ID.LCP_REGION, parameterList);
+
+ if (lcpRegionOptionId === FIELD.KEY.LCP_REGION_TEXT) {
+ lcpRegion = getValueFromList(FIELD.ID.LCP_REGION_TEXT,
+ parameterList);
+ cloudOwner = undefined;
+ } else {
+ var cloudOwnerAndLcpCloudRegion = getCloudOwnerAndLcpCloudRegionFromOptionId(lcpRegionOptionId);
+ lcpRegion = cloudOwnerAndLcpCloudRegion.cloudRegionId;
+ cloudOwner = cloudOwnerAndLcpCloudRegion.cloudOwner;
+ }
+
+ return {
+ lcpCloudRegionId: lcpRegion,
+ cloudOwner: featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST) ? cloudOwner : undefined,
+ tenantId: getValueFromList(FIELD.ID.TENANT, parameterList)
+ };
+ };
+
var getMsoE2ERequest = function(parameterList) {
return {
"globalSubscriberId": DataService.getSubscriberName(),
@@ -338,7 +361,8 @@ var DeleteResumeService = function($log, AaiService, AsdcService, DataService,
};
}
}
-
+
+ console.log("getMsoRequestDetails COMPONENT." + _this.componentId);
switch (_this.componentId) {
case COMPONENT.SERVICE:
if (!requestDetails.requestParameters) {
@@ -347,55 +371,17 @@ var DeleteResumeService = function($log, AaiService, AsdcService, DataService,
requestDetails.requestParameters.aLaCarte = DataService.getALaCarte();
if ( !(DataService.getALaCarte()) ) {
// for macro delete include cloud config.
- var lcpRegion = getValueFromList(FIELD.ID.LCP_REGION, parameterList);
- if (lcpRegion === FIELD.KEY.LCP_REGION_TEXT) {
- lcpRegion = getValueFromList(FIELD.ID.LCP_REGION_TEXT,
- parameterList);
- }
- requestDetails.cloudConfiguration = {
- lcpCloudRegionId : lcpRegion,
- tenantId : getValueFromList(FIELD.ID.TENANT, parameterList)
- };
+ requestDetails.cloudConfiguration = buildCloudConfiguration(parameterList);
}
break;
case COMPONENT.VNF:
case COMPONENT.CONFIGURATION:
- console.log("getMsoRequestDetails COMPONENT.VNF");
- var lcpRegion = getValueFromList(FIELD.ID.LCP_REGION, parameterList);
- if (lcpRegion === FIELD.KEY.LCP_REGION_TEXT) {
- lcpRegion = getValueFromList(FIELD.ID.LCP_REGION_TEXT,
- parameterList);
- }
- requestDetails.cloudConfiguration = {
- lcpCloudRegionId : lcpRegion,
- tenantId : getValueFromList(FIELD.ID.TENANT, parameterList)
- };
-
- break;
case COMPONENT.VF_MODULE:
case COMPONENT.NETWORK:
- var lcpRegion = getValueFromList(FIELD.ID.LCP_REGION, parameterList);
- if (lcpRegion === FIELD.KEY.LCP_REGION_TEXT) {
- lcpRegion = getValueFromList(FIELD.ID.LCP_REGION_TEXT,
- parameterList);
- }
- requestDetails.cloudConfiguration = {
- lcpCloudRegionId : lcpRegion,
- tenantId : getValueFromList(FIELD.ID.TENANT, parameterList)
- };
- break;
case COMPONENT.VOLUME_GROUP:
- var lcpRegion = getValueFromList(FIELD.ID.LCP_REGION, parameterList);
- if (lcpRegion === FIELD.KEY.LCP_REGION_TEXT) {
- lcpRegion = getValueFromList(FIELD.ID.LCP_REGION_TEXT,
- parameterList);
- }
- requestDetails.cloudConfiguration = {
- lcpCloudRegionId : lcpRegion,
- tenantId : getValueFromList(FIELD.ID.TENANT, parameterList)
- };
-
+ requestDetails.cloudConfiguration = buildCloudConfiguration(parameterList);
break;
+
default:
requestDetails.cloudConfiguration = {
lcpCloudRegionId : DataService.getLcpRegion(),
@@ -404,7 +390,7 @@ var DeleteResumeService = function($log, AaiService, AsdcService, DataService,
}
return requestDetails;
}
-
+
var getLcpRegion = function() {
var cloudRegionTenantList = DataService.getCloudRegionTenantList();
var parameter = "";
@@ -413,7 +399,7 @@ var DeleteResumeService = function($log, AaiService, AsdcService, DataService,
parameter.optionList = new Array();
for (var i = 0; i < cloudRegionTenantList.length; i++) {
for (var j = 0; j < parameter.optionList.length; j++) {
- if (parameter.optionList[j].id === cloudRegionTenantList[i].cloudRegionId) {
+ if (parameter.optionList[j].id === cloudRegionTenantList[i].cloudRegionOptionId) {
parameter.optionList[j].isPermitted =
parameter.optionList[j].isPermitted || cloudRegionTenantList[i].isPermitted;
break;
@@ -428,24 +414,32 @@ var DeleteResumeService = function($log, AaiService, AsdcService, DataService,
cloudRegionTenantList[i].cloudRegionId;
parameter.optionList.push({
- id : cloudRegionTenantList[i].cloudRegionId,
+ id : cloudRegionTenantList[i].cloudRegionOptionId,
name: optionName,
- isPermitted : cloudRegionTenantList[i].isPermitted
-
- });
+ isPermitted : cloudRegionTenantList[i].isPermitted
+ });
}
}
return parameter;
};
-
- var getTenantList = function(cloudRegionId) {
+
+ var getCloudOwnerAndLcpCloudRegionFromOptionId = function (cloudRegionOptionId) {
+ var cloudRegionTenantList = DataService.getCloudRegionTenantList();
+ var cloudRegionTenant = _.find(cloudRegionTenantList, {"cloudRegionOptionId": cloudRegionOptionId});
+ return {
+ cloudOwner: cloudRegionTenant.cloudOwner,
+ cloudRegionId: cloudRegionTenant.cloudRegionId
+ }
+ };
+
+ var getTenantList = function(cloudRegionOptionId) {
var parameter = "";
var cloudRegionTenantList = DataService.getCloudRegionTenantList();
if ( UtilityService.hasContents (cloudRegionTenantList) ) {
- var parameter = FIELD.PARAMETER.TENANT_ENABLED;
+ parameter = FIELD.PARAMETER.TENANT_ENABLED;
parameter.optionList = new Array();
for (var i = 0; i < cloudRegionTenantList.length; i++) {
- if (cloudRegionTenantList[i].cloudRegionId === cloudRegionId) {
+ if (cloudRegionTenantList[i].cloudRegionOptionId === cloudRegionOptionId) {
parameter.optionList.push({
id : cloudRegionTenantList[i].tenantId,
name : cloudRegionTenantList[i].tenantName,