X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=bpmn%2FMSOCommonBPMN%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fso%2Fbpmn%2Fservicedecomposition%2Ftasks%2FBBInputSetup.java;h=b29b95a3b158f12441e8b750a79790c199917dd4;hb=b0f785e99096f230281d17e0fa89c21aca00fbac;hp=a38eb8c3a7b78a262925bd1cad231323bea5fa42;hpb=2ef42cd813c85015322da874de668b79e790c5eb;p=so.git 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 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 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 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 list, List l3Networks) { for (AAIResourceUri aaiResourceUri : list) { l3Networks.add(this.mapL3Network(aaiResourceUri));