diff options
Diffstat (limited to 'bpmn')
31 files changed, 633 insertions, 290 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/db/PostCompletionRequestsDbListener.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/db/PostCompletionRequestsDbListener.java new file mode 100644 index 0000000000..f888e5333a --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/db/PostCompletionRequestsDbListener.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common.listener.db; + +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.db.request.beans.InfraActiveRequests; + +public interface PostCompletionRequestsDbListener { + + public boolean shouldRunFor(BuildingBlockExecution execution); + + public void run(InfraActiveRequests request, BuildingBlockExecution execution); + + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/db/RequestsDbListenerRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/db/RequestsDbListenerRunner.java new file mode 100644 index 0000000000..68cda5c22b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/db/RequestsDbListenerRunner.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.common.listener.db; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import javax.annotation.PostConstruct; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.ListenerRunner; +import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner; +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +@Component +public class RequestsDbListenerRunner extends ListenerRunner { + + + private static Logger logger = LoggerFactory.getLogger(FlowManipulatorListenerRunner.class); + + protected List<PostCompletionRequestsDbListener> postListeners; + + @PostConstruct + protected void init() { + + postListeners = + new ArrayList<>(Optional.ofNullable(context.getBeansOfType(PostCompletionRequestsDbListener.class)) + .orElse(new HashMap<>()).values()); + + } + + public void post(InfraActiveRequests request, BuildingBlockExecution execution) { + + List<PostCompletionRequestsDbListener> filtered = + filterListeners(postListeners, (item -> item.shouldRunFor(execution))); + + logger.info("Running post request db listeners:\n{}", + filtered.stream().map(item -> item.getClass().getName()).collect(Collectors.joining("\n"))); + filtered.forEach(item -> item.run(request, execution)); + + } + +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java index b814d6c595..8d02fa3e4f 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java @@ -113,7 +113,17 @@ public class ResourceRequestBuilder { if (resource.getResourceType() == ResourceType.VNF) { for (String eachResource : resourceList) { String resCusUuid = JsonUtils.getJsonValue(eachResource, "resourceCustomizationUuid"); - if ((null != resCusUuid) && resCusUuid.equals(resource.getModelInfo().getModelCustomizationUuid())) { + // in case of external api invocation customizatoin id is coming null + if (resCusUuid == null || resCusUuid.contains("null") || resCusUuid.isEmpty()) { + logger.info("resource resolved using model uuid"); + String uuid = (String) JsonUtils.getJsonValue(eachResource, "resourceUuid"); + if ((null != uuid) && uuid.equals(resource.getModelInfo().getModelUuid())) { + logger.info("found resource uuid" + uuid); + String resourceParameters = JsonUtils.getJsonValue(eachResource, "parameters"); + locationConstraints = JsonUtils.getJsonValue(resourceParameters, "locationConstraints"); + } + } else if (resCusUuid.equals(resource.getModelInfo().getModelCustomizationUuid())) { + logger.info("resource resolved using customization-id"); String resourceParameters = JsonUtils.getJsonValue(eachResource, "parameters"); locationConstraints = JsonUtils.getJsonValue(resourceParameters, "locationConstraints"); } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java index e8e4b85cae..ace6e1937d 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java @@ -101,7 +101,7 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { try { MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, getRequestId(inputVariables)); processor.startProcess(processKey, variableMap); - WorkflowResponse response = waitForResponse(getRequestId(inputVariables)); + WorkflowResponse response = waitForResponse(inputVariables); return Response.status(202).entity(response).build(); } catch (WorkflowProcessorException e) { WorkflowResponse response = e.getWorkflowResponse(); @@ -112,9 +112,12 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { } } - private WorkflowResponse waitForResponse(String requestId) throws Exception { + private WorkflowResponse waitForResponse(Map<String, Object> inputVariables) throws Exception { + String requestId = getRequestId(inputVariables); long currentWaitTime = 0; - while (DEFAULT_WAIT_TIME > currentWaitTime) { + long waitTime = getWaitTime(inputVariables); + logger.debug("WorkflowAsyncResource.waitForResponse using timeout: " + waitTime); + while (waitTime > currentWaitTime) { Thread.sleep(workflowPollInterval); currentWaitTime = currentWaitTime + workflowPollInterval; WorkflowContext foundContext = contextHolder.getWorkflowContext(requestId); @@ -123,7 +126,7 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { return buildResponse(foundContext); } } - throw new Exception("TimeOutOccured"); + throw new Exception("TimeOutOccured in WorkflowAsyncResource.waitForResponse for time " + waitTime + "ms"); } private WorkflowResponse buildUnkownError(String requestId, String error) { @@ -171,4 +174,25 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { return inputVariables; } + /** + * Returns the wait time, this is used by the resource on how long it should wait to send a response If none + * specified DEFAULT_WAIT_TIME is used + * + * @param inputVariables + * @return + */ + private long getWaitTime(Map<String, Object> inputVariables) { + String timeout = inputVariables.get("mso-service-request-timeout") == null ? null + : inputVariables.get("mso-service-request-timeout").toString(); + + if (timeout != null) { + try { + return Long.parseLong(timeout) * 1000; + } catch (NumberFormatException nex) { + logger.debug("Invalid input for mso-service-request-timeout"); + } + } + return DEFAULT_WAIT_TIME; + } + } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java index 20f3eb4fee..bcc3739c32 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java @@ -116,7 +116,7 @@ public class WorkflowResource extends ProcessEngineAwareService { long timeToWaitAfterProcessEnded = uriInfo == null ? 5000 : 60000; AtomicLong timeProcessEnded = new AtomicLong(0); boolean endedWithNoResponse = false; - + logger.debug(LOGMARKER + "WorkflowResource.startProcessInstanceByKey using timeout: " + waitTime); while (now <= endTime) { Thread.sleep(pollingInterval); diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy index 044f0b462b..8bb48a203b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy @@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.scripts +import com.google.gson.JsonObject import org.json.JSONArray import org.json.JSONObject import org.json.XML @@ -93,11 +94,12 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso // set local resourceInput execution.setVariable(Prefix + "ResourceInput", resourceInputObj) + String spPartnerModelName = UrnPropertiesReader.getVariable("sp-partner.modelName") boolean is3rdONAPExist = false - if(inputParameters.has("sppartner_url")) + if(inputParameters.has(spPartnerModelName + "_url")) { - String sppartnerUrl = inputParameters.get("sppartner_url") + String sppartnerUrl = inputParameters.get(spPartnerModelName + "_url") if(!isBlank(sppartnerUrl)) { execution.setVariable(Prefix + "SppartnerUrl", sppartnerUrl) is3rdONAPExist = true @@ -108,9 +110,9 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso logger.debug(msg) } } - if(inputParameters.has("sppartner_providingServiceUuid")) + if(inputParameters.has(spPartnerModelName + "_providingServiceUuid")) { - String sppartnerUUID= inputParameters.get("sppartner_providingServiceUuid") + String sppartnerUUID= inputParameters.get(spPartnerModelName + "_providingServiceUuid") execution.setVariable(Prefix + "SppartnerUUID", sppartnerUUID) is3rdONAPExist = true } @@ -119,9 +121,9 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso String msg = "sppartner providingServiceUuid is blank." logger.debug(msg) } - if(inputParameters.has("sppartner_providingServiceInvariantUuid")) + if(inputParameters.has(spPartnerModelName + "_providingServiceInvariantUuid")) { - String sppartnerInvarianteUUID = inputParameters.get("sppartner_providingServiceInvariantUuid") + String sppartnerInvarianteUUID = inputParameters.get(spPartnerModelName + "_providingServiceInvariantUuid") execution.setVariable(Prefix + "SppartnerInvarianteUUID", sppartnerInvarianteUUID) is3rdONAPExist = true } @@ -131,9 +133,9 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso logger.debug(msg) } - if(inputParameters.has("sppartner_handoverMode")) + if(inputParameters.has(spPartnerModelName + "_handoverMode")) { - String handoverMode = inputParameters.get("sppartner_handoverMode") + String handoverMode = inputParameters.get(spPartnerModelName + "_handoverMode") execution.setVariable(Prefix + "HandoverMode", handoverMode) is3rdONAPExist = true } @@ -167,7 +169,7 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso String serviceParameters = JsonUtils.getJsonValue(incomingRequest, "service.parameters") String requestInputs = JsonUtils.getJsonValue(serviceParameters, "requestInputs") JSONObject inputParameters = new JSONObject(requestInputs) - execution.setVariable(Prefix + "ServiceParameters", inputParameters) + execution.setVariable(Prefix + "ServiceParameters", inputParameters.toString()) // CallSource is added only when ONAP SO calling 3rdONAP(External API) SO(Remote call) boolean isLocalCall = true @@ -182,7 +184,7 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso } } execution.setVariable(Prefix + "CallSource", callSource) - logger.debug("callSource is: " + callSource ) + logger.info("callSource is: " + callSource ) execution.setVariable("IsLocalCall", isLocalCall) @@ -308,39 +310,39 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso String handoverMode = execution.getVariable(Prefix + "HandoverMode") if("SOTN".equalsIgnoreCase(handoverMode)) { // Put TP Link info into serviceParameters - JSONObject inputParameters = execution.getVariable(Prefix + "ServiceParameters") + JSONObject inputParameters = new JSONObject(execution.getVariable(Prefix + "ServiceParameters")) if(inputParameters.has("remote-access-provider-id")) { Map<String, Object> crossTPs = new HashMap<String, Object>(); - crossTPs.put("local-access-provider-id", inputParameters.get("remote-access-provider-id")); - crossTPs.put("local-access-client-id", inputParameters.get("remote-access-client-id")); - crossTPs.put("local-access-topology-id", inputParameters.get("remote-access-topology-id")); - crossTPs.put("local-access-node-id", inputParameters.get("remote-access-node-id")); - crossTPs.put("local-access-ltp-id", inputParameters.get("remote-access-ltp-id")); - crossTPs.put("remote-access-provider-id", inputParameters.get("local-access-provider-id")); - crossTPs.put("remote-access-client-id", inputParameters.get("local-access-client-id")); - crossTPs.put("remote-access-topology-id", inputParameters.get("local-access-topology-id")); - crossTPs.put("remote-access-node-id", inputParameters.get("local-access-node-id")); - crossTPs.put("remote-access-ltp-id", inputParameters.get("local-access-ltp-id")); - - inputParameters.put("local-access-provider-id", crossTPs.get("local-access-provider-id")); - inputParameters.put("local-access-client-id", crossTPs.get("local-access-client-id")); - inputParameters.put("local-access-topology-id", crossTPs.get("local-access-topology-id")); - inputParameters.put("local-access-node-id", crossTPs.get("local-access-node-id")); - inputParameters.put("local-access-ltp-id", crossTPs.get("local-access-ltp-id")); - inputParameters.put("remote-access-provider-id", crossTPs.get("remote-access-provider-id")); - inputParameters.put("remote-access-client-id", crossTPs.get("remote-access-client-id")); - inputParameters.put("remote-access-topology-id", crossTPs.get("remote-access-topology-id")); - inputParameters.put("remote-access-node-id", crossTPs.get("remote-access-node-id")); - inputParameters.put("remote-access-ltp-id", crossTPs.get("remote-access-ltp-id")); - - execution.setVariable(Prefix + "ServiceParameters", inputParameters) + crossTPs.put("local-access-provider-id", inputParameters.get("remote-access-provider-id")) + crossTPs.put("local-access-client-id", inputParameters.get("remote-access-client-id")) + crossTPs.put("local-access-topology-id", inputParameters.get("remote-access-topology-id")) + crossTPs.put("local-access-node-id", inputParameters.get("remote-access-node-id")) + crossTPs.put("local-access-ltp-id", inputParameters.get("remote-access-ltp-id")) + crossTPs.put("remote-access-provider-id", inputParameters.get("local-access-provider-id")) + crossTPs.put("remote-access-client-id", inputParameters.get("local-access-client-id")) + crossTPs.put("remote-access-topology-id", inputParameters.get("local-access-topology-id")) + crossTPs.put("remote-access-node-id", inputParameters.get("local-access-node-id")) + crossTPs.put("remote-access-ltp-id", inputParameters.get("local-access-ltp-id")) + + inputParameters.put("local-access-provider-id", crossTPs.get("local-access-provider-id")) + inputParameters.put("local-access-client-id", crossTPs.get("local-access-client-id")) + inputParameters.put("local-access-topology-id", crossTPs.get("local-access-topology-id")) + inputParameters.put("local-access-node-id", crossTPs.get("local-access-node-id")) + inputParameters.put("local-access-ltp-id", crossTPs.get("local-access-ltp-id")) + inputParameters.put("remote-access-provider-id", crossTPs.get("remote-access-provider-id")) + inputParameters.put("remote-access-client-id", crossTPs.get("remote-access-client-id")) + inputParameters.put("remote-access-topology-id", crossTPs.get("remote-access-topology-id")) + inputParameters.put("remote-access-node-id", crossTPs.get("remote-access-node-id")) + inputParameters.put("remote-access-ltp-id", crossTPs.get("remote-access-ltp-id")) + + execution.setVariable(Prefix + "ServiceParameters", inputParameters.toString()) } else { logger.error("No allocated CrossONAPResource found in ServiceParameters") } } - logger.info("Exit " + allocateCrossONAPResource) + logger.info("Exit allocateCrossONAPResource") } public void prepare3rdONAPRequest(DelegateExecution execution) { @@ -409,7 +411,7 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso _requestInputs_ += ",\n" + externalAPIUtil.setTemplate(ExternalAPIUtil.RequestInputsTemplate, requestInputsMap) // Transfer all uuiRequest incomeParameters to ExternalAPI format - JSONObject inputParameters = execution.getVariable(Prefix + "ServiceParameters") + JSONObject inputParameters = new JSONObject(execution.getVariable(Prefix + "ServiceParameters")) for(String key : inputParameters.keySet()) { String inputName = key String inputValue = inputParameters.opt(key) @@ -506,7 +508,7 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso } JSONArray items = responseObj.getJSONArray("orderItem") - JSONObject item = items[0] + JSONObject item = items.get(0) JSONObject service = item.get("service") String sppartnerServiceId = service.get("id") if(sppartnerServiceId == null || sppartnerServiceId.equals("null")) { @@ -572,7 +574,9 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso */ public void timeDelay(DelegateExecution execution) { try { + logger.debug("going to sleep for 5 sec") Thread.sleep(5000) + logger.debug("wakeup after 5 sec") } catch(InterruptedException e) { logger.error("Time Delay exception" + e) } @@ -601,6 +605,8 @@ public class Create3rdONAPE2EServiceInstance extends AbstractServiceTaskProcesso AAIResourcesClient client = new AAIResourcesClient() AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SP_PARTNER, sppartnerId) + logger.info("sending request to create sp-partner: " + uri.toString()) + logger.info("requestbody: " + partner) client.create(uri, partner) AAIResourceUri siUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, serviceInstanceId) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy index b0419be7cb..bcd33530b1 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy @@ -276,9 +276,10 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { case ~/[\w\s\W]*sdwanvpnattachment[\w\s\W]*/ : case ~/[\w\s\W]*sotnvpnattachment[\w\s\W]*/ : + case ~/[\w\s\W]*SOTN-Attachment[\w\s\W]*/ : // fill attachment TP in networkInputParamJson - def vpnName = StringUtils.containsIgnoreCase(modelName, "sotnvpnattachment") ? "sotnvpnattachmentvf_sotncondition_sotnVpnName" : "sdwanvpnattachmentvf_sdwancondition_sdwanVpnName" - fillAttachmentTPInfo(resourceInputObj, modelName, execution, vpnName) + def vpnName = StringUtils.containsIgnoreCase(modelName, "sotnvpnattachment") ? "sotnvpnattachmentvf_sotncondition_sotnVpnName" : (StringUtils.containsIgnoreCase(modelName, "SOTN-Attachment") ? "elinesotnattachmentvf0_elinesotnattachmentvfc0_sotnVpnName" : "sdwanvpnattachmentvf_sdwancondition_sdwanVpnName") + fillAttachmentTPInfo(resourceInputObj, execution, vpnName) break default: @@ -286,27 +287,36 @@ public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor { // in case name is different as expected if ("ALLOTTED_RESOURCE".equals(resourceInputObj.getResourceModelInfo().getModelType())) { def vpnName = modelName + "_sotnVpnName" - fillAttachmentTPInfo(resourceInputObj, modelName, execution, vpnName) + fillAttachmentTPInfo(resourceInputObj, execution, vpnName) } break } return resourceInputObj } - private void fillAttachmentTPInfo(ResourceInput resourceInputObj, String modelName, DelegateExecution execution, String vpnName) { - String customer = resourceInputObj.getGlobalSubscriberId() - String serviceType = resourceInputObj.getServiceType() + private void fillAttachmentTPInfo(ResourceInput resourceInputObj, DelegateExecution execution, String vpnName) { String parentServiceName = jsonUtil.getJsonValueForKey(resourceInputObj.getRequestsInputs(), vpnName) AAIResourcesClient client = new AAIResourcesClient() - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.SERVICE_INSTANCE, customer, serviceType).queryParam("service-instance-name", parentServiceName) - ServiceInstances sis = client.get(uri).asBean(ServiceInstances.class).get() - logger.debug("Fetched AAI ServiceInstances for the vpnName:" + vpnName + " is " + sis.getServiceInstance().toString()) - ServiceInstance si = sis.getServiceInstance().get(0) - - def parentServiceInstanceId = si.getServiceInstanceId() - execution.setVariable("parentServiceInstanceId", parentServiceInstanceId) + logger.info("sending request to resolve vpn-name:" + vpnName) + AAIResourceUri uri = AAIUriFactory.createResourceUri(new AAIObjectPlurals("/nodes", "/service-instances", "queryByName")).queryParam("service-instance-name", parentServiceName) + Optional<ServiceInstances> serviceInstancesOpt = client.get(ServiceInstances.class, uri) + + if(serviceInstancesOpt.isPresent()) { + List<ServiceInstance> serviceInstanceList = serviceInstancesOpt.get().getServiceInstance() + logger.info("response from aai:" + serviceInstanceList.toString()) + if (serviceInstanceList.size() > 0) { + ServiceInstance si = serviceInstanceList.get(0) + String parentServiceInstanceId = si.getServiceInstanceId() + execution.setVariable("parentServiceInstanceId", parentServiceInstanceId) + logger.info("setting parentService id:" + parentServiceInstanceId) + } else { + logger.error("No service instance found for given name.") + } + } else { + logger.error("No nodes found with this name" + vpnName) + } } /** diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy index d9f9299616..0191439dac 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy @@ -584,6 +584,13 @@ public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { List<Resource> addResourceList = serviceDecomposition.getServiceResources() execution.setVariable("addResourceList", addResourceList) + boolean isCreateResourceListValid = true + if (addResourceList == null || addResourceList.isEmpty()) { + isCreateResourceListValid = false + } + + execution.setVariable("isCreateResourceListValid", isCreateResourceListValid) + logger.trace("COMPLETED preProcessForAddResource Process ") } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy index 21f9484cbc..df8735aaaa 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy @@ -267,7 +267,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "queryAAIResponse", l3Network.get()) execution.setVariable(Prefix + "isAAIGood", true) if (relationships.isPresent()){ - if(relationships.get().getRelatedAAIUris(AAIObjectType.VF_MODULE).isEmpty()){ + if(!relationships.get().getRelatedAAIUris(AAIObjectType.VF_MODULE).isEmpty()){ execution.setVariable(Prefix + "isVfRelationshipExist", true) isVfRelationshipExist = true String relationshipMessage = "AAI Query Success Response but 'vf-module' relationship exist, not allowed to delete: network Id: " + networkId diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java index 9319353e5a..95be6ba7fc 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java @@ -29,6 +29,7 @@ import java.io.IOException; import java.io.InputStream; import java.net.SocketTimeoutException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -56,6 +57,8 @@ import org.camunda.bpm.engine.runtime.Execution; import org.onap.aai.domain.yang.LogicalLink; import org.onap.aai.domain.yang.LogicalLinks; import org.onap.aai.domain.yang.PInterface; +import org.onap.aai.domain.yang.Pnf; +import org.onap.aai.domain.yang.Relationship; import org.onap.so.bpmn.core.UrnPropertiesReader; import org.onap.so.bpmn.core.domain.Resource; import org.onap.so.bpmn.core.domain.ServiceDecomposition; @@ -166,8 +169,7 @@ public class ServicePluginFactory { } private boolean isNeedProcessSite(String uuiRequest) { - return uuiRequest.toLowerCase().contains("site_address") - && uuiRequest.toLowerCase().contains("sotncondition_clientsignal"); + return uuiRequest.toLowerCase().contains("address") && uuiRequest.toLowerCase().contains("clientsignal"); } @SuppressWarnings("unchecked") @@ -178,6 +180,7 @@ public class ServicePluginFactory { return true; } String host = (String) tpInfoMap.get("host"); + logger.info("host string from tpinfo:" + host); // host is empty means TP is in local, not empty means TP is in remote ONAP if (!host.isEmpty()) { return false; @@ -191,17 +194,33 @@ public class ServicePluginFactory { accessTPInfo.put("access-ltp-id", tpInfoMap.get("access-ltp-id")); // change resources + boolean flgResourceFound = false; String resourceName = (String) tpInfoMap.get("resourceName"); for (Object curResource : resources) { Map<String, Object> resource = (Map<String, Object>) curResource; String curResourceName = (String) resource.get("resourceName"); curResourceName = curResourceName.replaceAll(" ", ""); if (resourceName.equalsIgnoreCase(curResourceName)) { + flgResourceFound = true; + logger.info("found match to add site tp info using uui template resource name"); putResourceRequestInputs(resource, accessTPInfo); break; } } + if (!flgResourceFound) { + String attacmentResName = UrnPropertiesReader.getVariable("sp-partner.attachment-resource-name"); + for (Object curResource : resources) { + Map<String, Object> resource = (Map<String, Object>) curResource; + String curResourceName = (String) resource.get("resourceName"); + + if (attacmentResName.equals(curResourceName)) { + logger.info("found match to add site tp info using customized resource name"); + putResourceRequestInputs(resource, accessTPInfo); + } + } + } + return true; } @@ -215,10 +234,10 @@ public class ServicePluginFactory { // logic for R2 uuiRequest params in service level for (Entry<String, Object> entry : serviceRequestInputs.entrySet()) { String key = entry.getKey(); - if (key.toLowerCase().contains("site_address")) { + if (key.toLowerCase().contains("address")) { location = entry.getValue(); } - if (key.toLowerCase().contains("sotncondition_clientsignal")) { + if (key.toLowerCase().contains("clientsignal")) { clientSignal = entry.getValue(); vpnAttachmentResourceName = key.substring(0, key.indexOf("_")); } @@ -242,10 +261,12 @@ public class ServicePluginFactory { tpInfoMap = tpJson; // add resourceName tpInfoMap.put("resourceName", vpnAttachmentResourceName); + logger.info("*** we will try to find resourcename(" + vpnAttachmentResourceName + + ") to add resource input ***"); break; } } - logger.debug("Get Terminal TP from InventoryOSS"); + logger.info("Get Terminal TP from InventoryOSS: " + tpInfoMap); return tpInfoMap; } @@ -330,10 +351,40 @@ public class ServicePluginFactory { return false; } + public static String CUSTOM_RESOURCE_TP = "custom-resource-tp"; + public static String VS_MONITORED = "VS_assured"; + public static String VS_UNMONITORED = "VS_besteffort"; + public static String TS_MONITORED = "TS1"; + public static String TS_UNMONITORED = "TS2"; + public static String CUSTOM_TP_LIST[] = new String[] {VS_MONITORED, VS_UNMONITORED, TS_MONITORED, TS_UNMONITORED}; + + private void customizeTP(Map<String, Object> crossTps, String svcName, DelegateExecution execution) { + Optional<String> customType = Arrays.stream(CUSTOM_TP_LIST).filter(svcName::contains).findFirst(); + if (customType.isPresent()) { + logger.info("customizing TP"); + String localTPs = UrnPropertiesReader.getVariable(CUSTOM_RESOURCE_TP + "." + customType.get() + ".local"); + String remoteTPs = UrnPropertiesReader.getVariable(CUSTOM_RESOURCE_TP + "." + customType.get() + ".remote"); + + String localTP = (String) crossTps.get("local-access-ltp-id"); + String remoteTP = (String) crossTps.get("remote-access-ltp-id"); + + if (localTPs.contains(localTP) && remoteTPs.contains(remoteTP)) { + logger.info("using same tp returned from AAI"); + return; + } + + crossTps.put("local-access-ltp-id", localTPs.split(",")[0]); + crossTps.put("remote-access-ltp-id", remoteTPs.split(",")[0]); + } + logger.info("cross TP info:" + crossTps); + } + @SuppressWarnings("unchecked") private void allocateCrossTPResources(DelegateExecution execution, Map<String, Object> serviceRequestInputs) { - Map<String, Object> crossTPs = this.getTPsfromAAI(); + String serviceName = (String) execution.getVariable("serviceInstanceName"); + Map<String, Object> crossTPs = this.getTPsfromAAI(serviceName); + // customizeTP(crossTPs, serviceName, execution); if (crossTPs == null || crossTPs.isEmpty()) { serviceRequestInputs.put("local-access-provider-id", ""); @@ -353,17 +404,45 @@ public class ServicePluginFactory { serviceRequestInputs.put("local-access-node-id", crossTPs.get("local-access-node-id")); serviceRequestInputs.put("local-access-ltp-id", crossTPs.get("local-access-ltp-id")); serviceRequestInputs.put("remote-access-provider-id", crossTPs.get("remote-access-provider-id")); - serviceRequestInputs.put("remote-access-client-id", crossTPs.get("remote-client-id")); - serviceRequestInputs.put("remote-access-topology-id", crossTPs.get("remote-topology-id")); - serviceRequestInputs.put("remote-access-node-id", crossTPs.get("remote-node-id")); - serviceRequestInputs.put("remote-access-ltp-id", crossTPs.get("remote-ltp-id")); + serviceRequestInputs.put("remote-access-client-id", crossTPs.get("remote-access-client-id")); + serviceRequestInputs.put("remote-access-topology-id", crossTPs.get("remote-access-topology-id")); + serviceRequestInputs.put("remote-access-node-id", crossTPs.get("remote-access-node-id")); + serviceRequestInputs.put("remote-access-ltp-id", crossTPs.get("remote-access-ltp-id")); } return; } + private LogicalLink selectLogicalLink(List<LogicalLink> logicalLinks, String svcName) { + Optional<String> customType = Arrays.stream(CUSTOM_TP_LIST).filter(svcName::contains).findFirst(); + if (customType.isPresent()) { + + String[] allowedList = + UrnPropertiesReader.getVariable(CUSTOM_RESOURCE_TP + "." + customType.get() + ".local").split(","); + + for (String localTp : allowedList) { + for (LogicalLink link : logicalLinks) { + for (Relationship relationship : link.getRelationshipList().getRelationship()) { + if (relationship.getRelatedTo().equals("p-interface") + && relationship.getRelatedLink().contains("-ltpId-" + localTp) + && link.getOperationalStatus().equalsIgnoreCase("up")) { + logger.info("linkname:" + link.getLinkName() + " is matching with allowed list"); + return link; + } + } + } + } + + logger.error("There is no matching logical link for allowed list :" + allowedList.toString()); + return null; + } else { + logger.info("link customization is not required"); + return logicalLinks.get(0); + } + } + // This method returns Local and remote TPs information from AAI - public Map getTPsfromAAI() { + public Map getTPsfromAAI(String serviceName) { Map<String, Object> tpInfo = new HashMap<>(); AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.LOGICAL_LINK); @@ -372,11 +451,11 @@ public class ServicePluginFactory { if (result.isPresent()) { LogicalLinks links = result.get(); - boolean isRemoteLink = false; + LogicalLink link = selectLogicalLink(links.getLogicalLink(), serviceName); - links.getLogicalLink(); - - for (LogicalLink link : links.getLogicalLink()) { + if (link != null) { + boolean isRemoteLink = false; + logger.info("processing link :" + link.getLinkName()); AAIResultWrapper wrapper = new AAIResultWrapper(link); Optional<Relationships> optRelationships = wrapper.getRelationships(); List<AAIResourceUri> pInterfaces = new ArrayList<>(); @@ -386,57 +465,85 @@ public class ServicePluginFactory { isRemoteLink = true; } pInterfaces.addAll(relationships.getRelatedAAIUris(AAIObjectType.P_INTERFACE)); - } - - if (isRemoteLink) { - // find remote p interface - AAIResourceUri localTP = null; - AAIResourceUri remoteTP = null; - - AAIResourceUri pInterface0 = pInterfaces.get(0); - - if (isRemotePInterface(client, pInterface0)) { - remoteTP = pInterfaces.get(0); - localTP = pInterfaces.get(1); - } else { - localTP = pInterfaces.get(0); - remoteTP = pInterfaces.get(1); - } - - if (localTP != null && remoteTP != null) { - // give local tp - String tpUrl = localTP.build().toString(); - PInterface intfLocal = client.get(PInterface.class, localTP).get(); - tpInfo.put("local-access-node-id", tpUrl.split("/")[6]); - - String[] networkRef = intfLocal.getNetworkRef().split("/"); - if (networkRef.length == 6) { - tpInfo.put("local-access-provider-id", networkRef[1]); - tpInfo.put("local-access-client-id", networkRef[3]); - tpInfo.put("local-access-topology-id", networkRef[5]); - } - String ltpIdStr = tpUrl.substring(tpUrl.lastIndexOf("/") + 1); - if (ltpIdStr.contains("-")) { - tpInfo.put("local-access-ltp-id", ltpIdStr.substring(ltpIdStr.lastIndexOf("-") + 1)); + if (isRemoteLink) { + // find remote p interface + AAIResourceUri localTP = null; + AAIResourceUri remoteTP = null; + + AAIResourceUri pInterface0 = pInterfaces.get(0); + + if (isRemotePInterface(client, pInterface0)) { + remoteTP = pInterfaces.get(0); + localTP = pInterfaces.get(1); + } else { + localTP = pInterfaces.get(0); + remoteTP = pInterfaces.get(1); } - // give remote tp - tpUrl = remoteTP.build().toString(); - PInterface intfRemote = client.get(PInterface.class, remoteTP).get(); - tpInfo.put("remote-access-node-id", tpUrl.split("/")[6]); - - String[] networkRefRemote = intfRemote.getNetworkRef().split("/"); - - if (networkRefRemote.length == 6) { - tpInfo.put("remote-access-provider-id", networkRefRemote[1]); - tpInfo.put("remote-access-client-id", networkRefRemote[3]); - tpInfo.put("remote-access-topology-id", networkRefRemote[5]); + if (localTP != null && remoteTP != null) { + // give local tp + String tpUrl = localTP.build().toString(); + String localNodeId = tpUrl.split("/")[4]; + tpInfo.put("local-access-node-id", localNodeId); + + logger.info("Get info for local TP :" + localNodeId); + Optional<Pnf> optLocalPnf = client.get(Pnf.class, + AAIUriFactory.createResourceUri(AAIObjectType.PNF, localNodeId)); + + if (optLocalPnf.isPresent()) { + Pnf localPnf = optLocalPnf.get(); + + for (Relationship rel : localPnf.getRelationshipList().getRelationship()) { + if (rel.getRelatedTo().equalsIgnoreCase("network-resource")) { + String[] networkRef = rel.getRelatedLink() + .substring(rel.getRelatedLink().lastIndexOf("/") + 1).split("-"); + if (networkRef.length == 6) { + tpInfo.put("local-access-provider-id", networkRef[1]); + tpInfo.put("local-access-client-id", networkRef[3]); + tpInfo.put("local-access-topology-id", networkRef[5]); + } + } + } + } + String ltpIdStr = tpUrl.substring(tpUrl.lastIndexOf("/") + 1); + if (ltpIdStr.contains("-")) { + tpInfo.put("local-access-ltp-id", ltpIdStr.substring(ltpIdStr.lastIndexOf("-") + 1)); + } + + // give remote tp + tpUrl = remoteTP.build().toString(); + PInterface intfRemote = client.get(PInterface.class, remoteTP).get(); + + String remoteNodeId = tpUrl.split("/")[4]; + tpInfo.put("remote-access-node-id", remoteNodeId); + + logger.info("Get info for remote TP:" + remoteNodeId); + + String[] networkRefRemote = intfRemote.getNetworkRef().split("-"); + Optional<Pnf> optRemotePnf = client.get(Pnf.class, + AAIUriFactory.createResourceUri(AAIObjectType.PNF, remoteNodeId)); + + if (optRemotePnf.isPresent()) { + Pnf remotePnf = optRemotePnf.get(); + + for (Relationship rel : remotePnf.getRelationshipList().getRelationship()) { + if (rel.getRelatedTo().equalsIgnoreCase("network-resource")) { + String[] networkRef = rel.getRelatedLink() + .substring(rel.getRelatedLink().lastIndexOf("/") + 1).split("-"); + if (networkRef.length == 6) { + tpInfo.put("remote-access-provider-id", networkRefRemote[1]); + tpInfo.put("remote-access-client-id", networkRefRemote[3]); + tpInfo.put("remote-access-topology-id", networkRefRemote[5]); + } + } + } + } + + String ltpIdStrR = tpUrl.substring(tpUrl.lastIndexOf("/") + 1); + if (ltpIdStrR.contains("-")) { + tpInfo.put("remote-access-ltp-id", ltpIdStrR.substring(ltpIdStr.lastIndexOf("-") + 1)); + } } - String ltpIdStrR = tpUrl.substring(tpUrl.lastIndexOf("/") + 1); - if (ltpIdStrR.contains("-")) { - tpInfo.put("remote-access-ltp-id", ltpIdStrR.substring(ltpIdStr.lastIndexOf("-") + 1)); - } - return tpInfo; } } } @@ -811,5 +918,4 @@ public class ServicePluginFactory { } } } - } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactoryTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactoryTest.java index 1a75f125f6..6b310773b1 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactoryTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactoryTest.java @@ -110,7 +110,7 @@ public class ServicePluginFactoryTest { @Test public void doTPResourcesAllocation_Success() { - doReturn(null).when(servicePluginFactory).getTPsfromAAI(); + doReturn(null).when(servicePluginFactory).getTPsfromAAI("test"); String result = servicePluginFactory.doTPResourcesAllocation(null, uuiRequest); Assert.assertNotEquals(result, uuiRequest); } diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeActivateSDNCNetworkResource.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeActivateSDNCNetworkResource.bpmn index cfcd259d7c..082860dd65 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeActivateSDNCNetworkResource.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeActivateSDNCNetworkResource.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="2.0.0"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.1.0"> <bpmn:process id="DeActivateSDNCNetworkResource" name="DeActivateSDNCNetworkResource" isExecutable="true"> <bpmn:startEvent id="deleteNetworkResource_StartEvent_deactivate" name="deleteNetworkResource_StartEvent"> <bpmn:outgoing>SequenceFlow_1qo2pln</bpmn:outgoing> @@ -14,9 +14,9 @@ def dcsi = new DeActivateSDNCNetworkResource() dcsi.prepareSDNCRequest(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:endEvent id="EndEvent_1x6k78c_deactivate" name="delete SDNC call end"> - <bpmn:incoming>SequenceFlow_15wux6a</bpmn:incoming> + <bpmn:incoming>SequenceFlow_0ow44q0</bpmn:incoming> </bpmn:endEvent> - <bpmn:sequenceFlow id="SequenceFlow_0ow44q0" sourceRef="Task_023hred_deactivate" targetRef="ScriptTask_1emjxm2_deactivate" /> + <bpmn:sequenceFlow id="SequenceFlow_0ow44q0" sourceRef="Task_023hred_deactivate" targetRef="EndEvent_1x6k78c_deactivate" /> <bpmn:scriptTask id="Task_023hred_deactivate" name="post SDNC deactivate call"> <bpmn:incoming>SequenceFlow_13gl3wv</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0ow44q0</bpmn:outgoing> @@ -39,14 +39,6 @@ dcsi.preProcessRequest(execution)</bpmn:script> def dcsi = new DeActivateSDNCNetworkResource() dcsi.prepareUpdateAfterDeActivateSDNCResource(execution)</bpmn:script> </bpmn:scriptTask> - <bpmn:scriptTask id="ScriptTask_1emjxm2_deactivate" name="Send Sync Ack Response" scriptFormat="groovy"> - <bpmn:incoming>SequenceFlow_0ow44q0</bpmn:incoming> - <bpmn:outgoing>SequenceFlow_15wux6a</bpmn:outgoing> - <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* -def csi = new DeActivateSDNCNetworkResource() -csi.sendSyncResponse(execution)</bpmn:script> - </bpmn:scriptTask> - <bpmn:sequenceFlow id="SequenceFlow_15wux6a" sourceRef="ScriptTask_1emjxm2_deactivate" targetRef="EndEvent_1x6k78c_deactivate" /> <bpmn:sequenceFlow id="SequenceFlow_1fjtgq7" sourceRef="PreprocessIncomingRequest_deactivate" targetRef="Task_0n0lj30_deactivate" /> <bpmn:callActivity id="Task_0n0lj30_deactivate" name="Call SDNC Adapter V1" calledElement="SDNCAdapterRestV1"> <bpmn:incoming>SequenceFlow_1fjtgq7</bpmn:incoming> @@ -98,85 +90,75 @@ csi.sendSyncResponse(execution)</bpmn:script> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="DeActivateSDNCNetworkResource"> <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="deleteNetworkResource_StartEvent_deactivate"> - <dc:Bounds x="-111" y="111" width="36" height="36" /> + <dc:Bounds x="180" y="111" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="-135" y="147" width="88" height="40" /> + <dc:Bounds x="156" y="147" width="88" height="40" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1qo2pln_di" bpmnElement="SequenceFlow_1qo2pln"> - <di:waypoint x="-75" y="129" /> - <di:waypoint x="5" y="129" /> + <di:waypoint x="216" y="129" /> + <di:waypoint x="296" y="129" /> <bpmndi:BPMNLabel> <dc:Bounds x="-87.5" y="108" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_03j6ogo_di" bpmnElement="PreprocessIncomingRequest_deactivate"> - <dc:Bounds x="178" y="89" width="100" height="80" /> + <dc:Bounds x="469" y="89" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_15pcuuc_di" bpmnElement="EndEvent_1x6k78c_deactivate"> - <dc:Bounds x="964" y="327" width="36" height="36" /> + <dc:Bounds x="1255" y="327" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="928" y="369" width="84" height="27" /> + <dc:Bounds x="1219" y="369" width="84" height="27" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0ow44q0_di" bpmnElement="SequenceFlow_0ow44q0"> - <di:waypoint x="735" y="345" /> - <di:waypoint x="795" y="345" /> + <di:waypoint x="1026" y="345" /> + <di:waypoint x="1255" y="345" /> <bpmndi:BPMNLabel> <dc:Bounds x="719" y="314" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_0gyej62_di" bpmnElement="Task_023hred_deactivate"> - <dc:Bounds x="635" y="305" width="100" height="80" /> + <dc:Bounds x="926" y="305" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_18l3crb_di" bpmnElement="SequenceFlow_18l3crb"> - <di:waypoint x="105" y="129" /> - <di:waypoint x="178" y="129" /> + <di:waypoint x="396" y="129" /> + <di:waypoint x="469" y="129" /> <bpmndi:BPMNLabel> <dc:Bounds x="235.5" y="108" width="90" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ScriptTask_14l9mlv_di" bpmnElement="Task_13sx2bp_deactivate"> - <dc:Bounds x="5" y="89" width="100" height="80" /> + <dc:Bounds x="296" y="89" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1kqf4ge_di" bpmnElement="Task_0tezqd4_deactivate"> - <dc:Bounds x="333" y="305" width="100" height="80" /> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="ScriptTask_1emjxm2_di" bpmnElement="ScriptTask_1emjxm2_deactivate"> - <dc:Bounds x="795" y="305" width="100" height="80" /> + <dc:Bounds x="624" y="305" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="SequenceFlow_15wux6a_di" bpmnElement="SequenceFlow_15wux6a"> - <di:waypoint x="895" y="345" /> - <di:waypoint x="964" y="345" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="930" y="313" width="0" height="14" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1fjtgq7_di" bpmnElement="SequenceFlow_1fjtgq7"> <di:waypoint x="278" y="129" /> <di:waypoint x="333" y="129" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_1pzm7qx_di" bpmnElement="SequenceFlow_1pzm7qx"> - <di:waypoint x="433" y="345" /> - <di:waypoint x="487" y="345" /> + <di:waypoint x="724" y="345" /> + <di:waypoint x="778" y="345" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0k4fp1d_di" bpmnElement="Task_1a6f0p9_deactivate"> - <dc:Bounds x="487" y="305" width="100" height="80" /> + <dc:Bounds x="778" y="305" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_13gl3wv_di" bpmnElement="SequenceFlow_13gl3wv"> - <di:waypoint x="587" y="345" /> - <di:waypoint x="635" y="345" /> + <di:waypoint x="878" y="345" /> + <di:waypoint x="926" y="345" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="CallActivity_0a0txik_di" bpmnElement="CallActivity_0a0txik_DeActivate"> - <dc:Bounds x="333" y="89" width="100" height="80" /> + <dc:Bounds x="624" y="89" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0rn8vky_di" bpmnElement="SequenceFlow_0rn8vky"> - <di:waypoint x="383" y="169" /> - <di:waypoint x="383" y="305" /> + <di:waypoint x="674" y="169" /> + <di:waypoint x="674" y="305" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0nmt8ph_di" bpmnElement="SequenceFlow_0nmt8ph"> - <di:waypoint x="278" y="129" /> - <di:waypoint x="333" y="129" /> + <di:waypoint x="569" y="129" /> + <di:waypoint x="624" y="129" /> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/AbstractSDNCTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/AbstractSDNCTask.java new file mode 100644 index 0000000000..c134f31b42 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/AbstractSDNCTask.java @@ -0,0 +1,22 @@ +package org.onap.so.bpmn.infrastructure.sdnc.tasks; + +import java.net.URI; +import javax.ws.rs.core.UriBuilder; +import org.onap.so.client.sdnc.beans.SDNCRequest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; + +@Component +public class AbstractSDNCTask { + + @Autowired + Environment env; + + + public URI buildCallbackURI(SDNCRequest sdncRequest) { + UriBuilder builder = UriBuilder.fromPath(env.getRequiredProperty("mso.workflow.message.endpoint")) + .path(sdncRequest.getCorrelationName()).path(sdncRequest.getCorrelationValue()); + return builder.build(); + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTasks.java index e4dd35503e..b85e33144f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTasks.java @@ -22,8 +22,6 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; -import java.net.URI; -import javax.ws.rs.core.UriBuilder; import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; @@ -52,7 +50,7 @@ import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @Component -public class SDNCActivateTasks { +public class SDNCActivateTasks extends AbstractSDNCTask { public static final String SDNC_REQUEST = "SDNCRequest"; @Autowired @@ -77,9 +75,9 @@ public class SDNCActivateTasks { GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); CloudRegion cloudRegion = gBBInput.getCloudRegion(); Customer customer = gBBInput.getCustomer(); - GenericResourceApiVnfOperationInformation req = - sdncVnfResources.activateVnf(vnf, serviceInstance, customer, cloudRegion, requestContext); SDNCRequest sdncRequest = new SDNCRequest(); + GenericResourceApiVnfOperationInformation req = sdncVnfResources.activateVnf(vnf, serviceInstance, customer, + cloudRegion, requestContext, buildCallbackURI(sdncRequest)); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.VNF); execution.setVariable(SDNC_REQUEST, sdncRequest); @@ -127,11 +125,8 @@ public class SDNCActivateTasks { Customer customer = gBBInput.getCustomer(); CloudRegion cloudRegion = gBBInput.getCloudRegion(); SDNCRequest sdncRequest = new SDNCRequest(); - UriBuilder builder = UriBuilder.fromPath(env.getRequiredProperty("mso.workflow.message.endpoint")) - .path(sdncRequest.getCorrelationName()).path(sdncRequest.getCorrelationValue()); - URI uri = builder.build(); GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.activateVfModule(vfModule, vnf, - serviceInstance, customer, cloudRegion, requestContext, uri); + serviceInstance, customer, cloudRegion, requestContext, buildCallbackURI(sdncRequest)); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.VFMODULE); execution.setVariable(SDNC_REQUEST, sdncRequest); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java index c100cd6cee..ab2647a68d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasks.java @@ -22,8 +22,6 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; -import java.net.URI; -import javax.ws.rs.core.UriBuilder; import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; @@ -55,7 +53,7 @@ import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @Component -public class SDNCAssignTasks { +public class SDNCAssignTasks extends AbstractSDNCTask { private static final Logger logger = LoggerFactory.getLogger(SDNCAssignTasks.class); public static final String SDNC_REQUEST = "SDNCRequest"; @Autowired @@ -100,9 +98,11 @@ public class SDNCAssignTasks { GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); Customer customer = gBBInput.getCustomer(); CloudRegion cloudRegion = gBBInput.getCloudRegion(); - GenericResourceApiVnfOperationInformation req = sdncVnfResources.assignVnf(vnf, serviceInstance, customer, - cloudRegion, requestContext, Boolean.TRUE.equals(vnf.isCallHoming())); SDNCRequest sdncRequest = new SDNCRequest(); + + GenericResourceApiVnfOperationInformation req = + sdncVnfResources.assignVnf(vnf, serviceInstance, customer, cloudRegion, requestContext, + Boolean.TRUE.equals(vnf.isCallHoming()), buildCallbackURI(sdncRequest)); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.VNF); execution.setVariable(SDNC_REQUEST, sdncRequest); @@ -128,11 +128,9 @@ public class SDNCAssignTasks { Customer customer = gBBInput.getCustomer(); CloudRegion cloudRegion = gBBInput.getCloudRegion(); SDNCRequest sdncRequest = new SDNCRequest(); - UriBuilder builder = UriBuilder.fromPath(env.getRequiredProperty("mso.workflow.message.endpoint")) - .path(sdncRequest.getCorrelationName()).path(sdncRequest.getCorrelationValue()); - URI uri = builder.build(); - GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.assignVfModule(vfModule, - volumeGroup, vnf, serviceInstance, customer, cloudRegion, requestContext, uri); + GenericResourceApiVfModuleOperationInformation req = + sdncVfModuleResources.assignVfModule(vfModule, volumeGroup, vnf, serviceInstance, customer, + cloudRegion, requestContext, buildCallbackURI(sdncRequest)); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.VFMODULE); execution.setVariable(SDNC_REQUEST, sdncRequest); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasks.java index acf48acdda..c5ebc5e447 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasks.java @@ -20,8 +20,6 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; -import java.net.URI; -import javax.ws.rs.core.UriBuilder; import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; @@ -49,7 +47,7 @@ import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @Component -public class SDNCChangeAssignTasks { +public class SDNCChangeAssignTasks extends AbstractSDNCTask { public static final String SDNC_REQUEST = "SDNCRequest"; @Autowired private SDNCNetworkResources sdncNetworkResources; @@ -88,9 +86,10 @@ public class SDNCChangeAssignTasks { GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); - GenericResourceApiVnfOperationInformation req = sdncVnfResources.changeModelVnf(genericVnf, serviceInstance, - gBBInput.getCustomer(), gBBInput.getCloudRegion(), gBBInput.getRequestContext()); SDNCRequest sdncRequest = new SDNCRequest(); + GenericResourceApiVnfOperationInformation req = + sdncVnfResources.changeModelVnf(genericVnf, serviceInstance, gBBInput.getCustomer(), + gBBInput.getCloudRegion(), gBBInput.getRequestContext(), buildCallbackURI(sdncRequest)); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.VNF); execution.setVariable(SDNC_REQUEST, sdncRequest); @@ -127,11 +126,8 @@ public class SDNCChangeAssignTasks { VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); Customer customer = gBBInput.getCustomer(); SDNCRequest sdncRequest = new SDNCRequest(); - UriBuilder builder = UriBuilder.fromPath(env.getRequiredProperty("mso.workflow.message.endpoint")) - .path(sdncRequest.getCorrelationName()).path(sdncRequest.getCorrelationValue()); - URI uri = builder.build(); GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.changeAssignVfModule(vfModule, - vnf, serviceInstance, customer, cloudRegion, requestContext, uri); + vnf, serviceInstance, customer, cloudRegion, requestContext, buildCallbackURI(sdncRequest)); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.VFMODULE); execution.setVariable(SDNC_REQUEST, sdncRequest); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTasks.java index 3fc25196e1..3c42f76d73 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTasks.java @@ -22,8 +22,6 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; -import java.net.URI; -import javax.ws.rs.core.UriBuilder; import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; @@ -53,7 +51,7 @@ import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @Component -public class SDNCDeactivateTasks { +public class SDNCDeactivateTasks extends AbstractSDNCTask { public static final String SDNC_REQUEST = "SDNCRequest"; @Autowired @@ -82,11 +80,8 @@ public class SDNCDeactivateTasks { Customer customer = gBBInput.getCustomer(); CloudRegion cloudRegion = gBBInput.getCloudRegion(); SDNCRequest sdncRequest = new SDNCRequest(); - UriBuilder builder = UriBuilder.fromPath(env.getRequiredProperty("mso.workflow.message.endpoint")) - .path(sdncRequest.getCorrelationName()).path(sdncRequest.getCorrelationValue()); - URI uri = builder.build(); GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.deactivateVfModule(vfModule, vnf, - serviceInstance, customer, cloudRegion, requestContext, uri); + serviceInstance, customer, cloudRegion, requestContext, buildCallbackURI(sdncRequest)); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.VFMODULE); execution.setVariable(SDNC_REQUEST, sdncRequest); @@ -111,9 +106,9 @@ public class SDNCDeactivateTasks { vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); CloudRegion cloudRegion = gBBInput.getCloudRegion(); Customer customer = gBBInput.getCustomer(); - GenericResourceApiVnfOperationInformation req = - sdncVnfResources.deactivateVnf(vnf, serviceInstance, customer, cloudRegion, requestContext); SDNCRequest sdncRequest = new SDNCRequest(); + GenericResourceApiVnfOperationInformation req = sdncVnfResources.deactivateVnf(vnf, serviceInstance, + customer, cloudRegion, requestContext, buildCallbackURI(sdncRequest)); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.VNF); execution.setVariable(SDNC_REQUEST, sdncRequest); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java index 4721bf56f1..e3c9785ab2 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasks.java @@ -22,8 +22,6 @@ package org.onap.so.bpmn.infrastructure.sdnc.tasks; -import java.net.URI; -import javax.ws.rs.core.UriBuilder; import org.onap.sdnc.northbound.client.model.GenericResourceApiNetworkOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; @@ -53,7 +51,7 @@ import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @Component -public class SDNCUnassignTasks { +public class SDNCUnassignTasks extends AbstractSDNCTask { public static final String SDNC_REQUEST = "SDNCRequest"; @Autowired @@ -98,11 +96,8 @@ public class SDNCUnassignTasks { RequestContext requestContext = gBBInput.getRequestContext(); VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID); SDNCRequest sdncRequest = new SDNCRequest(); - UriBuilder builder = UriBuilder.fromPath(env.getRequiredProperty("mso.workflow.message.endpoint")) - .path(sdncRequest.getCorrelationName()).path(sdncRequest.getCorrelationValue()); - URI uri = builder.build(); - GenericResourceApiVfModuleOperationInformation req = - sdncVfModuleResources.unassignVfModule(vfModule, vnf, serviceInstance, requestContext, uri); + GenericResourceApiVfModuleOperationInformation req = sdncVfModuleResources.unassignVfModule(vfModule, vnf, + serviceInstance, requestContext, buildCallbackURI(sdncRequest)); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.VFMODULE); execution.setVariable(SDNC_REQUEST, sdncRequest); @@ -120,9 +115,9 @@ public class SDNCUnassignTasks { RequestContext requestContext = gBBInput.getRequestContext(); Customer customer = gBBInput.getCustomer(); CloudRegion cloudRegion = gBBInput.getCloudRegion(); - GenericResourceApiVnfOperationInformation req = - sdncVnfResources.unassignVnf(vnf, serviceInstance, customer, cloudRegion, requestContext); SDNCRequest sdncRequest = new SDNCRequest(); + GenericResourceApiVnfOperationInformation req = sdncVnfResources.unassignVnf(vnf, serviceInstance, customer, + cloudRegion, requestContext, buildCallbackURI(sdncRequest)); sdncRequest.setSDNCPayload(req); sdncRequest.setTopology(SDNCTopology.VNF); execution.setVariable(SDNC_REQUEST, sdncRequest); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index a17556f091..073dead8b3 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -28,6 +28,7 @@ import javax.persistence.EntityNotFoundException; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.aai.domain.yang.Vnfc; import org.onap.so.bpmn.common.DelegateExecutionImpl; +import org.onap.so.bpmn.common.listener.db.RequestsDbListenerRunner; import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner; import org.onap.so.bpmn.common.workflow.context.WorkflowCallbackResponse; import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder; @@ -81,6 +82,8 @@ public class WorkflowActionBBTasks { private CatalogDbClient catalogDbClient; @Autowired private FlowManipulatorListenerRunner flowManipulatorListenerRunner; + @Autowired + private RequestsDbListenerRunner requestsDbListener; public void selectBB(DelegateExecution execution) { List<ExecuteBuildingBlock> flowsToExecute = @@ -225,6 +228,7 @@ public class WorkflowActionBBTasks { request.setProgress(Long.valueOf(100)); request.setRequestStatus("COMPLETE"); request.setLastModifiedBy("CamundaBPMN"); + requestsDbListener.post(request, new DelegateExecutionImpl(execution)); requestDbclient.updateInfraActiveRequests(request); } catch (Exception ex) { workflowAction.buildAndThrowException(execution, "Error Updating Request Database", ex); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java index fd0de086ad..376a27e830 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java @@ -24,16 +24,18 @@ import java.util.Collections; import java.util.List; import org.onap.so.bpmn.common.BBConstants; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.listener.db.PostCompletionRequestsDbListener; import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulator; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.db.request.beans.InfraActiveRequests; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component -public class MultiStageSkipListener implements FlowManipulator { +public class MultiStageSkipListener implements FlowManipulator, PostCompletionRequestsDbListener { @Autowired protected BBInputSetupUtils bbInputSetupUtils; @@ -41,12 +43,21 @@ public class MultiStageSkipListener implements FlowManipulator { @Autowired private CatalogDbClient catalogDbClient; + private static final String G_MULTI_STAGE_DESIGN = "multiStageDesign"; + @Override public boolean shouldRunFor(String currentBBName, boolean isFirst, BuildingBlockExecution execution) { return ((boolean) execution.getVariable(BBConstants.G_ALACARTE)) && "AssignVfModuleBB".equals(currentBBName) && isFirst; } + + @Override + public boolean shouldRunFor(BuildingBlockExecution execution) { + + return (boolean) execution.getVariable(G_MULTI_STAGE_DESIGN); + } + @Override public void run(List<ExecuteBuildingBlock> flowsToExecute, ExecuteBuildingBlock currentBB, BuildingBlockExecution execution) { @@ -61,10 +72,15 @@ public class MultiStageSkipListener implements FlowManipulator { if (vnfCust != null && vnfCust.getMultiStageDesign() != null && vnfCust.getMultiStageDesign().equalsIgnoreCase("true")) { flowsToExecute.retainAll(Collections.singletonList(currentBB)); + execution.setVariable(G_MULTI_STAGE_DESIGN, Boolean.valueOf(vnfCust.getMultiStageDesign())); } } } } + @Override + public void run(InfraActiveRequests request, BuildingBlockExecution execution) { + request.setFlowStatus("Successfully completed Assign Building Block only due to multi-stage-design VNF"); + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java index 0e32955eed..12aae1e6a6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/SDNCVnfResources.java @@ -22,6 +22,7 @@ package org.onap.so.client.orchestration; +import java.net.URI; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; @@ -50,47 +51,48 @@ public class SDNCVnfResources { private SDNCClient sdncClient; public GenericResourceApiVnfOperationInformation assignVnf(GenericVnf vnf, ServiceInstance serviceInstance, - Customer customer, CloudRegion cloudRegion, RequestContext requestContext, boolean homing) { + Customer customer, CloudRegion cloudRegion, RequestContext requestContext, boolean homing, + URI callbackURI) { return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer, - cloudRegion, requestContext, homing); + cloudRegion, requestContext, homing, callbackURI); } public GenericResourceApiVnfOperationInformation activateVnf(GenericVnf vnf, ServiceInstance serviceInstance, - Customer customer, CloudRegion cloudRegion, RequestContext requestContext) { + Customer customer, CloudRegion cloudRegion, RequestContext requestContext, URI callbackURI) { return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ACTIVATE, GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer, - cloudRegion, requestContext, false); + cloudRegion, requestContext, false, callbackURI); } public GenericResourceApiVnfOperationInformation deactivateVnf(GenericVnf vnf, ServiceInstance serviceInstance, - Customer customer, CloudRegion cloudRegion, RequestContext requestContext) { + Customer customer, CloudRegion cloudRegion, RequestContext requestContext, URI callbackURI) { return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, GenericResourceApiRequestActionEnumeration.DELETEVNFINSTANCE, vnf, serviceInstance, customer, - cloudRegion, requestContext, false); + cloudRegion, requestContext, false, callbackURI); } public GenericResourceApiVnfOperationInformation unassignVnf(GenericVnf vnf, ServiceInstance serviceInstance, - Customer customer, CloudRegion cloudRegion, RequestContext requestContext) { + Customer customer, CloudRegion cloudRegion, RequestContext requestContext, URI callbackURI) { return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.UNASSIGN, GenericResourceApiRequestActionEnumeration.DELETEVNFINSTANCE, vnf, serviceInstance, customer, - cloudRegion, requestContext, false); + cloudRegion, requestContext, false, callbackURI); } public GenericResourceApiVnfOperationInformation deleteVnf(GenericVnf vnf, ServiceInstance serviceInstance, - Customer customer, CloudRegion cloudRegion, RequestContext requestContext) { + Customer customer, CloudRegion cloudRegion, RequestContext requestContext, URI callbackURI) { return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.DEACTIVATE, GenericResourceApiRequestActionEnumeration.DELETEVNFINSTANCE, vnf, serviceInstance, customer, - cloudRegion, requestContext, false); + cloudRegion, requestContext, false, callbackURI); } public GenericResourceApiVnfOperationInformation changeModelVnf(GenericVnf vnf, ServiceInstance serviceInstance, - Customer customer, CloudRegion cloudRegion, RequestContext requestContext) { + Customer customer, CloudRegion cloudRegion, RequestContext requestContext, URI callbackURI) { return sdncRM.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.CHANGE_ASSIGN, GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer, - cloudRegion, requestContext, false); + cloudRegion, requestContext, false, callbackURI); } public String queryVnf(GenericVnf vnf) throws MapperException, BadResponseException { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResources.java index 0a825b8424..62d6a110f6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResources.java @@ -39,12 +39,33 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +/** + * This class is used for creating and deleting the request for VfModule. + * + */ @Component public class VnfAdapterVfModuleResources { @Autowired private VnfAdapterVfModuleObjectMapper vnfAdapterVfModuleObjectMapper; + /** + * This method is used for creating the request for the VfModule. + * + * This method take these parameter and call the VnfAdapterVfModuleObjectMapper to create the request. + * + * @param requestContext + * @param cloudRegion + * @param orchestrationContext + * @param serviceInstance + * @param genericVnf + * @param vfModule + * @param volumeGroup + * @param sdncVnfQueryResponse + * @param sdncVfModuleQueryResponse + * @throws IOException & MissingValueTagException + * @return + */ public CreateVfModuleRequest createVfModuleRequest(RequestContext requestContext, CloudRegion cloudRegion, OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, GenericVnf genericVnf, VfModule vfModule, VolumeGroup volumeGroup, String sdncVnfQueryResponse, String sdncVfModuleQueryResponse) @@ -54,6 +75,19 @@ public class VnfAdapterVfModuleResources { sdncVfModuleQueryResponse); } + /** + * This method is used for delete the request for the VfModule. + * + * This method take these parameter and call the VnfAdapterVfModuleObjectMapper to delete the request. + * + * @param requestContext + * @param cloudRegion + * @param serviceInstance + * @param genericVnf + * @param vfModule + * @throws IOException + * @return + */ public DeleteVfModuleRequest deleteVfModuleRequest(RequestContext requestContext, CloudRegion cloudRegion, ServiceInstance serviceInstance, GenericVnf genericVnf, VfModule vfModule) throws IOException { return vnfAdapterVfModuleObjectMapper.deleteVfModuleRequestMapper(requestContext, cloudRegion, serviceInstance, diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java index e39e202aa3..fd0af3a4dd 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java @@ -20,6 +20,7 @@ package org.onap.so.client.sdnc.mapper; +import java.net.URI; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -54,9 +55,26 @@ public class VnfTopologyOperationRequestMapper { @Autowired private GeneralTopologyObjectMapper generalTopologyObjectMapper; + /** + * This method is used for creating the vnf request. + * + * By these parameter it will get he detailas and prepare the request. + * + * @param svcOperation + * @param svcAction + * @param requestAction + * @param vnf + * @param serviceInstance + * @param customer + * @param cloudRegion + * @param requestContext + * @param homing + * @return request + */ public GenericResourceApiVnfOperationInformation reqMapper(SDNCSvcOperation svcOperation, SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration requestAction, GenericVnf vnf, ServiceInstance serviceInstance, - Customer customer, CloudRegion cloudRegion, RequestContext requestContext, boolean homing) { + Customer customer, CloudRegion cloudRegion, RequestContext requestContext, boolean homing, + URI callbackUrl) { String sdncReqId = UUID.randomUUID().toString(); String msoRequestId = UUID.randomUUID().toString(); if (requestContext != null && requestContext.getMsoRequestId() != null) { @@ -64,7 +82,7 @@ public class VnfTopologyOperationRequestMapper { } GenericResourceApiVnfOperationInformation req = new GenericResourceApiVnfOperationInformation(); GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = - generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId); + generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId, callbackUrl.toString()); GenericResourceApiRequestinformationRequestInformation requestInformation = generalTopologyObjectMapper .buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, requestAction); GenericResourceApiServiceinformationServiceInformation serviceInformation = diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java index ffd4f74b63..510dc47649 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCActivateTaskTest.java @@ -94,11 +94,11 @@ public class SDNCActivateTaskTest extends BaseTaskTest { @Test public void activateVnfTest() throws Exception { - doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).activateVnf(genericVnf, - serviceInstance, customer, cloudRegion, requestContext); + doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).activateVnf(eq(genericVnf), + eq(serviceInstance), eq(customer), eq(cloudRegion), eq(requestContext), any(URI.class)); sdncActivateTasks.activateVnf(execution); - verify(sdncVnfResources, times(1)).activateVnf(genericVnf, serviceInstance, customer, cloudRegion, - requestContext); + verify(sdncVnfResources, times(1)).activateVnf(eq(genericVnf), eq(serviceInstance), eq(customer), + eq(cloudRegion), eq(requestContext), any(URI.class)); SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); assertEquals(SDNCTopology.VNF, sdncRequest.getTopology()); } @@ -106,8 +106,8 @@ public class SDNCActivateTaskTest extends BaseTaskTest { @Test public void activateVnfTestException() throws Exception { expectedException.expect(BpmnError.class); - doThrow(RuntimeException.class).when(sdncVnfResources).activateVnf(genericVnf, serviceInstance, customer, - cloudRegion, requestContext); + doThrow(RuntimeException.class).when(sdncVnfResources).activateVnf(eq(genericVnf), eq(serviceInstance), + eq(customer), eq(cloudRegion), eq(requestContext), any(URI.class)); sdncActivateTasks.activateVnf(execution); } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java index 982868dcbc..b72766c386 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCAssignTasksTest.java @@ -113,12 +113,12 @@ public class SDNCAssignTasksTest extends BaseTaskTest { @Test public void assignVnfTest() throws Exception { - doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).assignVnf(genericVnf, - serviceInstance, customer, cloudRegion, requestContext, false); + doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).assignVnf(eq(genericVnf), + eq(serviceInstance), eq(customer), eq(cloudRegion), eq(requestContext), eq(false), any(URI.class)); execution.setVariable("generalBuildingBlock", gBBInput); sdncAssignTasks.assignVnf(execution); - verify(sdncVnfResources, times(1)).assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, - false); + verify(sdncVnfResources, times(1)).assignVnf(eq(genericVnf), eq(serviceInstance), eq(customer), eq(cloudRegion), + eq(requestContext), eq(false), any(URI.class)); SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); assertEquals(SDNCTopology.VNF, sdncRequest.getTopology()); } @@ -126,8 +126,8 @@ public class SDNCAssignTasksTest extends BaseTaskTest { @Test public void assignVnfExceptionTest() throws Exception { expectedException.expect(BpmnError.class); - doThrow(RuntimeException.class).when(sdncVnfResources).assignVnf(genericVnf, serviceInstance, customer, - cloudRegion, requestContext, false); + doThrow(RuntimeException.class).when(sdncVnfResources).assignVnf(eq(genericVnf), eq(serviceInstance), + eq(customer), eq(cloudRegion), eq(requestContext), eq(false), any(URI.class)); sdncAssignTasks.assignVnf(execution); } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java index 8c25bea801..96ff01f78b 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCChangeAssignTasksTest.java @@ -80,11 +80,11 @@ public class SDNCChangeAssignTasksTest extends BaseTaskTest { @Test public void changeModelVnfTest() throws Exception { - doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).changeModelVnf(genericVnf, - serviceInstance, customer, cloudRegion, requestContext); + doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).changeModelVnf(eq(genericVnf), + eq(serviceInstance), eq(customer), eq(cloudRegion), eq(requestContext), any(URI.class)); sdncChangeAssignTasks.changeModelVnf(execution); - verify(sdncVnfResources, times(1)).changeModelVnf(genericVnf, serviceInstance, customer, cloudRegion, - requestContext); + verify(sdncVnfResources, times(1)).changeModelVnf(eq(genericVnf), eq(serviceInstance), eq(customer), + eq(cloudRegion), eq(requestContext), any(URI.class)); SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); assertEquals(SDNCTopology.VNF, sdncRequest.getTopology()); } @@ -92,8 +92,8 @@ public class SDNCChangeAssignTasksTest extends BaseTaskTest { @Test public void changeModelVnfExceptionTest() throws Exception { expectedException.expect(BpmnError.class); - doThrow(RuntimeException.class).when(sdncVnfResources).changeModelVnf(genericVnf, serviceInstance, customer, - cloudRegion, requestContext); + doThrow(RuntimeException.class).when(sdncVnfResources).changeModelVnf(eq(genericVnf), eq(serviceInstance), + eq(customer), eq(cloudRegion), eq(requestContext), any(URI.class)); sdncChangeAssignTasks.changeModelVnf(execution); } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java index d8a1b0182e..3714f9d9a9 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCDeactivateTaskTest.java @@ -107,19 +107,19 @@ public class SDNCDeactivateTaskTest extends BaseTaskTest { @Test public void deactivateVnfTest() throws Exception { - doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).deactivateVnf(genericVnf, - serviceInstance, customer, cloudRegion, requestContext); + doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).deactivateVnf(eq(genericVnf), + eq(serviceInstance), eq(customer), eq(cloudRegion), eq(requestContext), any(URI.class)); sdncDeactivateTasks.deactivateVnf(execution); - verify(sdncVnfResources, times(1)).deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, - requestContext); + verify(sdncVnfResources, times(1)).deactivateVnf(eq(genericVnf), eq(serviceInstance), eq(customer), + eq(cloudRegion), eq(requestContext), any(URI.class)); SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); assertEquals(SDNCTopology.VNF, sdncRequest.getTopology()); } @Test public void deactivateVnfExceptionTest() throws Exception { - doThrow(RuntimeException.class).when(sdncVnfResources).deactivateVnf(genericVnf, serviceInstance, customer, - cloudRegion, requestContext); + doThrow(RuntimeException.class).when(sdncVnfResources).deactivateVnf(eq(genericVnf), eq(serviceInstance), + eq(customer), eq(cloudRegion), eq(requestContext), any(URI.class)); expectedException.expect(BpmnError.class); sdncDeactivateTasks.deactivateVnf(execution); } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java index b29d15c830..98f6bfab9c 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCUnassignTasksTest.java @@ -125,11 +125,11 @@ public class SDNCUnassignTasksTest extends BaseTaskTest { @Test public void unassignVnfTest() throws Exception { - doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).unassignVnf(genericVnf, - serviceInstance, customer, cloudRegion, requestContext); + doReturn(new GenericResourceApiVnfOperationInformation()).when(sdncVnfResources).unassignVnf(eq(genericVnf), + eq(serviceInstance), eq(customer), eq(cloudRegion), eq(requestContext), any(URI.class)); sdncUnassignTasks.unassignVnf(execution); - verify(sdncVnfResources, times(1)).unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, - requestContext); + verify(sdncVnfResources, times(1)).unassignVnf(eq(genericVnf), eq(serviceInstance), eq(customer), + eq(cloudRegion), eq(requestContext), any(URI.class)); SDNCRequest sdncRequest = execution.getVariable("SDNCRequest"); assertEquals(SDNCTopology.VNF, sdncRequest.getTopology()); } @@ -137,8 +137,8 @@ public class SDNCUnassignTasksTest extends BaseTaskTest { @Test public void unassignVnfExceptionTest() throws Exception { expectedException.expect(BpmnError.class); - doThrow(RuntimeException.class).when(sdncVnfResources).unassignVnf(genericVnf, serviceInstance, customer, - cloudRegion, requestContext); + doThrow(RuntimeException.class).when(sdncVnfResources).unassignVnf(eq(genericVnf), eq(serviceInstance), + eq(customer), eq(cloudRegion), eq(requestContext), any(URI.class)); sdncUnassignTasks.unassignVnf(execution); } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListenerTest.java index b6f8aafa55..9e2eac416c 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListenerTest.java @@ -36,16 +36,16 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.bpmn.common.BBConstants; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.common.DelegateExecutionImpl; -import org.onap.so.bpmn.infrastructure.workflow.tasks.listeners.MultiStageSkipListener; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.db.request.beans.InfraActiveRequests; @RunWith(MockitoJUnitRunner.class) -public class MultiStageSkipTest { +public class MultiStageSkipListenerTest { @Mock private CatalogDbClient catalogDbClient; @@ -71,6 +71,12 @@ public class MultiStageSkipTest { assertFalse("should not be triggered", multiStageSkipListener.shouldRunFor("AssignVfModuleBB2", true, execution)); + execution.setVariable("multiStageDesign", true); + assertTrue("should be triggered", multiStageSkipListener.shouldRunFor(execution)); + + execution.setVariable("multiStageDesign", false); + assertFalse("should not be triggered", multiStageSkipListener.shouldRunFor(execution)); + } @@ -107,6 +113,15 @@ public class MultiStageSkipTest { assertEquals("Flows should only have Assign", flowsToExecute.size(), 1); assertEquals("Flows should only have Assign", flowsToExecute.get(0).getBuildingBlock().getBpmnFlowName(), "AssignVfModuleBB"); + } + + @Test + public void postCompletionRequestsDbListenerTest() { + InfraActiveRequests request = new InfraActiveRequests(); + BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake()); + multiStageSkipListener.run(request, execution); + assertEquals("Successfully completed Assign Building Block only due to multi-stage-design VNF", + request.getFlowStatus()); } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java index 4c0e2b873f..0ccf056ddc 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/SDNCVnfResourcesTest.java @@ -28,6 +28,8 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import java.net.URI; +import java.net.URISyntaxException; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -66,6 +68,7 @@ public class SDNCVnfResourcesTest extends TestDataSetup { private CloudRegion cloudRegion; private RequestContext requestContext; private GenericResourceApiVnfOperationInformation sdncReq; + private URI testURI; @Before public void before() { @@ -75,6 +78,11 @@ public class SDNCVnfResourcesTest extends TestDataSetup { cloudRegion = buildCloudRegion(); requestContext = buildRequestContext(); sdncReq = new GenericResourceApiVnfOperationInformation(); + try { + testURI = new URI("http://localhost:9800"); + } catch (URISyntaxException e) { + + } } @Test @@ -82,12 +90,12 @@ public class SDNCVnfResourcesTest extends TestDataSetup { doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), - anyBoolean()); - sdncVnfResources.assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, false); + anyBoolean(), any(URI.class)); + sdncVnfResources.assignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, false, testURI); verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), - anyBoolean()); + anyBoolean(), any(URI.class)); } @Test @@ -95,12 +103,12 @@ public class SDNCVnfResourcesTest extends TestDataSetup { doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), - anyBoolean()); - sdncVnfResources.activateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext); + anyBoolean(), any(URI.class)); + sdncVnfResources.activateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, testURI); verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), - anyBoolean()); + anyBoolean(), any(URI.class)); } @Test @@ -108,12 +116,12 @@ public class SDNCVnfResourcesTest extends TestDataSetup { doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), - anyBoolean()); - sdncVnfResources.deleteVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext); + anyBoolean(), any(URI.class)); + sdncVnfResources.deleteVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, testURI); verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), - anyBoolean()); + anyBoolean(), any(URI.class)); } @Test @@ -137,11 +145,12 @@ public class SDNCVnfResourcesTest extends TestDataSetup { doReturn(sdncReq).when(MOCK_vnfTopologyOperationRequestMapper).reqMapper(isA(SDNCSvcOperation.class), isA(SDNCSvcAction.class), isA(GenericResourceApiRequestActionEnumeration.class), isA(GenericVnf.class), isA(ServiceInstance.class), isA(Customer.class), isA(CloudRegion.class), isA(RequestContext.class), - anyBoolean()); - sdncVnfResources.changeModelVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext); - verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, - SDNCSvcAction.CHANGE_ASSIGN, GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, genericVnf, - serviceInstance, customer, cloudRegion, requestContext, false); + anyBoolean(), any(URI.class)); + sdncVnfResources.changeModelVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, testURI); + verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), + eq(SDNCSvcAction.CHANGE_ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE), + eq(genericVnf), eq(serviceInstance), eq(customer), eq(cloudRegion), eq(requestContext), eq(false), + any(URI.class)); } @Test @@ -150,12 +159,12 @@ public class SDNCVnfResourcesTest extends TestDataSetup { eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE), isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class), any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class), any(RequestContext.class), - anyBoolean()); - sdncVnfResources.deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext); + anyBoolean(), any(URI.class)); + sdncVnfResources.deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, testURI); verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE), isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class), any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class), - any(RequestContext.class), anyBoolean()); + any(RequestContext.class), anyBoolean(), any(URI.class)); } @@ -166,8 +175,8 @@ public class SDNCVnfResourcesTest extends TestDataSetup { eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DEACTIVATE), isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class), any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class), any(RequestContext.class), - anyBoolean()); - sdncVnfResources.deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext); + anyBoolean(), any(URI.class)); + sdncVnfResources.deactivateVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, testURI); } @Test @@ -176,12 +185,12 @@ public class SDNCVnfResourcesTest extends TestDataSetup { eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.UNASSIGN), isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class), any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class), any(RequestContext.class), - anyBoolean()); - sdncVnfResources.unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext); + anyBoolean(), any(URI.class)); + sdncVnfResources.unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, testURI); verify(MOCK_vnfTopologyOperationRequestMapper, times(1)).reqMapper(eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.UNASSIGN), isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class), any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class), - any(RequestContext.class), anyBoolean()); + any(RequestContext.class), anyBoolean(), any(URI.class)); } @Test @@ -191,7 +200,7 @@ public class SDNCVnfResourcesTest extends TestDataSetup { eq(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION), eq(SDNCSvcAction.UNASSIGN), isA(GenericResourceApiRequestActionEnumeration.class), any(GenericVnf.class), any(ServiceInstance.class), any(Customer.class), any(CloudRegion.class), any(RequestContext.class), - anyBoolean()); - sdncVnfResources.unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext); + anyBoolean(), any(URI.class)); + sdncVnfResources.unassignVnf(genericVnf, serviceInstance, customer, cloudRegion, requestContext, testURI); } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java index cecf34ea10..00836176f0 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapperTest.java @@ -23,15 +23,18 @@ package org.onap.so.client.sdnc.mapper; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import java.net.URI; import java.util.ArrayList; import java.util.HashMap; -import java.util.Map; import java.util.List; +import java.util.Map; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; +import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; @@ -45,8 +48,6 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; @RunWith(MockitoJUnitRunner.class) public class VnfTopologyOperationRequestMapperTest { @@ -127,11 +128,11 @@ public class VnfTopologyOperationRequestMapperTest { GenericResourceApiVnfOperationInformation vnfOpInformation = mapper.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer, - cloudRegion, requestContext, true); + cloudRegion, requestContext, true, new URI("http://localhost:8080")); GenericResourceApiVnfOperationInformation vnfOpInformationNullReqContext = mapper.reqMapper(SDNCSvcOperation.VNF_TOPOLOGY_OPERATION, SDNCSvcAction.ASSIGN, GenericResourceApiRequestActionEnumeration.CREATEVNFINSTANCE, vnf, serviceInstance, customer, - cloudRegion, null, true); + cloudRegion, null, true, new URI("http://localhost:8080")); assertNull(vnfOpInformation.getServiceInformation().getOnapModelInformation().getModelCustomizationUuid()); assertEquals("vnfModelCustomizationUUID", |