From e00d3ee9b090f3ceb87ac187e3e1c700d8a74fa7 Mon Sep 17 00:00:00 2001 From: sanket12345 Date: Tue, 30 Aug 2022 21:33:06 +0530 Subject: Code & Workflow Enhancements for CNF - Upgrade - Adding New Building Block : VfModuleUpgradeBB, which delgates Workflow to next BB by just changing AAI Orch_status, else WF fails during Orchestration flow validation DB lookup. - Adding changes to BB Inputs to take new version VNF & VFM model details and pass to BBs, as done for Service-Macro-Upgrade. - Adding new operations in CDS to skip execution,when SDC Model has skipCDS=True. - Calling CNF Adapter with existing heatStackID & passing it for CNF-Upgrade with new customization details. Issue-ID: SO-3857 Change-Id: I69f71f825b812d423f82f1a902dcb8567d8a6adb Signed-off-by: sanket12345 --- .../servicedecomposition/tasks/BBInputSetup.java | 56 +++++++++++++++++++--- .../BuildingBlock/UpgradeVfModuleBB.bpmn | 10 ++-- .../BuildingBlock/VfModuleUpgradeStatusBB.bpmn | 44 +++++++++++++++++ .../adapter/cnf/tasks/CnfAdapterCreateTasks.java | 2 +- .../adapter/cnf/tasks/CnfAdapterUpgradeTasks.java | 3 +- .../listeners/SkipCDSBuildingBlockListener.java | 4 +- .../so/client/adapter/cnf/CnfAdapterClient.java | 7 +-- 7 files changed, 107 insertions(+), 19 deletions(-) create mode 100644 bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/VfModuleUpgradeStatusBB.bpmn (limited to 'bpmn') 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 c36aaac5e1..f192024007 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 @@ -1272,7 +1272,8 @@ public class BBInputSetup implements JavaDelegate { || requestAction.equalsIgnoreCase("activateFabricConfiguration") || requestAction.equalsIgnoreCase("recreateInstance") || requestAction.equalsIgnoreCase("replaceInstance") - || requestAction.equalsIgnoreCase("upgradeInstance") || requestAction.equalsIgnoreCase("healthCheck")) { + || requestAction.equalsIgnoreCase("upgradeInstance") || requestAction.equalsIgnoreCase("healthCheck") + || requestAction.equalsIgnoreCase("upgradeCnf")) { return getGBBMacroExistingService(executeBB, lookupKeyMap, bbName, requestAction, requestDetails.getCloudConfiguration()); } @@ -1489,6 +1490,27 @@ public class BBInputSetup implements JavaDelegate { cloudRegion = mapperLayer.mapCloudRegion(cloudConfiguration, aaiCloudRegion); } gBB.setCloudRegion(cloudRegion); + String upgradeCnfModelCustomizationUUID = ""; + String upgradeCnfVfModuleModelCustomizationUUID = ""; + String upgradeCnfModelVersionId = ""; + String upgradeCnfVfModuleModelVersionId = ""; + if (requestDetails.getRelatedInstanceList() != null) { + for (RelatedInstanceList relatedInstList : requestDetails.getRelatedInstanceList()) { + RelatedInstance relatedInstance = relatedInstList.getRelatedInstance(); + // condition -1 + if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf) + && requestAction.equalsIgnoreCase("upgradeCnf")) { + upgradeCnfModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId(); + upgradeCnfModelVersionId = relatedInstance.getModelInfo().getModelVersionId(); + } + // condition -2 + if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vfModule) + && parameter.getRequestAction().equals("upgradeCnf")) { + upgradeCnfVfModuleModelCustomizationUUID = relatedInstance.getModelInfo().getModelCustomizationId(); + upgradeCnfVfModuleModelVersionId = relatedInstance.getModelInfo().getModelVersionId(); + } + } + } if (bbName.contains(VNF) || (bbName.contains(CONTROLLER) && (VNF).equalsIgnoreCase(executeBB.getBuildingBlock().getBpmnScope()))) { for (GenericVnf genericVnf : serviceInstance.getVnfs()) { @@ -1496,12 +1518,18 @@ public class BBInputSetup implements JavaDelegate { && genericVnf.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) { org.onap.aai.domain.yang.GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(genericVnf.getVnfId()); ModelInfo modelInfo = new ModelInfo(); - if (vnf != null) { + if ("upgradeCnf".equalsIgnoreCase(requestAction) && upgradeCnfModelCustomizationUUID != null) { + modelInfo.setModelCustomizationUuid(upgradeCnfModelCustomizationUUID); + modelInfo.setModelVersionId(upgradeCnfModelVersionId); + this.mapCatalogVnf(genericVnf, modelInfo, service); + } else if (vnf != null) { modelInfo.setModelCustomizationUuid(vnf.getModelCustomizationId()); + this.mapCatalogVnf(genericVnf, modelInfo, service); } - this.mapCatalogVnf(genericVnf, modelInfo, service); + } } + } else if (bbName.contains(VF_MODULE) || (bbName.contains(CONTROLLER) && (VF_MODULE).equalsIgnoreCase(executeBB.getBuildingBlock().getBpmnScope()))) { for (GenericVnf vnf : serviceInstance.getVnfs()) { @@ -1511,14 +1539,28 @@ public class BBInputSetup implements JavaDelegate { String vnfModelCustomizationUUID = this.bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId()).getModelCustomizationId(); ModelInfo vnfModelInfo = new ModelInfo(); - vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID); - this.mapCatalogVnf(vnf, vnfModelInfo, service); + if ("upgradeCnf".equalsIgnoreCase(requestAction) && upgradeCnfModelCustomizationUUID != null) { + vnfModelInfo.setModelCustomizationUuid(upgradeCnfModelCustomizationUUID); + vnfModelInfo.setModelVersionId(upgradeCnfModelVersionId); + this.mapCatalogVnf(vnf, vnfModelInfo, service); + } else { + vnfModelInfo.setModelCustomizationUuid(vnfModelCustomizationUUID); + this.mapCatalogVnf(vnf, vnfModelInfo, service); + } lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, vnf.getVnfId()); String vfModuleCustomizationUUID = this.bbInputSetupUtils .getAAIVfModule(vnf.getVnfId(), vfModule.getVfModuleId()).getModelCustomizationId(); ModelInfo vfModuleModelInfo = new ModelInfo(); - vfModuleModelInfo.setModelCustomizationId(vfModuleCustomizationUUID); - this.mapCatalogVfModule(vfModule, vfModuleModelInfo, service, vnfModelCustomizationUUID); + if ("upgradeCnf".equalsIgnoreCase(requestAction) + && upgradeCnfVfModuleModelCustomizationUUID != null) { + vfModuleModelInfo.setModelCustomizationUuid(upgradeCnfVfModuleModelCustomizationUUID); + vfModuleModelInfo.setModelVersionId(upgradeCnfVfModuleModelVersionId); + this.mapCatalogVfModule(vfModule, vfModuleModelInfo, service, + upgradeCnfVfModuleModelCustomizationUUID); + } else { + vfModuleModelInfo.setModelCustomizationId(vfModuleCustomizationUUID); + this.mapCatalogVfModule(vfModule, vfModuleModelInfo, service, vnfModelCustomizationUUID); + } if (cloudRegion != null) { Optional volumeGroupIdOp = getVolumeGroupIdRelatedToVfModule(vnf, vfModuleModelInfo, cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), lookupKeyMap); diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UpgradeVfModuleBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UpgradeVfModuleBB.bpmn index 59bb404936..dcfc8344f8 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UpgradeVfModuleBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/UpgradeVfModuleBB.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1xr6chl @@ -15,7 +15,7 @@ SequenceFlow_1xr6chl SequenceFlow_1s4rpyp - + SequenceFlow_0rds4rj SequenceFlow_1vbwdaw @@ -192,6 +192,9 @@ + + + @@ -207,9 +210,6 @@ - - - diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/VfModuleUpgradeStatusBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/VfModuleUpgradeStatusBB.bpmn new file mode 100644 index 0000000000..faade41d10 --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/VfModuleUpgradeStatusBB.bpmn @@ -0,0 +1,44 @@ + + + + + SequenceFlow_0zaz9o2 + + + SequenceFlow_1jwsja5 + + + SequenceFlow_0zaz9o2 + SequenceFlow_1jwsja5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java index ed01f2271f..5e3b781903 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterCreateTasks.java @@ -170,7 +170,7 @@ public class CnfAdapterCreateTasks { logger.debug("currentFlow: {}", currentFlow); String apiPath = "http://so-cnf-adapter:8090"; - if ("CreateVfModuleBB".equals(currentFlow)) { + if ("CreateVfModuleBB".equals(currentFlow) || ("UpgradeVfModuleBB".equals(currentFlow))) { apiPath = apiPath + "/api/cnf-adapter/v1/aai-update/"; } else if ("DeleteVfModuleBB".equals(currentFlow)) { apiPath = apiPath + "/api/cnf-adapter/v1/aai-delete/"; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterUpgradeTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterUpgradeTasks.java index 2eebde0687..4fd0aab397 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterUpgradeTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnf/tasks/CnfAdapterUpgradeTasks.java @@ -90,7 +90,8 @@ public class CnfAdapterUpgradeTasks { Map sdncDirectives = getSdncDirectives(paramsMap); UpgradeInstanceRequest upgradeInstanceRequest = upgradeInstanceRequest(vfModule, cloudRegion, sdncDirectives); - UpgradeInstanceResponse response = cnfAdapterClient.upgradeVfModule(upgradeInstanceRequest); + String heatStackId = vfModule.getHeatStackId(); + UpgradeInstanceResponse response = cnfAdapterClient.upgradeVfModule(upgradeInstanceRequest, heatStackId); execution.setVariable("heatStackId", response.getId()); } catch (Exception ex) { logger.error("Exception occurred", ex); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java index dc77ea1f0c..6df4f76a59 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java @@ -47,8 +47,8 @@ public class SkipCDSBuildingBlockListener implements PreFlowManipulator { @Autowired private CatalogDbClient catalogDbClient; - private Set vnfActions = - new HashSet(Arrays.asList("config-assign", "config-deploy", "VnfConfigAssign", "VnfConfigDeploy")); + private Set vnfActions = new HashSet(Arrays.asList("config-assign", "config-deploy", + "VnfConfigAssign", "VnfConfigDeploy", "config-upgrade-assign", "config-upgrade-deploy")); private Set vFModuleAction = new HashSet(Arrays.asList("VfModuleConfigAssign", "VfModuleConfigDeploy")); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java index e8122e7784..82c0e4916e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/cnf/CnfAdapterClient.java @@ -118,11 +118,12 @@ public class CnfAdapterClient { } @Retryable(value = {HttpServerErrorException.class}, maxAttempts = 3, backoff = @Backoff(delay = 3000)) - public UpgradeInstanceResponse upgradeVfModule(UpgradeInstanceRequest request) throws CnfAdapterClientException { + public UpgradeInstanceResponse upgradeVfModule(UpgradeInstanceRequest request, String heatStackId) + throws CnfAdapterClientException { try { String uri = "http://so-cnf-adapter:8090"; - String endpoint = UriBuilder.fromUri(uri).path("/api/cnf-adapter/v1/instance/{instanceID}/upgrade").build() - .toString(); + String endpoint = UriBuilder.fromUri(uri).path(INSTANCE_CREATE_PATH + "/" + heatStackId + "/upgrade") + .build().toString(); HttpEntity entity = getHttpEntity(request); ResponseEntity result = restTemplate.exchange(endpoint, HttpMethod.POST, entity, UpgradeInstanceResponse.class); -- cgit 1.2.3-korg