summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsanket12345 <SX00562924@techmahindra.com>2022-03-09 21:37:49 +0530
committerSANKET KS <sx00562924@techmahindra.com>2022-03-17 09:11:59 +0000
commitf2f6144f8600f87b8dce092574c0541eb17389b8 (patch)
treeb9072973cb443adb0cc6174d40879dece3b3245d
parent1e3c281b0ae601b3c1bed4ba52fc5cb9ae0b0f7a (diff)
AAI Relationship for Parent - Child Services with Composed Resource Node
-Code to add Relation between Parent & it's Child Services -Node used to connect parent and child in AAI is ComposedResource -Parent Service can be related with multiple Child Services via composedResource Node. Issue-ID: SO-3832 Change-ID: I73f97f986a817d423f92f8d922dcd9647b8a6adc Signed-off-by: sanket12345 <SX00562924@techmahindra.com> Signed-off-by: Lukasz Rajewski <lukasz.rajewski@orange.com>
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java6
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/test/resources/application-test.yaml3
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateChildServiceBB.bpmn12
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yaml4
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/CreateChildServiceBB.java41
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml4
7 files changed, 62 insertions, 12 deletions
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
index b561055468..61a920ead8 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
@@ -2121,6 +2121,8 @@ public class BBInputSetupTest {
String instanceGroupId = "instancegroupId";
String vnfInstanceName = "vnfInstanceName";
String vfModuleInstanceName = "vfModuleInstanceName";
+ String childServiceInstanceId = "childServiceInstanceId";
+ String childServiceInstanceName = "childServiceInstanceName";
expected.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstanceId);
expected.put(ResourceKey.NETWORK_ID, networkId);
@@ -2132,6 +2134,8 @@ public class BBInputSetupTest {
expected.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroupId);
expected.put(ResourceKey.VNF_INSTANCE_NAME, vnfInstanceName);
expected.put(ResourceKey.VF_MODULE_INSTANCE_NAME, vfModuleInstanceName);
+ expected.put(ResourceKey.CHILD_SERVICE_INSTANCE_ID, childServiceInstanceId);
+ expected.put(ResourceKey.CHILD_SERVICE_INSTANCE_NAME, childServiceInstanceName);
WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
workflowResourceIds.setServiceInstanceId(serviceInstanceId);
@@ -2144,6 +2148,8 @@ public class BBInputSetupTest {
workflowResourceIds.setInstanceGroupId(instanceGroupId);
workflowResourceIds.setVnfInstanceName(vnfInstanceName);
workflowResourceIds.setVfModuleInstanceName(vfModuleInstanceName);
+ workflowResourceIds.setChildServiceInstanceId(childServiceInstanceId);
+ workflowResourceIds.setChildServiceInstanceName(childServiceInstanceName);
SPY_bbInputSetup.populateLookupKeyMapWithIds(workflowResourceIds, actual);
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/resources/application-test.yaml b/bpmn/mso-infrastructure-bpmn/src/test/resources/application-test.yaml
index 56a92cbd01..07c90bf529 100644
--- a/bpmn/mso-infrastructure-bpmn/src/test/resources/application-test.yaml
+++ b/bpmn/mso-infrastructure-bpmn/src/test/resources/application-test.yaml
@@ -59,6 +59,9 @@ mso:
requestDb:
auth: Basic YnBlbDptc28tZGItMTUwNyE=
endpoint: http://localhost:8081
+ apihandler:
+ endpoint: http://localhost:8080
+ auth: Basic dGVzdDp0ZXN0Cg==
async:
core-pool-size: 50
max-pool-size: 50
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateChildServiceBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateChildServiceBB.bpmn
index b681b999b1..9d361bf101 100644
--- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateChildServiceBB.bpmn
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/CreateChildServiceBB.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: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" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1qv87sb" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.6.0">
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/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" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1qv87sb" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.12.0">
<bpmn:process id="CreateChildServiceBB" name="CreateChildServiceBB" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>SequenceFlow_14q7e7i</bpmn:outgoing>
@@ -47,10 +47,10 @@
<bpmn:serviceTask id="Task_0jc8k6m" name="Handle Failure" camunda:expression="${CreateChildServiceBB.handleFailure(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
<bpmn:incoming>SequenceFlow_052tga4</bpmn:incoming>
</bpmn:serviceTask>
- <bpmn:task id="Task_1oyb4b5" name="Update AAI">
+ <bpmn:serviceTask id="Task_1oyb4b5" name="Update AAI" camunda:expression="${CreateChildServiceBB.updateRelations(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
<bpmn:incoming>SequenceFlow_0zfixj7</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_143mdyp</bpmn:outgoing>
- </bpmn:task>
+ </bpmn:serviceTask>
</bpmn:process>
<bpmn:error id="Error_1d6c5q3" name="MSO Workflow Exception" errorCode="MSOWorkflowException" camunda:errorMessage="Child service creation timeout reached" />
<bpmn:message id="Message_0kfkpsv" name="ChildServiceRequest" />
@@ -121,15 +121,15 @@
<bpmndi:BPMNShape id="ServiceTask_1j024ya_di" bpmnElement="Task_0jc8k6m">
<dc:Bounds x="850" y="230" width="100" height="80" />
</bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_10o8qyu_di" bpmnElement="Task_1oyb4b5">
+ <dc:Bounds x="1040" y="80" width="100" height="80" />
+ </bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BoundaryEvent_0g07oag_di" bpmnElement="IntermediateThrowEvent_1gh5vds">
<dc:Bounds x="712" y="142" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="750" y="173" width="40" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
- <bpmndi:BPMNShape id="Task_1hukudm_di" bpmnElement="Task_1oyb4b5">
- <dc:Bounds x="1040" y="80" width="100" height="80" />
- </bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yaml b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yaml
index fa753396cf..7a9c4ba914 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yaml
+++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/application-test.yaml
@@ -64,7 +64,9 @@ mso:
#${mso.adapters.requestDb.auth}: BBInputSetup
auth: Basic YnBlbDptc28tZGItMTUwNyE=
endpoint: http://localhost:${wiremock.server.port}
-
+ apihandler:
+ endpoint: http://localhost:8080
+ auth: Basic dGVzdDp0ZXN0Cg==
async:
core-pool-size: 50
max-pool-size: 50
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/CreateChildServiceBB.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/CreateChildServiceBB.java
index 3672df4dba..0486c529c6 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/CreateChildServiceBB.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/service/composition/CreateChildServiceBB.java
@@ -35,6 +35,14 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import org.onap.aai.domain.yang.ComposedResource;
+import org.onap.aai.domain.yang.Relationship;
+import org.onap.aaiclient.client.aai.AAIResourcesClient;
+import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
+import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types;
+
@Component
public class CreateChildServiceBB {
@@ -73,7 +81,6 @@ public class CreateChildServiceBB {
log.info("Sending Create Service Request: \n{}", sir.toString());
buildingBlockExecution.setVariable(CHILD_SVC_REQ_CORRELATION_ID,
sir.getRequestDetails().getRequestInfo().getCorrelator());
-
ServiceInstancesResponse response = apiHandlerClient.createServiceInstance(sir);
buildingBlockExecution.setVariable(CHILD_SVC_REQ_ID, response.getRequestReferences().getRequestId());
buildingBlockExecution.setVariable(CHILD_SVC_INSTANCE_ID, response.getRequestReferences().getInstanceId());
@@ -83,6 +90,38 @@ public class CreateChildServiceBB {
}
}
+ /*
+ * This method is to create Relation between Parent & Child Services with Node as Composed Resource.
+ *
+ */
+
+ public void updateRelations(BuildingBlockExecution buildingBlockExecution) throws Exception {
+
+ Map<ResourceKey, String> lookupMap = buildingBlockExecution.getLookupMap();
+
+ String childSvcInstanceId = buildingBlockExecution.getVariable(CHILD_SVC_INSTANCE_ID);
+ String parentSvcInstanceId = lookupMap.get(ResourceKey.SERVICE_INSTANCE_ID);
+
+ ComposedResource composedResource = new ComposedResource();
+ composedResource.setId(UUID.randomUUID().toString());
+
+ AAIResourcesClient client = new AAIResourcesClient();
+
+ AAIResourceUri composedResourceURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
+ .customer(buildingBlockExecution.getGeneralBuildingBlock().getCustomer().getGlobalCustomerId())
+ .serviceSubscription(buildingBlockExecution.getGeneralBuildingBlock().getRequestContext()
+ .getSubscriptionServiceType())
+ .serviceInstance(parentSvcInstanceId).composedResource(composedResource.getId()));
+
+ client.create(composedResourceURI, composedResource);
+
+ AAIResourceUri childURI =
+ AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(childSvcInstanceId));
+
+ client.connect(composedResourceURI, childURI);
+
+ }
+
public void handleFailure(final BuildingBlockExecution buildingBlockExecution) {
Map<ResourceKey, String> lookupMap = buildingBlockExecution.getLookupMap();
String childSvcInstanceName = lookupMap.get(ResourceKey.CHILD_SERVICE_INSTANCE_NAME);
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java
index cedaef0bfd..aeef976fb4 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailureTest.java
@@ -34,7 +34,6 @@ import static org.onap.so.bpmn.infrastructure.service.composition.ServiceComposi
import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.CHILD_SVC_REQ_STATUS;
import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.IS_CHILD_PROCESS;
import static org.onap.so.bpmn.infrastructure.service.composition.ServiceCompositionConstants.PARENT_CORRELATION_ID;
-
import java.sql.Timestamp;
import org.camunda.bpm.engine.ProcessEngineServices;
import org.camunda.bpm.engine.RuntimeService;
@@ -315,8 +314,7 @@ public class WorkflowActionBBFailureTest extends BaseTaskTest {
workflowActionBBFailure.updateRequestStatusToFailed(mockExecution);
verify(messageCorrelationBuilder).setVariable(CHILD_SVC_REQ_STATUS, "FAILED");
- verify(messageCorrelationBuilder).setVariable(CHILD_SVC_REQ_ERROR,
- "Rollback has been completed successfully.");
+ verify(messageCorrelationBuilder).setVariable(CHILD_SVC_REQ_ERROR, "Rollback has been completed successfully.");
verify(messageCorrelationBuilder).processInstanceVariableEquals(CHILD_SVC_REQ_CORRELATION_ID,
parentCorrelationId);
}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml b/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml
index b64fc3318b..d3f5696c16 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml
+++ b/bpmn/so-bpmn-tasks/src/test/resources/application-test.yaml
@@ -84,7 +84,9 @@ mso:
workflow:
message:
endpoint: http://localhost:${wiremock.server.port}/workflows/messages/message
-
+ apihandler:
+ endpoint: http://localhost:8080
+ auth: Basic dGVzdDp0ZXN0Cg==
async:
core-pool-size: 50
max-pool-size: 50