aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/main')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java113
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForService.java4
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsUtil.java8
3 files changed, 87 insertions, 38 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
index a38eb8c3a7..b29b95a3b1 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
@@ -1252,7 +1252,7 @@ public class BBInputSetup implements JavaDelegate {
|| requestAction.equalsIgnoreCase("activateFabricConfiguration")
|| requestAction.equalsIgnoreCase("recreateInstance")
|| requestAction.equalsIgnoreCase("replaceInstance")
- || requestAction.equalsIgnoreCase("upgradeInstance")) {
+ || requestAction.equalsIgnoreCase("upgradeInstance") || requestAction.equalsIgnoreCase("healthCheck")) {
return getGBBMacroExistingService(executeBB, lookupKeyMap, bbName, requestAction,
requestDetails.getCloudConfiguration());
}
@@ -1566,6 +1566,9 @@ public class BBInputSetup implements JavaDelegate {
break;
}
}
+ } else if (bbName.equals("HealthCheckBB")
+ && (VNF).equalsIgnoreCase(executeBB.getBuildingBlock().getBpmnScope())) {
+ this.setisHelmforHealthCheckBB(service, serviceInstance, gBB);
}
if (executeBB.getWorkflowResourceIds() != null) {
parameter.setResourceId(executeBB.getWorkflowResourceIds().getNetworkCollectionId());
@@ -1586,9 +1589,10 @@ public class BBInputSetup implements JavaDelegate {
Vnfs vnfs = null;
VfModules vfModules = null;
Networks networks = null;
+
CloudConfiguration cloudConfiguration = requestDetails.getCloudConfiguration();
- CloudRegion cloudRegion = getCloudRegionFromMacroRequest(cloudConfiguration, resources);
- gBB.setCloudRegion(cloudRegion);
+ CloudRegion cloudRegion = setCloudConfiguration(gBB, cloudConfiguration);
+
BBInputSetupParameter parameter =
new BBInputSetupParameter.Builder().setRequestId(executeBB.getRequestId()).setService(service)
.setBbName(bbName).setServiceInstance(serviceInstance).setLookupKeyMap(lookupKeyMap).build();
@@ -1601,6 +1605,11 @@ public class BBInputSetup implements JavaDelegate {
vnfs = findVnfsByKey(key, resources);
}
+ // Vnf level cloud configuration takes precedence over service level cloud configuration.
+ if (vnfs.getCloudConfiguration() != null) {
+ setCloudConfiguration(gBB, vnfs.getCloudConfiguration());
+ }
+
String vnfId = lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID);
// This stores the vnf id in request db to be retrieved later when
// working on a vf module or volume group
@@ -1637,6 +1646,21 @@ public class BBInputSetup implements JavaDelegate {
vfModules = getVfModulesByKey(key, resources);
}
+ String vfModulesName = vfModules.getInstanceName();
+ String vfModulesModelCustId = vfModules.getModelInfo().getModelCustomizationId();
+ // Get the Vnf associated with vfModule
+ Optional<org.onap.so.serviceinstancebeans.Vnfs> parentVnf = resources.getVnfs().stream()
+ .filter(aVnf -> aVnf.getCloudConfiguration() != null)
+ .filter(aVnf -> aVnf.getVfModules().stream()
+ .anyMatch(aVfModules -> aVfModules.getInstanceName().equals(vfModulesName) && aVfModules
+ .getModelInfo().getModelCustomizationId().equals(vfModulesModelCustId)))
+ .findAny();
+
+ // Get the cloud configuration from this Vnf
+ if (parentVnf.isPresent()) {
+ cloudRegion = setCloudConfiguration(gBB, parentVnf.get().getCloudConfiguration());
+ }
+
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, getVnfId(executeBB, lookupKeyMap));
parameter.setModelInfo(vfModules.getModelInfo());
@@ -1667,6 +1691,16 @@ public class BBInputSetup implements JavaDelegate {
networks = findNetworksByKey(key, resources);
String networkId = lookupKeyMap.get(ResourceKey.NETWORK_ID);
if (networks != null) {
+ // If service level cloud configuration is not provided then get it from networks.
+ if (cloudConfiguration == null) {
+ Optional<org.onap.so.serviceinstancebeans.Networks> netWithCloudConfig = resources.getNetworks()
+ .stream().filter(aNetwork -> aNetwork.getCloudConfiguration() != null).findAny();
+ if (netWithCloudConfig.isPresent()) {
+ setCloudConfiguration(gBB, netWithCloudConfig.get().getCloudConfiguration());
+ } else {
+ logger.debug("Could not find any cloud configuration for this request.");
+ }
+ }
parameter.setInstanceName(networks.getInstanceName());
parameter.setModelInfo(networks.getModelInfo());
parameter.setInstanceParams(networks.getInstanceParams());
@@ -1692,6 +1726,24 @@ public class BBInputSetup implements JavaDelegate {
return gBB;
}
+ /**
+ * setCloudConfiguration - set cloud info on a building block.
+ *
+ * @param gBB
+ * @param cloudConfiguration
+ * @return CloudRegion
+ * @throws Exception
+ */
+ private CloudRegion setCloudConfiguration(GeneralBuildingBlock gBB, CloudConfiguration cloudConfiguration)
+ throws Exception {
+ org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfiguration);
+ Tenant tenant = getTenant(cloudConfiguration, aaiCloudRegion);
+ gBB.setTenant(tenant);
+ CloudRegion cloudRegion = mapperLayer.mapCloudRegion(cloudConfiguration, aaiCloudRegion);
+ gBB.setCloudRegion(cloudRegion);
+ return cloudRegion;
+ }
+
protected Networks findNetworksByKey(String key, Resources resources) {
for (Networks networks : resources.getNetworks()) {
if (networks.getModelInfo().getModelCustomizationId().equalsIgnoreCase(key)) {
@@ -1742,39 +1794,6 @@ public class BBInputSetup implements JavaDelegate {
throw new ResourceNotFoundException("Could not find vnf with key: " + key + " in userparams");
}
- protected CloudRegion getCloudRegionFromMacroRequest(CloudConfiguration cloudConfiguration, Resources resources) {
- if (cloudConfiguration == null) {
- for (Vnfs vnfs : resources.getVnfs()) {
- if (cloudConfiguration == null) {
- cloudConfiguration = vnfs.getCloudConfiguration();
- } else {
- break;
- }
- for (VfModules vfModules : vnfs.getVfModules()) {
- if (cloudConfiguration == null) {
- cloudConfiguration = vfModules.getCloudConfiguration();
- } else {
- break;
- }
- }
- }
- for (Networks networks : resources.getNetworks()) {
- if (cloudConfiguration == null) {
- cloudConfiguration = networks.getCloudConfiguration();
- } else {
- break;
- }
- }
- }
- if (cloudConfiguration != null) {
- org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfiguration);
- return mapperLayer.mapCloudRegion(cloudConfiguration, aaiCloudRegion);
- } else {
- logger.debug("Could not find any cloud configuration for this request.");
- return null;
- }
- }
-
protected String getVnfId(ExecuteBuildingBlock executeBB, Map<ResourceKey, String> lookupKeyMap) {
String vnfId = lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID);
if (vnfId == null) {
@@ -2114,6 +2133,28 @@ public class BBInputSetup implements JavaDelegate {
return collection;
}
+ private void setisHelmforHealthCheckBB(Service service, ServiceInstance serviceInstance, GeneralBuildingBlock gBB) {
+ for (GenericVnf vnf : serviceInstance.getVnfs()) {
+ for (VfModule vfModule : vnf.getVfModules()) {
+ String vnfModelCustomizationUUID =
+ this.bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId()).getModelCustomizationId();
+ ModelInfo vnfModelInfo = new ModelInfo();
+ vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID);
+ this.mapCatalogVnf(vnf, vnfModelInfo, service);
+ String vfModuleCustomizationUUID = this.bbInputSetupUtils
+ .getAAIVfModule(vnf.getVnfId(), vfModule.getVfModuleId()).getModelCustomizationId();
+ ModelInfo vfModuleModelInfo = new ModelInfo();
+ vfModuleModelInfo.setModelCustomizationId(vfModuleCustomizationUUID);
+ this.mapCatalogVfModule(vfModule, vfModuleModelInfo, service, vnfModelCustomizationUUID);
+ if (vfModule.getModelInfoVfModule() != null && vfModule.getModelInfoVfModule().getModelName() != null
+ && vfModule.getModelInfoVfModule().getModelName().contains("helm")) {
+ gBB.getRequestContext().setIsHelm(true);
+ break;
+ }
+ }
+ }
+ }
+
protected void mapL3Networks(List<AAIResourceUri> list, List<L3Network> l3Networks) {
for (AAIResourceUri aaiResourceUri : list) {
l3Networks.add(this.mapL3Network(aaiResourceUri));
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForService.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForService.java
index e8c88e00d7..4148a60433 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForService.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForService.java
@@ -20,7 +20,7 @@
package org.onap.so.client.cds;
-import static org.onap.so.client.cds.ConfigureInstanceParamsUtil.applyParamsToObject;
+import static org.onap.so.client.cds.ConfigureInstanceParamsUtil.applyJsonParamsToObject;
import com.google.gson.JsonObject;
import java.util.List;
import java.util.Map;
@@ -49,7 +49,7 @@ public class ConfigureInstanceParamsForService {
Optional<Service> service =
extractServiceFromUserParameters.getServiceFromRequestUserParams(userParamsFromRequest);
- service.map(Service::getInstanceParams).ifPresent(p -> applyParamsToObject(p, jsonObject));
+ service.map(Service::getInstanceParams).ifPresent(p -> applyJsonParamsToObject(p, jsonObject));
} catch (Exception e) {
throw new PayloadGenerationException("Failed to resolve instance parameters", e);
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsUtil.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsUtil.java
index 117fd74498..7e9c885496 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsUtil.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsUtil.java
@@ -20,15 +20,23 @@
package org.onap.so.client.cds;
+import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.util.List;
import java.util.Map;
public final class ConfigureInstanceParamsUtil {
+ private static final Gson gson = new Gson();
+
public static void applyParamsToObject(List<Map<String, String>> instanceParamsList, JsonObject jsonObject) {
instanceParamsList.stream().flatMap(instanceParamsMap -> instanceParamsMap.entrySet().stream())
.forEachOrdered(entry -> jsonObject.addProperty(entry.getKey(), entry.getValue()));
}
+ public static void applyJsonParamsToObject(List<Map<String, Object>> instanceParamsList, JsonObject jsonObject) {
+ instanceParamsList.stream().flatMap(instanceParamsMap -> instanceParamsMap.entrySet().stream())
+ .forEachOrdered(entry -> jsonObject.add(entry.getKey(), gson.toJsonTree(entry.getValue())));
+ }
+
}