diff options
Diffstat (limited to 'bpmn')
10 files changed, 281 insertions, 188 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 d971689f94..7c283ab153 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 @@ -1936,7 +1936,8 @@ public class BBInputSetup implements JavaDelegate { if (relationshipsOp.isPresent()) { Relationships relationships = relationshipsOp.get(); this.mapPlatform(relationships.getByType(Types.PLATFORM, uri -> uri.nodesOnly(true)), genericVnf); - this.mapLineOfBusiness(relationships.getByType(Types.LINE_OF_BUSINESS), genericVnf); + this.mapLineOfBusiness(relationships.getByType(Types.LINE_OF_BUSINESS, uri -> uri.nodesOnly(true)), + genericVnf); genericVnf.getVolumeGroups().addAll(mapVolumeGroups(relationships.getByType(Types.VOLUME_GROUP))); genericVnf.getInstanceGroups().addAll(mapInstanceGroups(relationships.getByType(Types.INSTANCE_GROUP))); } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java index 98a14fc0e5..2e0ec3f154 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/restproperties/AAIPropertiesImpl.java @@ -35,11 +35,10 @@ public class AAIPropertiesImpl implements AAIProperties { public static final String AAI_AUTH = "aai.auth"; public static final String AAI_ENDPOINT = "aai.endpoint"; public static final String AAI_READ_TIMEOUT = "aai.readTimeout"; + public static final String AAI_CONNECTION_TIMEOUT = "aai.connectionTimeout"; public static final String AAI_ENABLE_CACHING = "aai.caching.enable"; public static final String AAI_CACHE_MAX_AGE = "aai.caching.maxAge"; - private UrnPropertiesReader reader; - @Override public URL getEndpoint() throws MalformedURLException { return new URL(UrnPropertiesReader.getVariable(AAI_ENDPOINT)); @@ -67,12 +66,17 @@ public class AAIPropertiesImpl implements AAIProperties { @Override public Long getReadTimeout() { - return Long.valueOf(reader.getVariable(AAI_READ_TIMEOUT, "60000")); + return Long.valueOf(UrnPropertiesReader.getVariable(AAI_READ_TIMEOUT, "60000")); + } + + @Override + public Long getConnectionTimeout() { + return Long.valueOf(UrnPropertiesReader.getVariable(AAI_CONNECTION_TIMEOUT, "60000")); } @Override public boolean isCachingEnabled() { - return Boolean.parseBoolean(reader.getVariable(AAI_ENABLE_CACHING, "false")); + return Boolean.parseBoolean(UrnPropertiesReader.getVariable(AAI_ENABLE_CACHING, "false")); } @Override @@ -80,7 +84,7 @@ public class AAIPropertiesImpl implements AAIProperties { return new AAICacheProperties() { @Override public Long getMaxAge() { - return Long.valueOf(reader.getVariable(AAI_CACHE_MAX_AGE, "60000")); + return Long.valueOf(UrnPropertiesReader.getVariable(AAI_CACHE_MAX_AGE, "60000")); } }; } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmRestClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmRestClient.java index 3faf58ec28..85d67a89c9 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmRestClient.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/sdnc/lcm/SDNCLcmRestClient.java @@ -21,10 +21,11 @@ package org.onap.so.client.sdnc.lcm; import java.net.URI; -import java.util.Map; import java.util.Optional; -import org.onap.so.client.RestClient; +import javax.ws.rs.core.MultivaluedMap; +import org.javatuples.Pair; import org.onap.logging.filter.base.ONAPComponents; +import org.onap.so.client.RestClient; import org.onap.so.client.sdnc.lcm.beans.LcmInput; import org.onap.so.client.sdnc.lcm.beans.LcmOutput; import org.onap.so.client.sdnc.lcm.beans.LcmRestRequest; @@ -44,8 +45,8 @@ public class SDNCLcmRestClient extends RestClient { } @Override - protected void initializeHeaderMap(Map<String, String> headerMap) { - headerMap.put("Authorization", sdncLcmProperties.getBasicAuth()); + protected void initializeHeaderMap(MultivaluedMap<String, Pair<String, String>> headerMap) { + headerMap.add("ALL", Pair.with("Authorization", sdncLcmProperties.getBasicAuth())); } @Override diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ModelInfoVfModuleExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ModelInfoVfModuleExpected.json index 1f9a8be5cf..feff0f5fba 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ModelInfoVfModuleExpected.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/ModelInfoVfModuleExpected.json @@ -10,5 +10,5 @@ "max-instances": 3, "availability-zone-count": 5, "label": "label", - "initial-count": null + "initial-count": 0 }
\ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSI.groovy index ec97972e5d..01aefe2054 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNSSI.groovy @@ -123,7 +123,6 @@ class DoAllocateCoreNSSI extends AbstractServiceTaskProcessor { execution.setVariable("OOFResponse", OOFResponse) String solutions ="" if(requestStatus.equals("completed")) { - solutions = jsonUtil.getJsonValue(OOFResponse, "solutions") List solutionsList = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(OOFResponse, "solutions")) if(solutionsList!=null && !solutionsList.isEmpty() ) { solutions = solutionsList.get(0) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy index 1ca0605ac8..91599700ef 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy @@ -440,7 +440,9 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { AAIResourceUri networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), bh_routeId) client.create(networkRouteUri, bh_ep) //relationship b/w bh_ep and Core NSSI - def coreNssi = execution.getVariable("nssiServiceInstanceId") + String coreNssi = execution.getVariable("nssiServiceInstanceId") + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") Relationship relationship = new Relationship() String relatedLink = "aai/v21/network/network-routes/network-route/${bh_routeId}" relationship.setRelatedLink(relatedLink) @@ -448,10 +450,7 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf") logger.debug("networkRouteUri: "+networkRouteUri+"relationship: "+relationship) try { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, - execution.getVariable("globalSubscriberId"), - execution.getVariable("subscriptionServiceType"), - coreNssi).relationshipAPI() + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(coreNssi)).relationshipAPI() logger.debug("uri: "+uri) client.create(uri, relationship) } catch (BpmnError e) { @@ -475,6 +474,7 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { String serviceId = execution.getVariable("nsiId") String jobId = execution.getVariable("jobId") String nsiId = execution.getVariable("nsiId") + String nssiId = execution.getVariable("nssiServiceInstanceId") String operationType = "ALLOCATE" ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() resourceOperationStatus.setServiceId(serviceId) @@ -494,15 +494,17 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor { String serviceId = execution.getVariable("nsiId") String jobId = execution.getVariable("jobId") String nsiId = execution.getVariable("nsiId") - String nssiId = execution.getVariable("nssiId") + String nssiId = execution.getVariable("nssiServiceInstanceId") String operationType = "ALLOCATE" //modelUuid String modelUuid= execution.getVariable("modelUuid") - logger.debug("serviceId: "+serviceId +" "+ "jobId: "+jobId +" "+ "nsiId: "+nsiId +" "+ "operationType: "+operationType) + logger.debug("serviceId: "+serviceId +" "+ "jobId: "+jobId +" "+ "nsiId: "+nsiId +" "+ "nssiId: "+nssiId +" "+ "operationType: "+operationType) ResourceOperationStatus resourceOperationStatus = new ResourceOperationStatus() resourceOperationStatus.setServiceId(serviceId) resourceOperationStatus.setJobId(jobId) resourceOperationStatus.setOperationId(jobId) + resourceOperationStatus.setResourceTemplateUUID(nsiId) + resourceOperationStatus.setResourceInstanceID(nssiId) resourceOperationStatus.setResourceTemplateUUID(modelUuid) resourceOperationStatus.setOperType(operationType) resourceOperationStatus.setProgress("0") diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy index f591855b5c..982771f681 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyAccessNSSI.groovy @@ -549,7 +549,7 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { updateStatus.setResourceTemplateUUID(nsiId) updateStatus.setResourceInstanceID(nssiId) updateStatus.setOperType("Modify") - updateStatus.setProgress(100) + updateStatus.setProgress("100") updateStatus.setStatus("finished") requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus) @@ -571,7 +571,7 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { updateStatus.setResourceTemplateUUID(nsiId) updateStatus.setResourceInstanceID(nssiId) updateStatus.setOperType("Modify") - updateStatus.setProgress(0) + updateStatus.setProgress("0") updateStatus.setStatus("failed") requestDBUtil.prepareUpdateResourceOperationStatus(execution, updateStatus) } @@ -652,4 +652,4 @@ class DoModifyAccessNSSI extends AbstractServiceTaskProcessor { logger.debug("Error occured within deleteServiceInstance method: " + e) } } -}
\ No newline at end of file +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyRanNfNssi.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyRanNfNssi.groovy index 6fdfbe3218..e0df9ea64b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyRanNfNssi.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyRanNfNssi.groovy @@ -29,7 +29,8 @@ import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.core.json.JsonUtils import com.fasterxml.jackson.databind.ObjectMapper import com.google.gson.JsonObject -import java.sql.Timestamp +import com.google.gson.JsonParser +import java.time.Instant import static org.apache.commons.lang3.StringUtils.isBlank import org.onap.so.bpmn.core.UrnPropertiesReader @@ -75,7 +76,7 @@ class DoModifyRanNfNssi extends AbstractServiceTaskProcessor { execution.setVariable("sliceProfile", sliceProfile) break case "reconfigure": - String resourceConfig = execution.getVariable("additionalProperties") + String resourceConfig = execution.getVariable("additionalProperties") execution.setVariable("resourceConfig", resourceConfig) break default: @@ -83,7 +84,7 @@ class DoModifyRanNfNssi extends AbstractServiceTaskProcessor { exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Invalid modify Action : "+modifyAction) } } - List<String> snssaiList = objectMapper.readValue(execution.getVariable("snssaiList"), List.class) + List<String> snssaiList = execution.getVariable("snssaiList") String sliceProfileId = execution.getVariable("sliceProfileId") if (isBlank(sliceProfileId) || (snssaiList.empty)) { msg = "Mandatory fields are empty" @@ -109,7 +110,7 @@ class DoModifyRanNfNssi extends AbstractServiceTaskProcessor { logger.debug(Prefix+"createSdnrRequest method start") String callbackUrl = UrnPropertiesReader.getVariable("mso.workflow.message.endpoint") + "/AsyncSdnrResponse/"+execution.getVariable("msoRequestId") String modifyAction = execution.getVariable("modifyAction") - String sdnrRequest = buildSdnrAllocateRequest(execution, modifyAction, "InstantiateRANSlice", callbackUrl) + String sdnrRequest = buildSdnrAllocateRequest(execution, modifyAction, "instantiateRANSlice", callbackUrl) execution.setVariable("createNSSI_sdnrRequest", sdnrRequest) execution.setVariable("createNSSI_timeout", "PT10M") execution.setVariable("createNSSI_correlator", execution.getVariable("msoRequestId")) @@ -123,6 +124,7 @@ class DoModifyRanNfNssi extends AbstractServiceTaskProcessor { if(status.equalsIgnoreCase("success")) { String nfIds = jsonUtil.getJsonValue(SDNRResponse, "nfIds") execution.setVariable("ranNfIdsJson", nfIds) + execution.setVariable("ranNfStatus", status) }else { String reason = jsonUtil.getJsonValue(SDNRResponse, "reason") logger.error("received failed status from SDNR "+ reason) @@ -134,53 +136,47 @@ class DoModifyRanNfNssi extends AbstractServiceTaskProcessor { private String buildSdnrAllocateRequest(DelegateExecution execution, String action, String rpcName, String callbackUrl) { String requestId = execution.getVariable("msoRequestId") - Date date = new Date().getTime() - Timestamp time = new Timestamp(date) - String sliceProfileString + Instant time = Instant.now() + Map<String,Object> sliceProfile = new HashMap<>() JsonObject response = new JsonObject() JsonObject body = new JsonObject() JsonObject input = new JsonObject() JsonObject commonHeader = new JsonObject() JsonObject payload = new JsonObject() JsonObject payloadInput = new JsonObject() + JsonParser parser = new JsonParser() if(action.equals("allocate")) { - Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class) + sliceProfile = objectMapper.readValue(execution.getVariable("sliceProfile"), Map.class) sliceProfile.put("sliceProfileId", execution.getVariable("sliceProfileId")) sliceProfile.put("maxNumberofConns", sliceProfile.get("maxNumberofPDUSessions")) sliceProfile.put("uLThptPerSlice", sliceProfile.get("expDataRateUL")) sliceProfile.put("dLThptPerSlice", sliceProfile.get("expDataRateDL")) - sliceProfileString = objectMapper.writeValueAsString(sliceProfile) action = "modify-"+action payloadInput.add("additionalproperties", new JsonObject()) }else if(action.equals("deallocate")) { action = "modify-"+action - Map<String,Object> sliceProfile = new HashMap<>() sliceProfile.put("sliceProfileId", execution.getVariable("sliceProfileId")) sliceProfile.put("sNSSAI", execution.getVariable("snssai")) - sliceProfileString = objectMapper.writeValueAsString(sliceProfile) payloadInput.add("additionalproperties", new JsonObject()) }else if(action.equals("reconfigure")) { - Map<String,Object> sliceProfile = new HashMap<>() sliceProfile.put("sliceProfileId", execution.getVariable("sliceProfileId")) sliceProfile.put("sNSSAI", execution.getVariable("snssai")) - sliceProfileString = objectMapper.writeValueAsString(sliceProfile) JsonObject resourceconfig = new JsonObject() - resourceconfig.addProperty("resourceConfig", execution.getVariable("resourceConfig")) + resourceconfig.add("resourceConfig", (JsonObject) parser.parse(execution.getVariable("resourceConfig"))) payloadInput.add("additionalproperties", resourceconfig) } - commonHeader.addProperty("TimeStamp", time.toString()) - commonHeader.addProperty("APIver", "1.0") - commonHeader.addProperty("RequestID", requestId) - commonHeader.addProperty("SubRequestID", "1") - commonHeader.add("RequestTrack", new JsonObject()) - commonHeader.add("Flags", new JsonObject()) - payloadInput.addProperty("sliceProfile", sliceProfileString) + commonHeader.addProperty("timestamp", time.toString()) + commonHeader.addProperty("api-ver", "1.0") + commonHeader.addProperty("request-id", requestId) + commonHeader.addProperty("sub-request-id", "1") + commonHeader.add("flags", new JsonObject()) + payloadInput.addProperty("sliceProfile", sliceProfile.toString()) payloadInput.addProperty("RANNFNSSIId", execution.getVariable("serviceInstanceID")) payloadInput.addProperty("callbackURL", callbackUrl) payload.add("input", payloadInput) - input.add("CommonHeader", commonHeader) - input.addProperty("Action", action) - input.add("Payload", payload) + input.add("common-header", commonHeader) + input.addProperty("action", action) + input.addProperty("payload", payload.toString()) body.add("input", input) response.add("body", body) response.addProperty("version", "1.0") @@ -190,4 +186,4 @@ class DoModifyRanNfNssi extends AbstractServiceTaskProcessor { return response.toString() } -}
\ No newline at end of file +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index aad8b51a48..4be497c469 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -28,6 +28,7 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; import org.apache.commons.lang3.SerializationUtils; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.javatuples.Pair; @@ -175,8 +176,7 @@ public class WorkflowAction { String serviceInstanceId = getServiceInstanceId(execution, resourceId, resourceType); fillExecution(execution, requestDetails.getRequestInfo().getSuppressRollback(), resourceId, resourceType); - List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); - + List<ExecuteBuildingBlock> flowsToExecute; if (isRequestMacroServiceResume(isALaCarte, resourceType, requestAction, serviceInstanceId)) { String errorMessage = "Could not resume Macro flow. Error loading execution path."; flowsToExecute = loadExecuteBuildingBlocks(execution, requestId, errorMessage); @@ -193,141 +193,13 @@ public class WorkflowAction { final String serviceType = Optional.ofNullable((String) execution.getVariable(BBConstants.G_SERVICE_TYPE)).orElse(""); if (isALaCarte) { - if (orchFlows == null || orchFlows.isEmpty()) { - orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, true, - cloudOwner, serviceType); - } - Resource resourceKey = getResourceKey(sIRequest, resourceType); - - ReplaceInstanceRelatedInformation replaceInfo = new ReplaceInstanceRelatedInformation(); - if ((requestAction.equalsIgnoreCase(REPLACEINSTANCE) - || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)) - && resourceType.equals(WorkflowType.VFMODULE)) { - logger.debug("Build a BB list for replacing BB modules"); - ConfigBuildingBlocksDataObject cbbdo = createConfigBuildingBlocksDataObject(execution, - sIRequest, requestId, workflowResourceIds, requestDetails, requestAction, resourceId, - vnfType, orchFlows, apiVersion, resourceKey, replaceInfo); - orchFlows = getVfModuleReplaceBuildingBlocks(cbbdo); - - createBuildingBlocksForOrchFlows(execution, sIRequest, requestId, workflowResourceIds, - requestDetails, requestAction, resourceId, flowsToExecute, vnfType, orchFlows, - apiVersion, resourceKey, replaceInfo); - } else { - if (isConfiguration(orchFlows) && !requestAction.equalsIgnoreCase(CREATE_INSTANCE)) { - addConfigBuildingBlocksToFlowsToExecuteList(execution, sIRequest, requestId, - workflowResourceIds, requestDetails, requestAction, resourceId, flowsToExecute, - vnfType, apiVersion, resourceKey, replaceInfo, orchFlows); - } - orchFlows = - orchFlows.stream().filter(item -> !item.getFlowName().contains(FABRIC_CONFIGURATION)) - .collect(Collectors.toList()); - - for (OrchestrationFlow orchFlow : orchFlows) { - ExecuteBuildingBlock ebb = executeBuildingBlockBuilder.buildExecuteBuildingBlock(orchFlow, - requestId, resourceKey, apiVersion, resourceId, requestAction, true, vnfType, - workflowResourceIds, requestDetails, false, null, null, false, replaceInfo); - flowsToExecute.add(ebb); - } - } + flowsToExecute = loadExecuteBuildingBlocksForAlaCarte(orchFlows, execution, requestAction, + resourceType, cloudOwner, serviceType, sIRequest, requestId, workflowResourceIds, + requestDetails, resourceId, vnfType, apiVersion); } else { - boolean containsService = false; - List<Resource> resourceList = new ArrayList<>(); - List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>(); - List<Map<String, Object>> userParams = - sIRequest.getRequestDetails().getRequestParameters().getUserParams(); - if (resourceType == WorkflowType.SERVICE && requestAction.equalsIgnoreCase(ASSIGNINSTANCE)) { - // SERVICE-MACRO-ASSIGN will always get user params with a - // service. - - if (userParams != null) { - containsService = isContainsService(sIRequest); - if (containsService) { - resourceList = userParamsServiceTraversal.getResourceListFromUserParams(execution, - userParams, serviceInstanceId, requestAction); - } - } else { - buildAndThrowException(execution, - "Service-Macro-Assign request details must contain user params with a service"); - } - } else if (resourceType == WorkflowType.SERVICE - && requestAction.equalsIgnoreCase(CREATE_INSTANCE)) { - // SERVICE-MACRO-CREATE will get user params with a service, - // a service with a network, a service with a - // network collection, OR an empty service. - // If user params is just a service or null and macro - // queries the SI and finds a VNF, macro fails. - - if (userParams != null) { - containsService = isContainsService(sIRequest); - } - if (containsService) { - resourceList = userParamsServiceTraversal.getResourceListFromUserParams(execution, - userParams, serviceInstanceId, requestAction); - } - if (!foundRelated(resourceList)) { - traverseCatalogDbService(execution, sIRequest, resourceList, aaiResourceIds); - } - } else if (resourceType == WorkflowType.SERVICE - && ("activateInstance".equalsIgnoreCase(requestAction) - || "unassignInstance".equalsIgnoreCase(requestAction) - || "deleteInstance".equalsIgnoreCase(requestAction) - || requestAction.equalsIgnoreCase("activate" + FABRIC_CONFIGURATION))) { - // SERVICE-MACRO-ACTIVATE, SERVICE-MACRO-UNASSIGN, and - // SERVICE-MACRO-DELETE - // Will never get user params with service, macro will have - // to query the SI in AAI to find related instances. - traverseAAIService(execution, resourceList, resourceId, aaiResourceIds); - } else if (resourceType == WorkflowType.SERVICE - && "deactivateInstance".equalsIgnoreCase(requestAction)) { - resourceList.add(new Resource(WorkflowType.SERVICE, "", false)); - } else if (resourceType == WorkflowType.VNF && (REPLACEINSTANCE.equalsIgnoreCase(requestAction) - || ("recreateInstance".equalsIgnoreCase(requestAction)))) { - traverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(), - workflowResourceIds.getVnfId(), aaiResourceIds); - } else if (resourceType == WorkflowType.VNF && "updateInstance".equalsIgnoreCase(requestAction)) { - customTraverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(), - workflowResourceIds.getVnfId(), aaiResourceIds); - } else { - buildAndThrowException(execution, "Current Macro Request is not supported"); - } - StringBuilder foundObjects = new StringBuilder(); - for (WorkflowType type : WorkflowType.values()) { - foundObjects.append(type).append(" - ").append( - (int) resourceList.stream().filter(x -> type.equals(x.getResourceType())).count()) - .append(" "); - } - logger.info("Found {}", foundObjects); - - if (orchFlows == null || orchFlows.isEmpty()) { - orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, isALaCarte, - cloudOwner, serviceType); - } - boolean vnfReplace = false; - if (resourceType.equals(WorkflowType.VNF) && (REPLACEINSTANCE.equalsIgnoreCase(requestAction) - || REPLACEINSTANCERETAINASSIGNMENTS.equalsIgnoreCase(requestAction))) { - vnfReplace = true; - } - flowsToExecute = executeBuildingBlockBuilder.buildExecuteBuildingBlockList(orchFlows, resourceList, - requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, - requestDetails, vnfReplace); - if (isNetworkCollectionInTheResourceList(resourceList)) { - logger.info("Sorting for Vlan Tagging"); - flowsToExecute = sortExecutionPathByObjectForVlanTagging(flowsToExecute, requestAction); - } - // By default, enable homing at VNF level for CREATE_INSTANCE and ASSIGNINSTANCE - if (resourceType == WorkflowType.SERVICE - && (requestAction.equals(CREATE_INSTANCE) || requestAction.equals(ASSIGNINSTANCE)) - && resourceList.stream().anyMatch(x -> WorkflowType.VNF.equals(x.getResourceType()))) { - execution.setVariable(HOMING, true); - execution.setVariable("calledHoming", false); - } - if (resourceType == WorkflowType.SERVICE && (requestAction.equalsIgnoreCase(ASSIGNINSTANCE) - || requestAction.equalsIgnoreCase(CREATE_INSTANCE))) { - generateResourceIds(flowsToExecute, resourceList, serviceInstanceId); - } else { - updateResourceIdsFromAAITraversal(flowsToExecute, resourceList, aaiResourceIds, - serviceInstanceId); - } + flowsToExecute = loadExecuteBuildingBlocksForMacro(sIRequest, resourceType, requestAction, + execution, serviceInstanceId, resourceId, workflowResourceIds, orchFlows, cloudOwner, + serviceType, requestId, apiVersion, vnfType, requestDetails); } } // If the user set "Homing_Solution" to "none", disable homing, else if "Homing_Solution" is specified, @@ -368,6 +240,151 @@ public class WorkflowAction { } } + private List<ExecuteBuildingBlock> loadExecuteBuildingBlocksForAlaCarte(List<OrchestrationFlow> orchFlows, + DelegateExecution execution, String requestAction, WorkflowType resourceType, String cloudOwner, + String serviceType, ServiceInstancesRequest sIRequest, String requestId, + WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, String resourceId, String vnfType, + String apiVersion) throws Exception { + List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); + if (orchFlows == null || orchFlows.isEmpty()) { + orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, true, cloudOwner, + serviceType); + } + Resource resourceKey = getResourceKey(sIRequest, resourceType); + + ReplaceInstanceRelatedInformation replaceInfo = new ReplaceInstanceRelatedInformation(); + if ((requestAction.equalsIgnoreCase(REPLACEINSTANCE) + || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)) + && resourceType.equals(WorkflowType.VFMODULE)) { + logger.debug("Build a BB list for replacing BB modules"); + ConfigBuildingBlocksDataObject cbbdo = createConfigBuildingBlocksDataObject(execution, sIRequest, requestId, + workflowResourceIds, requestDetails, requestAction, resourceId, vnfType, orchFlows, apiVersion, + resourceKey, replaceInfo); + orchFlows = getVfModuleReplaceBuildingBlocks(cbbdo); + + createBuildingBlocksForOrchFlows(execution, sIRequest, requestId, workflowResourceIds, requestDetails, + requestAction, resourceId, flowsToExecute, vnfType, orchFlows, apiVersion, resourceKey, + replaceInfo); + } else { + if (isConfiguration(orchFlows) && !requestAction.equalsIgnoreCase(CREATE_INSTANCE)) { + addConfigBuildingBlocksToFlowsToExecuteList(execution, sIRequest, requestId, workflowResourceIds, + requestDetails, requestAction, resourceId, flowsToExecute, vnfType, apiVersion, resourceKey, + replaceInfo, orchFlows); + } + orchFlows = orchFlows.stream().filter(item -> !item.getFlowName().contains(FABRIC_CONFIGURATION)) + .collect(Collectors.toList()); + + for (OrchestrationFlow orchFlow : orchFlows) { + ExecuteBuildingBlock ebb = executeBuildingBlockBuilder.buildExecuteBuildingBlock(orchFlow, requestId, + resourceKey, apiVersion, resourceId, requestAction, true, vnfType, workflowResourceIds, + requestDetails, false, null, null, false, replaceInfo); + flowsToExecute.add(ebb); + } + } + return flowsToExecute; + } + + private List<ExecuteBuildingBlock> loadExecuteBuildingBlocksForMacro(ServiceInstancesRequest sIRequest, + WorkflowType resourceType, String requestAction, DelegateExecution execution, String serviceInstanceId, + String resourceId, WorkflowResourceIds workflowResourceIds, List<OrchestrationFlow> orchFlows, + String cloudOwner, String serviceType, String requestId, String apiVersion, String vnfType, + RequestDetails requestDetails) throws IOException, VrfBondingServiceException { + List<ExecuteBuildingBlock> flowsToExecute; + boolean containsService = false; + List<Resource> resourceList = new ArrayList<>(); + List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>(); + List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters().getUserParams(); + if (resourceType == WorkflowType.SERVICE && requestAction.equalsIgnoreCase(ASSIGNINSTANCE)) { + // SERVICE-MACRO-ASSIGN will always get user params with a + // service. + + if (userParams != null) { + containsService = isContainsService(sIRequest); + if (containsService) { + resourceList = userParamsServiceTraversal.getResourceListFromUserParams(execution, userParams, + serviceInstanceId, requestAction); + } + } else { + buildAndThrowException(execution, + "Service-Macro-Assign request details must contain user params with a service"); + } + } else if (resourceType == WorkflowType.SERVICE && requestAction.equalsIgnoreCase(CREATE_INSTANCE)) { + // SERVICE-MACRO-CREATE will get user params with a service, + // a service with a network, a service with a + // network collection, OR an empty service. + // If user params is just a service or null and macro + // queries the SI and finds a VNF, macro fails. + + if (userParams != null) { + containsService = isContainsService(sIRequest); + } + if (containsService) { + resourceList = userParamsServiceTraversal.getResourceListFromUserParams(execution, userParams, + serviceInstanceId, requestAction); + } + if (!foundRelated(resourceList)) { + traverseCatalogDbService(execution, sIRequest, resourceList, aaiResourceIds); + } + } else if (resourceType == WorkflowType.SERVICE && ("activateInstance".equalsIgnoreCase(requestAction) + || "unassignInstance".equalsIgnoreCase(requestAction) + || "deleteInstance".equalsIgnoreCase(requestAction) + || requestAction.equalsIgnoreCase("activate" + FABRIC_CONFIGURATION))) { + // SERVICE-MACRO-ACTIVATE, SERVICE-MACRO-UNASSIGN, and + // SERVICE-MACRO-DELETE + // Will never get user params with service, macro will have + // to query the SI in AAI to find related instances. + traverseAAIService(execution, resourceList, resourceId, aaiResourceIds); + } else if (resourceType == WorkflowType.SERVICE && "deactivateInstance".equalsIgnoreCase(requestAction)) { + resourceList.add(new Resource(WorkflowType.SERVICE, "", false)); + } else if (resourceType == WorkflowType.VNF && (REPLACEINSTANCE.equalsIgnoreCase(requestAction) + || ("recreateInstance".equalsIgnoreCase(requestAction)))) { + traverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(), + workflowResourceIds.getVnfId(), aaiResourceIds); + } else if (resourceType == WorkflowType.VNF && "updateInstance".equalsIgnoreCase(requestAction)) { + customTraverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(), + workflowResourceIds.getVnfId(), aaiResourceIds); + } else { + buildAndThrowException(execution, "Current Macro Request is not supported"); + } + StringBuilder foundObjects = new StringBuilder(); + for (WorkflowType type : WorkflowType.values()) { + foundObjects.append(type).append(" - ") + .append((int) resourceList.stream().filter(x -> type.equals(x.getResourceType())).count()) + .append(" "); + } + logger.info("Found {}", foundObjects); + + if (orchFlows == null || orchFlows.isEmpty()) { + orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, false, cloudOwner, + serviceType); + } + boolean vnfReplace = false; + if (resourceType.equals(WorkflowType.VNF) && (REPLACEINSTANCE.equalsIgnoreCase(requestAction) + || REPLACEINSTANCERETAINASSIGNMENTS.equalsIgnoreCase(requestAction))) { + vnfReplace = true; + } + flowsToExecute = executeBuildingBlockBuilder.buildExecuteBuildingBlockList(orchFlows, resourceList, requestId, + apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, vnfReplace); + if (isNetworkCollectionInTheResourceList(resourceList)) { + logger.info("Sorting for Vlan Tagging"); + flowsToExecute = sortExecutionPathByObjectForVlanTagging(flowsToExecute, requestAction); + } + // By default, enable homing at VNF level for CREATE_INSTANCE and ASSIGNINSTANCE + if (resourceType == WorkflowType.SERVICE + && (requestAction.equals(CREATE_INSTANCE) || requestAction.equals(ASSIGNINSTANCE)) + && resourceList.stream().anyMatch(x -> WorkflowType.VNF.equals(x.getResourceType()))) { + execution.setVariable(HOMING, true); + execution.setVariable("calledHoming", false); + } + if (resourceType == WorkflowType.SERVICE && (requestAction.equalsIgnoreCase(ASSIGNINSTANCE) + || requestAction.equalsIgnoreCase(CREATE_INSTANCE))) { + generateResourceIds(flowsToExecute, resourceList, serviceInstanceId); + } else { + updateResourceIdsFromAAITraversal(flowsToExecute, resourceList, aaiResourceIds, serviceInstanceId); + } + return flowsToExecute; + } + private void setExecutionVariables(DelegateExecution execution, List<ExecuteBuildingBlock> flowsToExecute, List<String> flowNames) { execution.setVariable("flowNames", flowNames); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAITest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAITest.java index 35a5bfefd7..7ac245d0f4 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAITest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAITest.java @@ -56,7 +56,8 @@ public class WorkflowActionExtractResourcesAAITest { public void extractRelationshipsConfigurationSuccess() { // given Relationships relationships = mock(Relationships.class); - when(relationships.getByType(Types.CONFIGURATION)).thenReturn(getConfigurationList()); + when(relationships.getByType(Types.CONFIGURATION)) + .thenReturn(getConfigurationList("{\"configuration-id\" : \"" + CONFIGURATION_ID + "\"}")); // when Optional<Configuration> resultOpt = testedObject.extractRelationshipsConfiguration(relationships); // then @@ -65,7 +66,18 @@ public class WorkflowActionExtractResourcesAAITest { } @Test - public void extractRelationshipsConfiguration_notFound() { + public void extractRelationshipsConfiguration_noConfigurationFoundInList() { + // given + Relationships relationships = mock(Relationships.class); + when(relationships.getByType(Types.CONFIGURATION)).thenReturn(getConfigurationList("noJson")); + // when + Optional<Configuration> resultOpt = testedObject.extractRelationshipsConfiguration(relationships); + // then + assertThat(resultOpt).isEmpty(); + } + + @Test + public void extractRelationshipsConfiguration_notFound_listEmpty() { // given Relationships relationships = mock(Relationships.class); when(relationships.getByType(Types.CONFIGURATION)).thenReturn(Collections.emptyList()); @@ -92,10 +104,71 @@ public class WorkflowActionExtractResourcesAAITest { assertThat(resultOpt.get().getVpnId()).isEqualTo(VPN_ID); } - private List<AAIResultWrapper> getConfigurationList() { + @Test + public void extractRelationshipsVpnBinding_noVpnBindingFoundInList() { + // given + Relationships relationships = mock(Relationships.class); + AAIResourceUri aaiResourceUri = mock(AAISimpleUri.class); + List<AAIResourceUri> aaiResourceUriList = new ArrayList<>(); + aaiResourceUriList.add(aaiResourceUri); + when(relationships.getRelatedUris(Types.VPN_BINDING)).thenReturn(aaiResourceUriList); + AAIResultWrapper aaiResultWrapper = new AAIResultWrapper("noJson"); + when(bbInputSetupUtils.getAAIResourceDepthOne(aaiResourceUri)).thenReturn(aaiResultWrapper); + // when + Optional<VpnBinding> resultOpt = testedObject.extractRelationshipsVpnBinding(relationships); + // then + assertThat(resultOpt).isEmpty(); + } + + @Test + public void extractRelationshipsVpnBinding_notFound_listEmpty() { + // given + Relationships relationships = mock(Relationships.class); + when(relationships.getRelatedUris(Types.VPN_BINDING)).thenReturn(Collections.emptyList()); + // when + Optional<VpnBinding> resultOpt = testedObject.extractRelationshipsVpnBinding(relationships); + // then + assertThat(resultOpt).isEmpty(); + } + + @Test + public void extractRelationshipsVnfcSuccess() { + // given + Relationships relationships = mock(Relationships.class); + when(relationships.getByType(Types.VNFC)).thenReturn( + getConfigurationList("{\"relationship-list\": {\"relationship\": [{\"related-to\": \"tenant\"}]}}")); + // when + Optional<Relationships> resultOpt = testedObject.extractRelationshipsVnfc(relationships); + // then + assertThat(resultOpt).isNotEmpty(); + assertThat(resultOpt.get().getJson()).isEqualTo("{\"relationship\":[{\"related-to\":\"tenant\"}]}"); + } + + @Test + public void extractRelationshipsVnfc_noRelationFoundList() { + // given + Relationships relationships = mock(Relationships.class); + when(relationships.getByType(Types.VNFC)).thenReturn(getConfigurationList("{\"jsonWithNoRelation\": {}}")); + // when + Optional<Relationships> resultOpt = testedObject.extractRelationshipsVnfc(relationships); + // then + assertThat(resultOpt).isEmpty(); + } + + @Test + public void extractRelationshipsVnfc_notFound_listEmpty() { + // given + Relationships relationships = mock(Relationships.class); + when(relationships.getByType(Types.VNFC)).thenReturn(Collections.emptyList()); + // when + Optional<Relationships> resultOpt = testedObject.extractRelationshipsVnfc(relationships); + // then + assertThat(resultOpt).isEmpty(); + } + + private List<AAIResultWrapper> getConfigurationList(String json) { List<AAIResultWrapper> configurations = new ArrayList<>(); - AAIResultWrapper aaiResultWrapper = - new AAIResultWrapper("{\"configuration-id\" : \"" + CONFIGURATION_ID + "\"}"); + AAIResultWrapper aaiResultWrapper = new AAIResultWrapper(json); configurations.add(aaiResultWrapper); return configurations; } |