aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java12
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java51
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java13
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java32
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java2
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/PauseForManualTaskActivity.bpmn10
-rw-r--r--bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/PauseForManualTaskActivityTest.java3
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/Create3rdONAPE2EServiceInstance.groovy80
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy36
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy7
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java234
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactoryTest.java2
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/DeActivateSDNCNetworkResource.bpmn72
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java7
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java9
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java120
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListener.java3
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVfModuleResources.java34
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VnfTopologyOperationRequestMapper.java16
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java16
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java362
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListenerTest.java2
22 files changed, 886 insertions, 237 deletions
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/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java
index f8d5402260..dcb9e08d0b 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java
@@ -31,6 +31,7 @@ import java.util.Map;
import java.util.Optional;
import org.onap.aai.domain.yang.CloudRegion;
import org.onap.aai.domain.yang.Configuration;
+import org.onap.aai.domain.yang.Configurations;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.GenericVnfs;
import org.onap.aai.domain.yang.InstanceGroup;
@@ -50,6 +51,7 @@ import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFou
import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException;
import org.onap.so.client.aai.AAIObjectPlurals;
import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.AAIResourcesClient;
import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
@@ -575,4 +577,53 @@ public class BBInputSetupUtils {
}
return Optional.empty();
}
+
+ public ServiceInstances getAAIServiceInstancesGloballyByName(String serviceInstanceName) {
+
+ return injectionHelper.getAaiClient()
+ .get(ServiceInstances.class, AAIUriFactory.createNodesUri(AAIObjectPlurals.SERVICE_INSTANCE)
+ .queryParam("service-instance-name", serviceInstanceName))
+ .orElseGet(() -> {
+ logger.debug("No Service Instance matched by name");
+ return null;
+ });
+ }
+
+ public boolean existsAAINetworksGloballyByName(String networkName) {
+
+ AAIResourceUri l3networkUri =
+ AAIUriFactory.createResourceUri(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", networkName);
+ AAIResourcesClient aaiRC = injectionHelper.getAaiClient();
+ return aaiRC.exists(l3networkUri);
+ }
+
+ public GenericVnfs getAAIVnfsGloballyByName(String vnfName) {
+
+ return injectionHelper.getAaiClient()
+ .get(GenericVnfs.class,
+ AAIUriFactory.createNodesUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName))
+ .orElseGet(() -> {
+ logger.debug("No GenericVnfs matched by name");
+ return null;
+ });
+ }
+
+ public Optional<Configuration> getRelatedConfigurationByNameFromServiceInstance(String serviceInstanceId,
+ String configurationName) throws Exception {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId);
+ uri.relatedTo(AAIObjectPlurals.CONFIGURATION).queryParam("configuration-name", configurationName);
+ Optional<Configurations> configurations = injectionHelper.getAaiClient().get(Configurations.class, uri);
+ Configuration configuration = null;
+ if (!configurations.isPresent()) {
+ logger.debug("No Configurations matched by name");
+ return Optional.empty();
+ } else {
+ if (configurations.get().getConfiguration().size() > 1) {
+ throw new Exception("Multiple Configurations Returned");
+ } else {
+ configuration = configurations.get().getConfiguration().get(0);
+ }
+ return Optional.of(configuration);
+ }
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java
index 189947595a..7780837714 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java
@@ -47,6 +47,7 @@ import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.aai.domain.yang.CloudRegion;
import org.onap.aai.domain.yang.Configuration;
+import org.onap.aai.domain.yang.Configurations;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.GenericVnfs;
import org.onap.aai.domain.yang.L3Network;
@@ -865,4 +866,16 @@ public class BBInputSetupUtilsTest {
assertEquals(expectedFlowsToExecute.size(), flowsToExecute.size());
}
+ @Test
+ public void getRelatedConfigurationByNameFromServiceInstanceTest() throws Exception {
+ Optional<Configurations> expected = Optional.of(new Configurations());
+ Configuration configuration = new Configuration();
+ configuration.setConfigurationId("id123");
+ expected.get().getConfiguration().add(configuration);
+ doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(Configurations.class), any(AAIResourceUri.class));
+ Optional<Configuration> actual =
+ this.bbInputSetupUtils.getRelatedConfigurationByNameFromServiceInstance("id123", "name123");
+ assertEquals(actual.get().getConfigurationId(), expected.get().getConfiguration().get(0).getConfigurationId());
+ }
+
}
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-building-blocks/src/main/resources/subprocess/Activity/PauseForManualTaskActivity.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/PauseForManualTaskActivity.bpmn
index fb9704d294..884ec209aa 100644
--- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/PauseForManualTaskActivity.bpmn
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/Activity/PauseForManualTaskActivity.bpmn
@@ -22,11 +22,11 @@
</bpmn2:userTask>
<bpmn2:sequenceFlow id="SequenceFlow_0b84ki5" sourceRef="UpdateDbStatusToPendingManualTask" targetRef="CreateExternalTicket" />
<bpmn2:sequenceFlow id="SequenceFlow_14cyk9v" sourceRef="UpdateDbStatusToInProgress" targetRef="PauseForManualTaskActivity_End" />
- <bpmn2:serviceTask id="UpdateDbStatusToPendingManualTask" name="Update Infra DB Status to PENDING_MANUAL_TASK" camunda:expression="${ManualHandlingTasks.updateRequestDbStatus(execution,&#34;PENDING_MANUAL_TASK&#34;)}">
+ <bpmn2:serviceTask id="UpdateDbStatusToPendingManualTask" name="Update Infra DB Status to PENDING_MANUAL_TASK" camunda:expression="${ManualHandlingTasks.updateRequestDbStatus(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)),&#34;PENDING_MANUAL_TASK&#34;)}">
<bpmn2:incoming>SequenceFlow_0jav6cu</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_0b84ki5</bpmn2:outgoing>
</bpmn2:serviceTask>
- <bpmn2:serviceTask id="UpdateDbStatusToInProgress" name="Update Infra DB Status to IN_PROGRESS" camunda:expression="${ManualHandlingTasks.updateRequestDbStatus(execution, &#34;IN_PROGRESS&#34;)}">
+ <bpmn2:serviceTask id="UpdateDbStatusToInProgress" name="Update Infra DB Status to IN_PROGRESS" camunda:expression="${ManualHandlingTasks.updateRequestDbStatus(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)), &#34;IN_PROGRESS&#34;)}">
<bpmn2:incoming>SequenceFlow_192yimz</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_14cyk9v</bpmn2:outgoing>
</bpmn2:serviceTask>
@@ -37,12 +37,12 @@
<bpmn2:timeDuration xsi:type="bpmn2:tFormalExpression"><![CDATA[${execution.getVariable("taskTimeout")}]]></bpmn2:timeDuration>
</bpmn2:timerEventDefinition>
</bpmn2:boundaryEvent>
- <bpmn2:serviceTask id="CreateExternalTicket" name="Create ExternalTicket" camunda:expression="${ManualHandlingTasks.createExternalTicket(execution)}">
+ <bpmn2:serviceTask id="CreateExternalTicket" name="Create ExternalTicket" camunda:expression="${ManualHandlingTasks.createExternalTicket(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
<bpmn2:incoming>SequenceFlow_0b84ki5</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_0igra4l</bpmn2:outgoing>
</bpmn2:serviceTask>
<bpmn2:sequenceFlow id="SequenceFlow_01k6zgt" sourceRef="ManualTaskTimer" targetRef="UpdateDBStatusToTimeout" />
- <bpmn2:serviceTask id="UpdateDBStatusToTimeout" name="Update Infra DB Status To TIMEOUT" camunda:expression="${ManualHandlingTasks.updateRequestDbStatus(execution, &#34;TIMEOUT&#34;)}">
+ <bpmn2:serviceTask id="UpdateDBStatusToTimeout" name="Update Infra DB Status To TIMEOUT" camunda:expression="${ManualHandlingTasks.updateRequestDbStatus(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)), &#34;TIMEOUT&#34;)}">
<bpmn2:incoming>SequenceFlow_01k6zgt</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_16bjdgj</bpmn2:outgoing>
</bpmn2:serviceTask>
@@ -147,4 +147,4 @@
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
-</bpmn2:definitions>
+</bpmn2:definitions> \ No newline at end of file
diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/PauseForManualTaskActivityTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/PauseForManualTaskActivityTest.java
index 484f9b8506..c0b0094f20 100644
--- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/PauseForManualTaskActivityTest.java
+++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/PauseForManualTaskActivityTest.java
@@ -35,6 +35,7 @@ import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.onap.so.bpmn.BaseBPMNTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
public class PauseForManualTaskActivityTest extends BaseBPMNTest {
@@ -85,7 +86,7 @@ public class PauseForManualTaskActivityTest extends BaseBPMNTest {
@Test
public void rainyDayPauseForManualTask_Test() throws Exception {
doThrow(new BpmnError("7000", "TESTING ERRORS")).when(manualHandlingTasks)
- .createExternalTicket((any(DelegateExecution.class)));
+ .createExternalTicket((any(BuildingBlockExecution.class)));
ProcessInstance pi = runtimeService.startProcessInstanceByKey("PauseForManualTaskActivity", variables);
assertThat(pi).isNotNull().isStarted()
.hasPassedInOrder("PauseForManualTaskActivity_Start", "UpdateDbStatusToPendingManualTask",
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/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 &#10; 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/activity/ExecuteActivity.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java
index 775e3213d4..638ecefa49 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java
@@ -22,6 +22,7 @@
package org.onap.so.bpmn.infrastructure.activity;
+import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@@ -99,6 +100,12 @@ public class ExecuteActivity implements JavaDelegate {
variables.put("retryCount", 1);
variables.put("aLaCarte", true);
+ execution.getVariables().forEach((key, value) -> {
+ if (value instanceof Serializable) {
+ variables.put(key, (Serializable) value);
+ }
+ });
+
ProcessInstanceWithVariables buildingBlockResult =
runtimeService.createProcessInstanceByKey("ExecuteBuildingBlock").setVariables(variables)
.executeWithVariablesInReturn();
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java
index 17089be571..7e45c3b640 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java
@@ -27,6 +27,7 @@ import org.camunda.bpm.engine.TaskService;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateTask;
import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.client.ticket.ExternalTicket;
import org.onap.so.db.request.beans.InfraActiveRequests;
@@ -46,7 +47,7 @@ public class ManualHandlingTasks {
private static final String TASK_TYPE_FALLOUT = "fallout";
public static final String VNF_TYPE = "vnfType";
public static final String SERVICE_TYPE = "serviceType";
- public static final String MSO_REQUEST_ID = "msoRequestId";
+ public static final String MSO_REQUEST_ID = "mso-request-id";
public static final String REQUESTOR_ID = "requestorId";
public static final String ERROR_CODE = "errorCode";
public static final String VALID_RESPONSES = "validResponses";
@@ -120,7 +121,7 @@ public class ManualHandlingTasks {
String originalRequestId = (String) execution.getVariable(MSO_REQUEST_ID);
String originalRequestorId = (String) execution.getVariable(REQUESTOR_ID);
String description = (String) execution.getVariable(DESCRIPTION);
- String timeout = (String) execution.getVariable("taskTimeout");
+ String timeout = "";
String errorSource = "";
String errorCode = "";
String errorMessage = "";
@@ -188,7 +189,7 @@ public class ManualHandlingTasks {
}
- public void createExternalTicket(DelegateExecution execution) {
+ public void createExternalTicket(BuildingBlockExecution execution) {
try {
ExternalTicket ticket = new ExternalTicket();
@@ -218,7 +219,7 @@ public class ManualHandlingTasks {
}
- public void updateRequestDbStatus(DelegateExecution execution, String status) {
+ public void updateRequestDbStatus(BuildingBlockExecution execution, String status) {
try {
String requestId = (String) execution.getVariable(MSO_REQUEST_ID);
InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
index 89030d52dc..78cb533c9e 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java
@@ -36,9 +36,11 @@ import java.util.stream.Collectors;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.javatuples.Pair;
import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.GenericVnfs;
import org.onap.aai.domain.yang.L3Network;
import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.aai.domain.yang.ServiceInstances;
import org.onap.aai.domain.yang.Vnfc;
import org.onap.aai.domain.yang.VolumeGroup;
import org.onap.aai.domain.yang.VpnBinding;
@@ -51,6 +53,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds;
import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup;
import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
+import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException;
import org.onap.so.client.aai.AAICommonObjectMapperProvider;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.entities.AAIResultWrapper;
@@ -112,6 +115,14 @@ public class WorkflowAction {
private static final String SERVICE_TYPE_BONDING = "BONDING";
private static final String CLOUD_OWNER = "DEFAULT";
private static final Logger logger = LoggerFactory.getLogger(WorkflowAction.class);
+ private static final String NAME_EXISTS_WITH_DIFF_VERSION_ID = "(%s) and different version id (%s)";
+ private static final String NAME_EXISTS_MULTIPLE =
+ "(%s) and multiple combination of model-version-id + service-type + global-customer-id";
+ private static final String NAME_EXISTS_WITH_DIFF_COMBINATION =
+ "(%s) and global-customer-id (%s), service-type (%s), model-version-id (%s)";
+ private static final String NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID =
+ "(%s), same parent and different customization id (%s)";
+ private static final String NAME_EXISTS_WITH_DIFF_PARENT = "(%s) id (%s) and different parent relationship";
@Autowired
protected BBInputSetup bbInputSetup;
@@ -149,6 +160,7 @@ public class WorkflowAction {
String uri = (String) execution.getVariable(BBConstants.G_URI);
final String vnfType = (String) execution.getVariable(VNF_TYPE);
String serviceInstanceId = (String) execution.getVariable("serviceInstanceId");
+ final String createInstanceAction = "createInstance";
final String serviceType =
Optional.ofNullable((String) execution.getVariable(BBConstants.G_SERVICE_TYPE)).orElse("");
@@ -189,7 +201,8 @@ public class WorkflowAction {
WorkflowType resourceType = resource.getResourceType();
execution.setVariable("resourceName", resourceType.toString());
String resourceId = "";
- if (resource.isGenerated()) {
+ if (resource.isGenerated() && requestAction.equalsIgnoreCase(createInstanceAction)
+ && sIRequest.getRequestDetails().getRequestInfo().getInstanceName() != null) {
resourceId = validateResourceIdInAAI(resource.getResourceId(), resourceType,
sIRequest.getRequestDetails().getRequestInfo().getInstanceName(), sIRequest.getRequestDetails(),
workflowResourceIds);
@@ -1134,55 +1147,146 @@ public class WorkflowAction {
RequestDetails reqDetails, WorkflowResourceIds workflowResourceIds) throws Exception {
try {
if ("SERVICE".equalsIgnoreCase(type.toString())) {
+ // Service name verification based upon name + model-version-id
+ // + service-type + global-customer-id per requirements
String globalCustomerId = reqDetails.getSubscriberInfo().getGlobalSubscriberId();
String serviceType = reqDetails.getRequestParameters().getSubscriptionServiceType();
if (instanceName != null) {
Optional<ServiceInstance> serviceInstanceAAI =
bbInputSetupUtils.getAAIServiceInstanceByName(globalCustomerId, serviceType, instanceName);
if (serviceInstanceAAI.isPresent()) {
- return serviceInstanceAAI.get().getServiceInstanceId();
+ if (serviceInstanceAAI.get().getModelVersionId()
+ .equalsIgnoreCase(reqDetails.getModelInfo().getModelVersionId())) {
+ return serviceInstanceAAI.get().getServiceInstanceId();
+ } else {
+ throw new DuplicateNameException("serviceInstance",
+ String.format(NAME_EXISTS_WITH_DIFF_VERSION_ID, instanceName,
+ reqDetails.getModelInfo().getModelVersionId()));
+ }
+ } else {
+ ServiceInstances aaiServiceInstances =
+ bbInputSetupUtils.getAAIServiceInstancesGloballyByName(instanceName);
+ if (aaiServiceInstances != null) {
+ if (aaiServiceInstances.getServiceInstance() != null
+ && !aaiServiceInstances.getServiceInstance().isEmpty()) {
+ if (aaiServiceInstances.getServiceInstance().size() > 1) {
+ throw new DuplicateNameException("serviceInstance",
+ String.format(NAME_EXISTS_MULTIPLE, instanceName));
+ } else {
+ ServiceInstance si =
+ aaiServiceInstances.getServiceInstance().stream().findFirst().get();
+ Map<String, String> keys =
+ bbInputSetupUtils.getURIKeysFromServiceInstance(si.getServiceInstanceId());
+
+ throw new DuplicateNameException("serviceInstance",
+ String.format(NAME_EXISTS_WITH_DIFF_COMBINATION, instanceName,
+ keys.get("global-customer-id"), keys.get("service-type"),
+ si.getModelVersionId()));
+ }
+ }
+ }
}
}
} else if ("NETWORK".equalsIgnoreCase(type.toString())) {
Optional<L3Network> network = bbInputSetupUtils.getRelatedNetworkByNameFromServiceInstance(
workflowResourceIds.getServiceInstanceId(), instanceName);
if (network.isPresent()) {
- return network.get().getNetworkId();
+ if (network.get().getModelCustomizationId()
+ .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
+ return network.get().getNetworkId();
+ } else {
+ throw new DuplicateNameException("l3Network",
+ String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID, instanceName,
+ network.get().getModelCustomizationId()));
+ }
+ }
+
+ if (bbInputSetupUtils.existsAAINetworksGloballyByName(instanceName)) {
+ throw new DuplicateNameException("l3Network", String.format(NAME_EXISTS_WITH_DIFF_PARENT,
+ instanceName, workflowResourceIds.getServiceInstanceId()));
}
+
} else if ("VNF".equalsIgnoreCase(type.toString())) {
Optional<GenericVnf> vnf = bbInputSetupUtils.getRelatedVnfByNameFromServiceInstance(
workflowResourceIds.getServiceInstanceId(), instanceName);
if (vnf.isPresent()) {
- return vnf.get().getVnfId();
+ if (vnf.get().getModelCustomizationId()
+ .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
+ return vnf.get().getVnfId();
+ } else {
+ throw new DuplicateNameException("generic-vnf",
+ String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID, instanceName,
+ vnf.get().getModelCustomizationId()));
+ }
+ }
+ GenericVnfs vnfs = bbInputSetupUtils.getAAIVnfsGloballyByName(instanceName);
+ if (vnfs != null) {
+ throw new DuplicateNameException("generic-vnf", String.format(NAME_EXISTS_WITH_DIFF_PARENT,
+ instanceName, vnfs.getGenericVnf().get(0).getVnfId()));
}
} else if ("VFMODULE".equalsIgnoreCase(type.toString())) {
GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(workflowResourceIds.getVnfId());
if (vnf != null && vnf.getVfModules() != null) {
for (org.onap.aai.domain.yang.VfModule vfModule : vnf.getVfModules().getVfModule()) {
if (vfModule.getVfModuleName().equalsIgnoreCase(instanceName)) {
- return vfModule.getVfModuleId();
+ if (vfModule.getModelCustomizationId()
+ .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
+ return vfModule.getVfModuleId();
+ } else {
+ throw new DuplicateNameException("vfModule",
+ String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID, instanceName,
+ reqDetails.getModelInfo().getModelCustomizationId()));
+ }
}
}
}
} else if ("VOLUMEGROUP".equalsIgnoreCase(type.toString())) {
+ GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(workflowResourceIds.getVnfId());
Optional<VolumeGroup> volumeGroup = bbInputSetupUtils
.getRelatedVolumeGroupByNameFromVnf(workflowResourceIds.getVnfId(), instanceName);
if (volumeGroup.isPresent()) {
- return volumeGroup.get().getVolumeGroupId();
+ if (vnf.getModelCustomizationId()
+ .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
+ return volumeGroup.get().getVolumeGroupId();
+ } else {
+ throw new DuplicateNameException("volumeGroup", volumeGroup.get().getVolumeGroupName());
+ }
}
- GenericVnf vnf = bbInputSetupUtils.getAAIGenericVnf(workflowResourceIds.getVnfId());
if (vnf != null && vnf.getVfModules() != null) {
for (org.onap.aai.domain.yang.VfModule vfModule : vnf.getVfModules().getVfModule()) {
Optional<VolumeGroup> volumeGroupFromVfModule =
bbInputSetupUtils.getRelatedVolumeGroupByNameFromVfModule(vnf.getVnfId(),
vfModule.getVfModuleId(), instanceName);
if (volumeGroupFromVfModule.isPresent()) {
- return volumeGroupFromVfModule.get().getVolumeGroupId();
+ if (vnf.getModelCustomizationId()
+ .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
+ return volumeGroupFromVfModule.get().getVolumeGroupId();
+ } else {
+ throw new DuplicateNameException("volumeGroup",
+ String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID, instanceName,
+ volumeGroupFromVfModule.get().getModelCustomizationId()));
+ }
}
}
}
+ } else if ("CONFIGURATION".equalsIgnoreCase(type.toString())) {
+ Optional<org.onap.aai.domain.yang.Configuration> configuration =
+ bbInputSetupUtils.getRelatedConfigurationByNameFromServiceInstance(
+ workflowResourceIds.getServiceInstanceId(), instanceName);
+ if (configuration.isPresent()) {
+ if (configuration.get().getModelCustomizationId()
+ .equalsIgnoreCase(reqDetails.getModelInfo().getModelCustomizationId())) {
+ return configuration.get().getConfigurationId();
+ } else {
+ throw new DuplicateNameException("configuration",
+ String.format(NAME_EXISTS_WITH_DIFF_CUSTOMIZATION_ID, instanceName,
+ configuration.get().getConfigurationId()));
+ }
+ }
}
return generatedResourceId;
+ } catch (DuplicateNameException dne) {
+ throw dne;
} catch (Exception ex) {
logger.error(WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI, ex);
throw new IllegalStateException(
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 376a27e830..4cde9c1fc8 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
@@ -22,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks.listeners;
import java.util.Collections;
import java.util.List;
+import java.util.Optional;
import org.onap.so.bpmn.common.BBConstants;
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.common.listener.db.PostCompletionRequestsDbListener;
@@ -55,7 +56,7 @@ public class MultiStageSkipListener implements FlowManipulator, PostCompletionRe
@Override
public boolean shouldRunFor(BuildingBlockExecution execution) {
- return (boolean) execution.getVariable(G_MULTI_STAGE_DESIGN);
+ return (boolean) Optional.ofNullable(execution.getVariable(G_MULTI_STAGE_DESIGN)).orElse(false);
}
@Override
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 bef4ec3465..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
@@ -55,6 +55,22 @@ 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,
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java
index 9677f8e8f3..b40195c07b 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java
@@ -38,6 +38,8 @@ import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.DelegateExecutionImpl;
import org.onap.so.db.request.beans.InfraActiveRequests;
public class ManualHandlingTasksTest extends BaseTaskTest {
@@ -56,11 +58,13 @@ public class ManualHandlingTasksTest extends BaseTaskTest {
@Mock
private DelegateTask task;
- private DelegateExecution delegateExecution;
+ @Mock
+ private BuildingBlockExecution buildingBlockExecution;
@Before
public void before() throws Exception {
delegateExecution = new DelegateExecutionFake();
+ buildingBlockExecution = new DelegateExecutionImpl(delegateExecution);
}
@Test
@@ -99,18 +103,18 @@ public class ManualHandlingTasksTest extends BaseTaskTest {
@Test
public void updateRequestDbStatus_Test() throws Exception {
InfraActiveRequests mockedRequest = new InfraActiveRequests();
- delegateExecution.setVariable("msoRequestId", "testMsoRequestId");
+ buildingBlockExecution.setVariable("mso-request-id", "msoRequestId");
when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest);
doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class));
- manualHandlingTasks.updateRequestDbStatus(delegateExecution, "IN_PROGRESS");
+ manualHandlingTasks.updateRequestDbStatus(buildingBlockExecution, "IN_PROGRESS");
verify(requestsDbClient, times(1)).updateInfraActiveRequests(any(InfraActiveRequests.class));
assertEquals(mockedRequest.getRequestStatus(), "IN_PROGRESS");
}
@Test
public void createExternalTicket_Test() throws Exception {
- delegateExecution.setVariable("msoRequestId", ("testMsoRequestId"));
- delegateExecution.setVariable("vnfType", "testVnfType");
- manualHandlingTasks.createExternalTicket(delegateExecution);
+ buildingBlockExecution.setVariable("mso-request-id", ("testMsoRequestId"));
+ buildingBlockExecution.setVariable("vnfType", "testVnfType");
+ manualHandlingTasks.createExternalTicket(buildingBlockExecution);
}
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
index 918a474b8a..eea885288e 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
@@ -44,8 +44,10 @@ import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
@@ -62,10 +64,13 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Spy;
import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.GenericVnfs;
import org.onap.aai.domain.yang.L3Network;
+import org.onap.aai.domain.yang.L3Networks;
import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.RelationshipList;
import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.aai.domain.yang.ServiceInstances;
import org.onap.aai.domain.yang.VfModule;
import org.onap.aai.domain.yang.VfModules;
import org.onap.aai.domain.yang.VolumeGroup;
@@ -76,6 +81,7 @@ 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.modelinfo.ModelInfoVfModule;
+import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.DuplicateNameException;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.client.aai.entities.Relationships;
@@ -99,6 +105,7 @@ import org.onap.so.db.catalog.beans.macro.NorthBoundRequest;
import org.onap.so.db.catalog.beans.macro.OrchestrationFlow;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.beans.RequestProcessingData;
+import org.onap.so.serviceinstancebeans.ModelInfo;
import org.onap.so.serviceinstancebeans.RequestDetails;
import org.onap.so.serviceinstancebeans.RequestParameters;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
@@ -114,7 +121,6 @@ public class WorkflowActionTest extends BaseTaskTest {
protected WorkflowAction workflowAction;
private DelegateExecution execution;
-
@InjectMocks
@Spy
protected WorkflowAction SPY_workflowAction;
@@ -1494,104 +1500,368 @@ public class WorkflowActionTest extends BaseTaskTest {
assertNull(x.getVolumeGroupId());
}
- @Test
- public void validateResourceIdInAAITest() throws Exception {
- // SI
+ private RequestDetails setupRequestDetails(String globalSubscriberId, String subscriptionServiceType,
+ String modelCustomizationId) {
RequestDetails reqDetails = new RequestDetails();
SubscriberInfo subInfo = new SubscriberInfo();
- subInfo.setGlobalSubscriberId("id123");
+ subInfo.setGlobalSubscriberId(globalSubscriberId);
reqDetails.setSubscriberInfo(subInfo);
RequestParameters reqParams = new RequestParameters();
- reqParams.setSubscriptionServiceType("subServiceType123");
+ reqParams.setSubscriptionServiceType(subscriptionServiceType);
reqDetails.setRequestParameters(reqParams);
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelCustomizationId(modelCustomizationId);
+ reqDetails.setModelInfo(modelInfo);
+ return reqDetails;
+ }
+
+ @Test
+ public void validateVnfResourceIdInAAITest() throws Exception {
+ RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
- ServiceInstance si = new ServiceInstance();
- si.setServiceInstanceId("siId123");
- Optional<ServiceInstance> siOp = Optional.of(si);
- when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName123")).thenReturn(siOp);
- when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "111111"))
- .thenReturn(Optional.empty());
- String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName123",
- reqDetails, workflowResourceIds);
- assertEquals("siId123", id);
- String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "111111",
- reqDetails, workflowResourceIds);
+ workflowResourceIds.setServiceInstanceId("siId123");
+ // Vnf
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("id123");
+ vnf.setVnfName("vnfName123");
+ vnf.setModelCustomizationId("1234567");
+ Optional<GenericVnf> opVnf = Optional.of(vnf);
+ GenericVnf vnf2 = new GenericVnf();
+ vnf2.setVnfId("id123");
+ vnf2.setVnfName("vnfName222");
+ vnf2.setModelCustomizationId("222");
+ Optional<GenericVnf> opVnf2 = Optional.of(vnf2);
+ when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName123")).thenReturn(opVnf);
+ when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName222")).thenReturn(opVnf2);
+ when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "111111")).thenReturn(Optional.empty());
+ String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "vnfName123", reqDetails,
+ workflowResourceIds);
+ assertEquals("id123", id);
+ String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "111111", reqDetails,
+ workflowResourceIds);
assertEquals("generatedId123", id2);
+ this.expectedException.expect(DuplicateNameException.class);
+ this.expectedException.expectMessage(containsString(
+ "generic-vnf with name (vnfName222), same parent and different customization id (222) already exists. The name must be unique."));
+ workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "vnfName222", reqDetails,
+ workflowResourceIds);
+ }
+
+ @Test
+ public void validateVnfResourceNameInAAITest() throws Exception {
+ RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
+ WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+ workflowResourceIds.setServiceInstanceId("siId123");
+
+ // Vnf
+ GenericVnfs genericVnfs = new GenericVnfs();
+ GenericVnf vnf3 = new GenericVnf();
+ vnf3.setVnfId("id123");
+ vnf3.setVnfName("vnfName333");
+ genericVnfs.getGenericVnf().add(vnf3);
+ when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "vnfName333")).thenReturn(Optional.empty());
+ when(bbSetupUtils.getAAIVnfsGloballyByName("vnfName333")).thenReturn(genericVnfs);
+
+ this.expectedException.expect(DuplicateNameException.class);
+ this.expectedException.expectMessage(containsString(
+ "generic-vnf with name (vnfName333) id (id123) and different parent relationship already exists. The name must be unique."));
+ workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "vnfName333", reqDetails,
+ workflowResourceIds);
+ }
+
+ @Test
+ public void validateNetworkResourceIdInAAITest() throws Exception {
+ RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
+ WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+ workflowResourceIds.setServiceInstanceId("siId123");
+
// Network
L3Network network = new L3Network();
network.setNetworkId("id123");
network.setNetworkName("name123");
+ network.setModelCustomizationId("1234567");
workflowResourceIds.setServiceInstanceId("siId123");
Optional<L3Network> opNetwork = Optional.of(network);
+ L3Network network2 = new L3Network();
+ network2.setNetworkId("id123");
+ network2.setNetworkName("networkName222");
+ network2.setModelCustomizationId("222");
+ Optional<L3Network> opNetwork2 = Optional.of(network2);
when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "name123")).thenReturn(opNetwork);
+ when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "networkName222"))
+ .thenReturn(opNetwork2);
when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("siId123", "111111")).thenReturn(Optional.empty());
- id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "name123", reqDetails,
- workflowResourceIds);
+ String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "name123",
+ reqDetails, workflowResourceIds);
assertEquals("id123", id);
- id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "111111", reqDetails,
- workflowResourceIds);
+ String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "111111",
+ reqDetails, workflowResourceIds);
assertEquals("generatedId123", id2);
- // Vnf
+ this.expectedException.expect(DuplicateNameException.class);
+ this.expectedException.expectMessage(containsString(
+ "l3Network with name (networkName222), same parent and different customization id (222) already exists. The name must be unique."));
+ workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "networkName222", reqDetails,
+ workflowResourceIds);
+ }
+
+ @Test
+ public void validateNetworkResourceNameExistsInAAITest() throws Exception {
+ RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
+ WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+ workflowResourceIds.setServiceInstanceId("siId123");
+
+ // Network
+ L3Network network = new L3Network();
+ network.setNetworkId("id123");
+ network.setNetworkName("name123");
+ network.setModelCustomizationId("1234567");
+ workflowResourceIds.setServiceInstanceId("siId123");
+
+ when(bbSetupUtils.getRelatedNetworkByNameFromServiceInstance("networkName333", "111111"))
+ .thenReturn(Optional.empty());
+ when(bbSetupUtils.existsAAINetworksGloballyByName("networkName333")).thenReturn(true);
+
+ this.expectedException.expect(DuplicateNameException.class);
+ this.expectedException.expectMessage(containsString(
+ "l3Network with name (networkName333) id (siId123) and different parent relationship already exists. The name must be unique."));
+ workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.NETWORK, "networkName333", reqDetails,
+ workflowResourceIds);
+ }
+
+ @Test
+ public void validateVfModuleResourceIdInAAITest() throws Exception {
+ RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
+ WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+ workflowResourceIds.setServiceInstanceId("siId123");
+
GenericVnf vnf = new GenericVnf();
vnf.setVnfId("id123");
vnf.setVnfName("vnfName123");
- Optional<GenericVnf> opVnf = Optional.of(vnf);
- when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "name123")).thenReturn(opVnf);
- when(bbSetupUtils.getRelatedVnfByNameFromServiceInstance("siId123", "111111")).thenReturn(Optional.empty());
- id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "name123", reqDetails,
- workflowResourceIds);
- assertEquals("id123", id);
- id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VNF, "111111", reqDetails,
- workflowResourceIds);
- assertEquals("generatedId123", id2);
+ vnf.setModelCustomizationId("222");
// VfModule
VfModules vfModules = new VfModules();
VfModule vfModule = new VfModule();
vfModule.setVfModuleId("id123");
vfModule.setVfModuleName("name123");
+ vfModule.setModelCustomizationId("1234567");
vfModules.getVfModule().add(vfModule);
vnf.setVfModules(vfModules);
workflowResourceIds.setVnfId("id123");
when(bbSetupUtils.getAAIGenericVnf("id123")).thenReturn(vnf);
- id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "name123", reqDetails,
- workflowResourceIds);
+ String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "name123",
+ reqDetails, workflowResourceIds);
assertEquals("id123", id);
- GenericVnf vnf2 = new GenericVnf();
+ GenericVnf vnf1 = new GenericVnf();
VfModules vfModules2 = new VfModules();
VfModule vfModule2 = new VfModule();
vfModule2.setVfModuleId("id123");
- vfModule2.setVfModuleName("name123");
+ vfModule2.setVfModuleName("vFModName222");
+ vfModule2.setModelCustomizationId("222");
vfModules2.getVfModule().add(vfModule2);
- vnf2.setVfModules(vfModules2);
+ vnf1.setVfModules(vfModules2);
workflowResourceIds.setVnfId("id111");
- when(bbSetupUtils.getAAIGenericVnf("id111")).thenReturn(vnf2);
- id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "111111", reqDetails,
- workflowResourceIds);
+ when(bbSetupUtils.getAAIGenericVnf("id111")).thenReturn(vnf1);
+ String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "111111",
+ reqDetails, workflowResourceIds);
assertEquals("generatedId123", id2);
+ this.expectedException.expect(DuplicateNameException.class);
+ this.expectedException.expectMessage(containsString(
+ "vfModule with name (vFModName222), same parent and different customization id (1234567) already exists. The name must be unique."));
+ workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VFMODULE, "vFModName222", reqDetails,
+ workflowResourceIds);
+
+ }
+
+ @Test
+ public void validateVolumeGroupResourceIdInAAITest() throws Exception {
+ RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
+ WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+ workflowResourceIds.setServiceInstanceId("siId123");
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("id123");
+ vnf.setVnfName("vnfName123");
+ vnf.setModelCustomizationId("1234567");
+
+ GenericVnf vnf2 = new GenericVnf();
+ vnf2.setVnfId("id123");
+ vnf2.setVnfName("vnfName123");
+ vnf2.setModelCustomizationId("222");
+
// VolumeGroup
VolumeGroup volumeGroup = new VolumeGroup();
volumeGroup.setVolumeGroupId("id123");
volumeGroup.setVolumeGroupName("name123");
workflowResourceIds.setVnfId("id123");
Optional<VolumeGroup> opVolumeGroup = Optional.of(volumeGroup);
+
+ workflowResourceIds.setVnfId("id123");
+
+ when(bbSetupUtils.getAAIGenericVnf("id123")).thenReturn(vnf);
when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("id123", "name123")).thenReturn(opVolumeGroup);
- id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "name123", reqDetails,
- workflowResourceIds);
+ String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "name123",
+ reqDetails, workflowResourceIds);
assertEquals("id123", id);
- workflowResourceIds.setVnfId("id444");
- when(bbSetupUtils.getAAIGenericVnf("id444")).thenReturn(vnf);
+ when(bbSetupUtils.getAAIGenericVnf("id123")).thenReturn(vnf2);
when(bbSetupUtils.getRelatedVolumeGroupByNameFromVfModule("id123", "id123", "111111"))
.thenReturn(opVolumeGroup);
- when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("id444", "111111")).thenReturn(Optional.empty());
- id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "111111", reqDetails,
+
+ when(bbSetupUtils.getRelatedVolumeGroupByNameFromVnf("id123", "111111")).thenReturn(Optional.empty());
+ String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.VOLUMEGROUP, "111111",
+ reqDetails, workflowResourceIds);
+ assertEquals("generatedId123", id2);
+ }
+
+ @Test
+ public void validateConfigurationResourceIdInAAITest() throws Exception {
+ RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
+ WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+ workflowResourceIds.setServiceInstanceId("siId123");
+
+ // Configuration
+ org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
+ configuration.setConfigurationId("id123");
+ configuration.setConfigurationName("name123");
+ configuration.setModelCustomizationId("1234567");
+ Optional<org.onap.aai.domain.yang.Configuration> opConfiguration = Optional.of(configuration);
+
+ org.onap.aai.domain.yang.Configuration configuration2 = new org.onap.aai.domain.yang.Configuration();
+ configuration2.setConfigurationId("id123");
+ configuration2.setConfigurationName("name123");
+ configuration2.setModelCustomizationId("222");
+ Optional<org.onap.aai.domain.yang.Configuration> opConfiguration2 = Optional.of(configuration2);
+
+ workflowResourceIds.setVnfId("id123");
+
+ when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "name123"))
+ .thenReturn(opConfiguration);
+ String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.CONFIGURATION, "name123",
+ reqDetails, workflowResourceIds);
+ assertEquals("id123", id);
+
+ when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "111111"))
+ .thenReturn(Optional.empty());
+ String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.CONFIGURATION, "111111",
+ reqDetails, workflowResourceIds);
+ assertEquals("generatedId123", id2);
+
+ when(bbSetupUtils.getRelatedConfigurationByNameFromServiceInstance("siId123", "name222"))
+ .thenReturn(opConfiguration2);
+ this.expectedException.expect(DuplicateNameException.class);
+ this.expectedException.expectMessage(containsString(
+ "configuration with name (name222), same parent and different customization id (id123) already exists. The name must be unique."));
+ workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.CONFIGURATION, "name222", reqDetails,
+ workflowResourceIds);
+ }
+
+ @Test
+ public void validateServiceInstanceResourceIdInAAITest() throws Exception {
+ WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+ workflowResourceIds.setServiceInstanceId("siId123");
+ RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
+ reqDetails.getModelInfo().setModelVersionId("1234567");
+
+ ServiceInstance si = new ServiceInstance();
+ si.setServiceInstanceId("siId123");
+ si.setModelVersionId("1234567");
+ ServiceInstances serviceInstances = new ServiceInstances();
+ serviceInstances.getServiceInstance().add(si);
+ Optional<ServiceInstance> siOp = Optional.of(si);
+ ServiceInstance si2 = new ServiceInstance();
+ si2.setServiceInstanceId("siId222");
+ si2.setModelVersionId("22222");
+ si2.setServiceInstanceName("siName222");
+ Optional<ServiceInstance> siOp2 = Optional.of(si2);
+ ServiceInstances serviceInstances2 = new ServiceInstances();
+ serviceInstances2.getServiceInstance().add(si2);
+
+ when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName123")).thenReturn(siOp);
+ when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siName222")).thenReturn(siOp2);
+ when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "111111"))
+ .thenReturn(Optional.empty());
+
+ when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName123")).thenReturn(serviceInstances);
+ String id = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName123",
+ reqDetails, workflowResourceIds);
+ assertEquals("siId123", id);
+ String id2 = workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "111111",
+ reqDetails, workflowResourceIds);
+ assertEquals("generatedId123", id2);
+
+ when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName222")).thenReturn(serviceInstances2);
+ this.expectedException.expect(DuplicateNameException.class);
+ this.expectedException.expectMessage(containsString(
+ "serviceInstance with name (siName222) and different version id (1234567) already exists. The name must be unique."));
+ workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName222", reqDetails,
+ workflowResourceIds);
+ }
+
+ @Test
+ public void validateServiceInstanceResourceIdInAAIMultipleTest() throws Exception {
+ WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+ workflowResourceIds.setServiceInstanceId("siId123");
+ RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
+ reqDetails.getModelInfo().setModelVersionId("1234567");
+
+ ServiceInstance si = new ServiceInstance();
+ si.setServiceInstanceId("siId123");
+ si.setModelVersionId("1234567");
+ ServiceInstances serviceInstances = new ServiceInstances();
+ serviceInstances.getServiceInstance().add(si);
+
+ ServiceInstance si2 = new ServiceInstance();
+ si2.setServiceInstanceId("siId222");
+ si2.setModelVersionId("22222");
+ si2.setServiceInstanceName("siName222");
+ serviceInstances.getServiceInstance().add(si2);
+
+ when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siId123"))
+ .thenReturn(Optional.empty());
+
+ when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName123")).thenReturn(serviceInstances);
+
+ this.expectedException.expect(DuplicateNameException.class);
+ this.expectedException.expectMessage(containsString(
+ "serviceInstance with name (siName123) and multiple combination of model-version-id + service-type + global-customer-id already exists. The name must be unique."));
+ workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName123", reqDetails,
+ workflowResourceIds);
+ }
+
+ @Test
+ public void validateServiceInstanceResourceIdInAAIExistsTest() throws Exception {
+ WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+ workflowResourceIds.setServiceInstanceId("siId123");
+ RequestDetails reqDetails = setupRequestDetails("id123", "subServiceType123", "1234567");
+ reqDetails.getModelInfo().setModelVersionId("1234567");
+
+ ServiceInstance si = new ServiceInstance();
+ si.setServiceInstanceId("siId123");
+ si.setModelVersionId("1234567");
+ ServiceInstances serviceInstances = new ServiceInstances();
+ serviceInstances.getServiceInstance().add(si);
+
+ when(bbSetupUtils.getAAIServiceInstanceByName("id123", "subServiceType123", "siId123"))
+ .thenReturn(Optional.empty());
+
+ when(bbSetupUtils.getAAIServiceInstancesGloballyByName("siName123")).thenReturn(serviceInstances);
+
+ Map<String, String> uriKeys = new HashMap<>();
+ uriKeys.put("global-customer-id", "globalCustomerId");
+ uriKeys.put("service-type", "serviceType");
+
+ when(bbSetupUtils.getURIKeysFromServiceInstance("siId123")).thenReturn(uriKeys);
+
+ this.expectedException.expect(DuplicateNameException.class);
+ this.expectedException.expectMessage(containsString(
+ "serviceInstance with name (siName123) and global-customer-id (globalCustomerId), service-type (serviceType), model-version-id (1234567) already exists. The name must be unique."));
+ workflowAction.validateResourceIdInAAI("generatedId123", WorkflowType.SERVICE, "siName123", reqDetails,
workflowResourceIds);
- assertEquals("id123", id2);
}
@Test
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListenerTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListenerTest.java
index 9e2eac416c..82d610fa97 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListenerTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/MultiStageSkipListenerTest.java
@@ -77,6 +77,8 @@ public class MultiStageSkipListenerTest {
execution.setVariable("multiStageDesign", false);
assertFalse("should not be triggered", multiStageSkipListener.shouldRunFor(execution));
+ execution.setVariable("multiStageDesign", null);
+ assertFalse("should not be triggered", multiStageSkipListener.shouldRunFor(execution));
}