aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKalkere Ramesh, Sharan (sk720x) <sk720x@att.com>2018-12-06 14:11:29 -0500
committerKalkere Ramesh, Sharan (sk720x) <sk720x@att.com>2018-12-06 14:16:25 -0500
commitfeb3f66334092f8d28cdba41450d0a11970319de (patch)
treea5c585ad759e3eded7bbb56e56d4f15b5ad67825
parentf4eb1ccfa197b1a96195a6179a8290435ba02fd2 (diff)
creating relationships vnf and tenant
Change-Id: I515fc40c7924c2fdb3f0bc4dd3a620eb0a3bf948 Issue-ID: SO-1284 Signed-off-by: Kalkere Ramesh, Sharan (sk720x) <sk720x@att.com>
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java15
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAI.java93
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java3
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAITest.java142
-rw-r--r--bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn63
-rw-r--r--bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/AssignVnfBBTest.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java28
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVnfResources.java14
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java16
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java22
10 files changed, 378 insertions, 20 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
index 7edf39df14..c0f1c48b76 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
@@ -90,6 +90,7 @@ import org.onap.so.serviceinstancebeans.Vnfs;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
@@ -112,6 +113,9 @@ public class BBInputSetup implements JavaDelegate {
@Autowired
private BBInputSetupMapperLayer mapperLayer;
+
+ @Autowired
+ private CloudInfoFromAAI bbInputSetupHelper;
@Autowired
private ExceptionBuilder exceptionUtil;
@@ -981,11 +985,18 @@ public class BBInputSetup implements JavaDelegate {
Map<ResourceKey, String> lookupKeyMap, String bbName, GeneralBuildingBlock gBB, Service service,
String requestAction, CloudConfiguration cloudConfiguration) throws Exception {
ServiceInstance serviceInstance = gBB.getServiceInstance();
+ CloudRegion cloudRegion = null;
+ if(cloudConfiguration == null) {
+ Optional<CloudRegion> cloudRegionOp = bbInputSetupHelper.getCloudInfoFromAAI(serviceInstance);
+ if(cloudRegionOp.isPresent()) {
+ cloudRegion = cloudRegionOp.get();
+ }
+ }
if (cloudConfiguration != null && requestAction.equalsIgnoreCase("deleteInstance")) {
org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfiguration);
- CloudRegion cloudRegion = mapperLayer.mapCloudRegion(cloudConfiguration, aaiCloudRegion);
- gBB.setCloudRegion(cloudRegion);
+ cloudRegion = mapperLayer.mapCloudRegion(cloudConfiguration, aaiCloudRegion);
}
+ gBB.setCloudRegion(cloudRegion);
if (bbName.contains(VNF)) {
for (GenericVnf genericVnf : serviceInstance.getVnfs()) {
if (lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID) != null
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAI.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAI.java
new file mode 100644
index 0000000000..37088022bc
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAI.java
@@ -0,0 +1,93 @@
+package org.onap.so.bpmn.servicedecomposition.tasks;
+
+import java.util.List;
+import java.util.Optional;
+
+import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.client.aai.AAICommonObjectMapperProvider;
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
+import org.onap.so.client.aai.entities.Relationships;
+import org.onap.so.logger.MsoLogger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+
+@Component
+public class CloudInfoFromAAI {
+
+ private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CloudInfoFromAAI.class);
+ @Autowired
+ private BBInputSetupUtils bbInputSetupUtils;
+
+ public void setBbInputSetupUtils(BBInputSetupUtils bbInputSetupUtils) {
+ this.bbInputSetupUtils = bbInputSetupUtils;
+ }
+
+ protected Optional<CloudRegion> getCloudInfoFromAAI(ServiceInstance serviceInstance) throws JsonProcessingException {
+ Optional<Relationships> relationshipsOp = Optional.empty();
+ if(!serviceInstance.getVnfs().isEmpty()) {
+ GenericVnf vnf = serviceInstance.getVnfs().get(0);
+ org.onap.aai.domain.yang.GenericVnf aaiVnf = bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId());
+ AAIResultWrapper vnfWrapper = new AAIResultWrapper(
+ new AAICommonObjectMapperProvider().getMapper().writeValueAsString(aaiVnf));
+ relationshipsOp = getRelationshipsFromWrapper(vnfWrapper);
+ } else if(!serviceInstance.getNetworks().isEmpty()) {
+ L3Network network = serviceInstance.getNetworks().get(0);
+ org.onap.aai.domain.yang.L3Network aaiL3Network = bbInputSetupUtils.getAAIL3Network(network.getNetworkId());
+ AAIResultWrapper networkWrapper = new AAIResultWrapper(
+ new AAICommonObjectMapperProvider().getMapper().writeValueAsString(aaiL3Network));
+ relationshipsOp = getRelationshipsFromWrapper(networkWrapper);
+ } else {
+ msoLogger.debug("BBInputSetup could not find a cloud region or tenant, since there are no resources under the SI.");
+ return Optional.empty();
+ }
+ if (relationshipsOp.isPresent()) {
+ return getRelatedCloudRegionAndTenant(relationshipsOp.get());
+ } else {
+ msoLogger.debug("BBInputSetup could not find a cloud region or tenant");
+ return Optional.empty();
+ }
+ }
+
+ protected Optional<Relationships> getRelationshipsFromWrapper(AAIResultWrapper wrapper) {
+ Optional<Relationships> relationshipsOp;
+ relationshipsOp = wrapper.getRelationships();
+ if(relationshipsOp.isPresent()) {
+ return relationshipsOp;
+ }
+ return Optional.empty();
+ }
+
+ protected Optional<CloudRegion> getRelatedCloudRegionAndTenant(Relationships relationships) {
+ CloudRegion cloudRegion = new CloudRegion();
+ List<AAIResultWrapper> cloudRegions = relationships.getByType(AAIObjectType.CLOUD_REGION);
+ List<AAIResultWrapper> tenants = relationships.getByType(AAIObjectType.TENANT);
+ if(!cloudRegions.isEmpty()) {
+ AAIResultWrapper cloudRegionWrapper = cloudRegions.get(0);
+ Optional<org.onap.aai.domain.yang.CloudRegion> aaiCloudRegionOp = cloudRegionWrapper
+ .asBean(org.onap.aai.domain.yang.CloudRegion.class);
+ if(aaiCloudRegionOp.isPresent()) {
+ org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = aaiCloudRegionOp.get();
+ cloudRegion.setCloudOwner(aaiCloudRegion.getCloudOwner());
+ cloudRegion.setCloudRegionVersion(aaiCloudRegion.getCloudRegionVersion());
+ cloudRegion.setLcpCloudRegionId(aaiCloudRegion.getCloudRegionId());
+ cloudRegion.setComplex(aaiCloudRegion.getComplexName());
+ }
+ }
+ if(!tenants.isEmpty()) {
+ AAIResultWrapper tenantWrapper = tenants.get(0);
+ Optional<org.onap.aai.domain.yang.Tenant> aaiTenantOp = tenantWrapper
+ .asBean(org.onap.aai.domain.yang.Tenant.class);
+ if(aaiTenantOp.isPresent()) {
+ org.onap.aai.domain.yang.Tenant aaiTenant = aaiTenantOp.get();
+ cloudRegion.setTenantId(aaiTenant.getTenantId());
+ }
+ }
+ return Optional.of(cloudRegion);
+ }
+}
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 b36d6d43f8..8399fe15a3 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
@@ -84,6 +84,7 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
import org.onap.so.client.aai.AAICommonObjectMapperProvider;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.entities.AAIResultWrapper;
+import org.onap.so.client.aai.entities.Relationships;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.constants.Defaults;
@@ -137,7 +138,7 @@ public class BBInputSetupTest {
SPY_bbInputSetup.setBbInputSetupUtils(SPY_bbInputSetupUtils);
SPY_bbInputSetup.setMapperLayer(bbInputSetupMapperLayer);
}
-
+
@Test
public void testGetAlaCarteServiceInstance() throws Exception {
ServiceInstance expected = mapper.readValue(
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAITest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAITest.java
new file mode 100644
index 0000000000..ccaa97b735
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAITest.java
@@ -0,0 +1,142 @@
+package org.onap.so.bpmn.servicedecomposition.tasks;
+
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Matchers.isA;
+import static org.mockito.Mockito.doReturn;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.Spy;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.client.aai.AAICommonObjectMapperProvider;
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
+import org.onap.so.client.aai.entities.Relationships;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@RunWith(MockitoJUnitRunner.class)
+public class CloudInfoFromAAITest {
+
+ private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
+
+ @Spy
+ private CloudInfoFromAAI SPY_CloudInfoFromAAI = new CloudInfoFromAAI();
+
+ protected ObjectMapper mapper = new ObjectMapper();
+
+ @Mock
+ private BBInputSetupUtils SPY_bbInputSetupUtils;
+
+ @Before
+ public void setup(){
+ SPY_CloudInfoFromAAI.setBbInputSetupUtils(SPY_bbInputSetupUtils);
+ }
+
+ @Test
+ public void testGetCloudInfoFromAAI() throws JsonParseException, JsonMappingException, IOException {
+ //Test vnfs
+ ServiceInstance serviceInstance = mapper.readValue(
+ new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"),
+ ServiceInstance.class);
+ CloudRegion expected = new CloudRegion();
+ GenericVnf vnf = new GenericVnf();
+ String vnfId = "vnfId";
+ vnf.setVnfId(vnfId);
+ serviceInstance.getVnfs().add(vnf);
+ org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
+ aaiVnf.setVnfId(vnfId);
+ Relationships relationships = Mockito.mock(Relationships.class);
+ Optional<Relationships> relationshipsOp= Optional.of(relationships);
+ doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
+ doReturn(relationshipsOp).when(SPY_CloudInfoFromAAI).getRelationshipsFromWrapper(isA(AAIResultWrapper.class));
+ doReturn(Optional.of(expected)).when(SPY_CloudInfoFromAAI).getRelatedCloudRegionAndTenant(relationships);
+ Optional<CloudRegion> actual = SPY_CloudInfoFromAAI.getCloudInfoFromAAI(serviceInstance);
+ assertThat(actual.get(), sameBeanAs(expected));
+
+ //Test networks
+ serviceInstance = mapper.readValue(
+ new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"),
+ ServiceInstance.class);
+ L3Network l3Network = new L3Network();
+ String networkId = "networkId";
+ l3Network.setNetworkId(networkId);
+ serviceInstance.getNetworks().add(l3Network);
+ org.onap.aai.domain.yang.L3Network aaiL3Network = new org.onap.aai.domain.yang.L3Network();
+ aaiL3Network.setNetworkId(networkId);
+ doReturn(aaiL3Network).when(SPY_bbInputSetupUtils).getAAIL3Network(l3Network.getNetworkId());
+ actual = SPY_CloudInfoFromAAI.getCloudInfoFromAAI(serviceInstance);
+ assertThat(actual.get(), sameBeanAs(expected));
+
+ //Test no relationships
+
+ doReturn(Optional.empty()).when(SPY_CloudInfoFromAAI).getRelationshipsFromWrapper(isA(AAIResultWrapper.class));
+ actual = SPY_CloudInfoFromAAI.getCloudInfoFromAAI(serviceInstance);
+ assertEquals(actual, Optional.empty());
+
+ //Test null
+ serviceInstance = mapper.readValue(
+ new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"),
+ ServiceInstance.class);
+ actual = SPY_CloudInfoFromAAI.getCloudInfoFromAAI(serviceInstance);
+ assertEquals(actual, Optional.empty());
+ }
+
+ @Test
+ public void testGetRelatedCloudRegionAndTenant() throws JsonProcessingException {
+ String cloudOwner = "cloudOwner";
+ String cloudRegionId = "cloudRegionId";
+ String cloudRegionVersion = "cloudRegionVersion";
+ String cloudRegionComplexName = "cloudRegionComplexName";
+ String tenantId = "tenantId";
+ CloudRegion expected = new CloudRegion();
+ expected.setCloudOwner(cloudOwner);
+ expected.setCloudRegionVersion(cloudRegionVersion);
+ expected.setComplex(cloudRegionComplexName);
+ expected.setLcpCloudRegionId(cloudRegionId);
+ expected.setTenantId(tenantId);
+
+ Relationships relationships = Mockito.mock(Relationships.class);
+ List<AAIResultWrapper> cloudRegions = new ArrayList<>();
+ org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
+ cloudRegion.setCloudOwner(cloudOwner);
+ cloudRegion.setCloudRegionId(cloudRegionId);
+ cloudRegion.setCloudRegionVersion(cloudRegionVersion);
+ cloudRegion.setComplexName(cloudRegionComplexName);
+ AAIResultWrapper cloudRegionWrapper = new AAIResultWrapper(
+ new AAICommonObjectMapperProvider().getMapper().writeValueAsString(cloudRegion));
+ cloudRegions.add(cloudRegionWrapper);
+
+ doReturn(cloudRegions).when(relationships).getByType(AAIObjectType.CLOUD_REGION);
+ List<AAIResultWrapper> tenants = new ArrayList<>();
+ org.onap.aai.domain.yang.Tenant tenant = new org.onap.aai.domain.yang.Tenant();
+ tenant.setTenantId(tenantId);
+ AAIResultWrapper tenantWrapper = new AAIResultWrapper(
+ new AAICommonObjectMapperProvider().getMapper().writeValueAsString(tenant));
+ tenants.add(tenantWrapper);
+ doReturn(tenants).when(relationships).getByType(AAIObjectType.TENANT);
+
+ Optional<CloudRegion> actual = SPY_CloudInfoFromAAI.getRelatedCloudRegionAndTenant(relationships);
+
+ assertThat(actual.get(), sameBeanAs(expected));
+ }
+}
diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn
index 0a067483ff..f4db92ba5c 100644
--- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn
+++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/AssignVnfBB.bpmn
@@ -13,7 +13,7 @@
</bpmn:endEvent>
<bpmn:serviceTask id="Task_CreateVnf" name="&#10;AAI&#10;Create&#10;(vnf)&#10;" camunda:expression="${AAICreateTasks.createVnf(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
<bpmn:incoming>SequenceFlow_0zaz9o2</bpmn:incoming>
- <bpmn:outgoing>SequenceFlow_1jwsja5</bpmn:outgoing>
+ <bpmn:outgoing>SequenceFlow_0qj7zcn</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="SequenceFlow_0zaz9o2" sourceRef="Start_AssignVnfBB" targetRef="Task_CreateVnf" />
<bpmn:sequenceFlow id="SequenceFlow_0csh9dc" sourceRef="Task_UpdateVnfOrchestrationStatusAssigned" targetRef="End_AssignVnfBB" />
@@ -25,7 +25,6 @@
<bpmn:incoming>SequenceFlow_1lppa2m</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_1nle8kc</bpmn:outgoing>
</bpmn:serviceTask>
- <bpmn:sequenceFlow id="SequenceFlow_1jwsja5" sourceRef="Task_CreateVnf" targetRef="Task_createPlatform" />
<bpmn:sequenceFlow id="SequenceFlow_1nle8kc" sourceRef="Task_createInstanceGroups" targetRef="ExclusiveGateway_02tchpp" />
<bpmn:sequenceFlow id="SequenceFlow_11jum90" name="no" sourceRef="ExclusiveGateway_02tchpp" targetRef="ExclusiveGateway_1blf52g" />
<bpmn:sequenceFlow id="SequenceFlow_1uiok7v" name="yes" sourceRef="ExclusiveGateway_02tchpp" targetRef="Task_callHoming">
@@ -45,7 +44,7 @@
<bpmn:sequenceFlow id="SequenceFlow_169g0ir" sourceRef="Task_createPlatform" targetRef="Task_createLineOfBusiness" />
<bpmn:sequenceFlow id="SequenceFlow_1lppa2m" sourceRef="Task_createLineOfBusiness" targetRef="Task_createInstanceGroups" />
<bpmn:serviceTask id="Task_createPlatform" name="&#10;AAI&#10;Connect&#10;(platform)&#10;" camunda:expression="${AAICreateTasks.createPlatform(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
- <bpmn:incoming>SequenceFlow_1jwsja5</bpmn:incoming>
+ <bpmn:incoming>SequenceFlow_18ixm0j</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_169g0ir</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:serviceTask id="Task_createLineOfBusiness" name="&#10;AAI&#10;Create&#10;(line bus)&#10;" camunda:expression="${AAICreateTasks.createLineOfBusiness(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
@@ -73,6 +72,17 @@
<bpmn:incoming>SequenceFlow_0v8d14a</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_1samncw</bpmn:outgoing>
</bpmn:inclusiveGateway>
+ <bpmn:serviceTask id="ServiceTask_ConnectVnfToCloudRegion" name="&#10;AAI&#10;Connect&#10;(vnf to cloud region)&#10;" camunda:expression="${AAICreateTasks.connectVnfToCloudRegion(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_0qj7zcn</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_0nsg48b</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="SequenceFlow_0qj7zcn" sourceRef="Task_CreateVnf" targetRef="ServiceTask_ConnectVnfToCloudRegion" />
+ <bpmn:serviceTask id="ServiceTask_ConnectVnfToTenant" name="&#10;AAI&#10;Connect&#10;(vnf to tenant)&#10;" camunda:expression="${AAICreateTasks.connectVnfToTenant(InjectExecution.execute(execution, execution.getVariable(&#34;gBuildingBlockExecution&#34;)))}">
+ <bpmn:incoming>SequenceFlow_0nsg48b</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_18ixm0j</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="SequenceFlow_0nsg48b" sourceRef="ServiceTask_ConnectVnfToCloudRegion" targetRef="ServiceTask_ConnectVnfToTenant" />
+ <bpmn:sequenceFlow id="SequenceFlow_18ixm0j" sourceRef="ServiceTask_ConnectVnfToTenant" targetRef="Task_createPlatform" />
<bpmn:callActivity id="CallActivity_sdncAssign" name="SDNC Assign (vnf)" calledElement="SDNCHandler">
<bpmn:extensionElements>
<camunda:in source="SDNCRequest" target="SDNCRequest" />
@@ -89,9 +99,9 @@
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="AssignVnfBB">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="Start_AssignVnfBB">
- <dc:Bounds x="72" y="116" width="36" height="36" />
+ <dc:Bounds x="-249" y="116" width="36" height="36" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="79" y="152" width="23" height="12" />
+ <dc:Bounds x="-275" y="152" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ServiceTask_0m0ikey_di" bpmnElement="Task_SDNCAdapterVnfTopologyAssign">
@@ -104,13 +114,13 @@
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ServiceTask_1r380lg_di" bpmnElement="Task_CreateVnf">
- <dc:Bounds x="147" y="94" width="100" height="80" />
+ <dc:Bounds x="-159" y="94" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_0zaz9o2_di" bpmnElement="SequenceFlow_0zaz9o2">
- <di:waypoint xsi:type="dc:Point" x="108" y="134" />
- <di:waypoint xsi:type="dc:Point" x="147" y="134" />
+ <di:waypoint xsi:type="dc:Point" x="-213" y="134" />
+ <di:waypoint xsi:type="dc:Point" x="-159" y="134" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="83" y="113" width="90" height="12" />
+ <dc:Bounds x="-231" y="113" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0csh9dc_di" bpmnElement="SequenceFlow_0csh9dc">
@@ -126,13 +136,6 @@
<bpmndi:BPMNShape id="ServiceTask_0wjy7za_di" bpmnElement="Task_createInstanceGroups">
<dc:Bounds x="534" y="94" width="100" height="80" />
</bpmndi:BPMNShape>
- <bpmndi:BPMNEdge id="SequenceFlow_1jwsja5_di" bpmnElement="SequenceFlow_1jwsja5">
- <di:waypoint xsi:type="dc:Point" x="247" y="134" />
- <di:waypoint xsi:type="dc:Point" x="279" y="134" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="218" y="113" width="90" height="12" />
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1nle8kc_di" bpmnElement="SequenceFlow_1nle8kc">
<di:waypoint xsi:type="dc:Point" x="634" y="134" />
<di:waypoint xsi:type="dc:Point" x="679" y="134" />
@@ -222,6 +225,33 @@
<dc:Bounds x="896" y="163" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="ServiceTask_0zx2c43_di" bpmnElement="ServiceTask_ConnectVnfToCloudRegion">
+ <dc:Bounds x="-10" y="94" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_0qj7zcn_di" bpmnElement="SequenceFlow_0qj7zcn">
+ <di:waypoint xsi:type="dc:Point" x="-59" y="134" />
+ <di:waypoint xsi:type="dc:Point" x="-10" y="134" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="-34.5" y="113" width="0" height="12" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ServiceTask_0y6itfu_di" bpmnElement="ServiceTask_ConnectVnfToTenant">
+ <dc:Bounds x="140" y="94" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_0nsg48b_di" bpmnElement="SequenceFlow_0nsg48b">
+ <di:waypoint xsi:type="dc:Point" x="90" y="134" />
+ <di:waypoint xsi:type="dc:Point" x="140" y="134" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="115" y="113" width="0" height="12" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_18ixm0j_di" bpmnElement="SequenceFlow_18ixm0j">
+ <di:waypoint xsi:type="dc:Point" x="240" y="134" />
+ <di:waypoint xsi:type="dc:Point" x="279" y="134" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="259.5" y="113" width="0" height="12" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="CallActivity_12uxg1m_di" bpmnElement="CallActivity_sdncAssign">
<dc:Bounds x="1060" y="94" width="100" height="80" />
</bpmndi:BPMNShape>
@@ -249,3 +279,4 @@
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
+
diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/AssignVnfBBTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/AssignVnfBBTest.java
index f675440ead..f4258f46b8 100644
--- a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/AssignVnfBBTest.java
+++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/AssignVnfBBTest.java
@@ -38,7 +38,7 @@ public class AssignVnfBBTest extends BaseBPMNTest {
mockSubprocess("SDNCHandler", "My Mock Process Name", "GenericStub");
ProcessInstance pi = runtimeService.startProcessInstanceByKey("AssignVnfBB", variables);
assertThat(pi).isNotNull();
- assertThat(pi).isStarted().hasPassedInOrder("Start_AssignVnfBB", "Task_CreateVnf", "Task_createPlatform", "Task_createLineOfBusiness", "Task_createInstanceGroups",
+ assertThat(pi).isStarted().hasPassedInOrder("Start_AssignVnfBB", "Task_CreateVnf", "ServiceTask_ConnectVnfToCloudRegion", "ServiceTask_ConnectVnfToTenant", "Task_createPlatform", "Task_createLineOfBusiness", "Task_createInstanceGroups",
"Task_callHoming", "Task_SDNCAdapterVnfTopologyAssign","CallActivity_sdncAssign", "Task_UpdateVnfOrchestrationStatusAssigned",
"End_AssignVnfBB");
assertThat(pi).isEnded();
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
index 887c51e179..54ee26d0ad 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java
@@ -354,6 +354,34 @@ public class AAICreateTasks {
* @param execution
* @throws Exception
*/
+ public void connectVnfToCloudRegion(BuildingBlockExecution execution) {
+ try {
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID));
+ aaiVnfResources.connectVnfToCloudRegion(vnf, execution.getGeneralBuildingBlock().getCloudRegion());
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * BPMN access method to establish relationships in AAI
+ * @param execution
+ * @throws Exception
+ */
+ public void connectVnfToTenant(BuildingBlockExecution execution) {
+ try {
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID));
+ aaiVnfResources.connectVnfToTenant(vnf, execution.getGeneralBuildingBlock().getCloudRegion());
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
+ }
+ }
+
+ /**
+ * BPMN access method to establish relationships in AAI
+ * @param execution
+ * @throws Exception
+ */
public void connectNetworkToNetworkCollectionServiceInstance(BuildingBlockExecution execution) {
try {
ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVnfResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVnfResources.java
index 19025b4b9f..6717c1c6bc 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVnfResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVnfResources.java
@@ -110,4 +110,18 @@ public class AAIVnfResources {
.orElse(new org.onap.aai.domain.yang.GenericVnf());
return vnf.isInMaint();
}
+
+ public void connectVnfToCloudRegion(GenericVnf vnf, CloudRegion cloudRegion) {
+ AAIResourceUri cloudRegionURI = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION,
+ cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId());
+ AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId());
+ injectionHelper.getAaiClient().connect(cloudRegionURI, vnfURI);
+ }
+
+ public void connectVnfToTenant(GenericVnf vnf, CloudRegion cloudRegion) {
+ AAIResourceUri tenantURI = AAIUriFactory.createResourceUri(AAIObjectType.TENANT,
+ cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), cloudRegion.getTenantId());
+ AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId());
+ injectionHelper.getAaiClient().connect(tenantURI, vnfURI);
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java
index 44b56662ba..b2e46f6130 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasksTest.java
@@ -417,4 +417,20 @@ public class AAICreateTasksTest extends BaseTaskTest{
aaiCreateTasks.createConfiguration(execution);
verify(aaiConfigurationResources, times(1)).createConfiguration(configuration);
}
+
+ @Test
+ public void connectVnfToCloudRegionTest() throws Exception {
+ gBBInput = execution.getGeneralBuildingBlock();
+ doNothing().when(aaiVnfResources).connectVnfToCloudRegion(genericVnf, gBBInput.getCloudRegion());
+ aaiCreateTasks.connectVnfToCloudRegion(execution);
+ verify(aaiVnfResources, times(1)).connectVnfToCloudRegion(genericVnf, gBBInput.getCloudRegion());
+ }
+
+ @Test
+ public void connectVnfTenantTest() throws Exception {
+ gBBInput = execution.getGeneralBuildingBlock();
+ doNothing().when(aaiVnfResources).connectVnfToTenant(genericVnf, gBBInput.getCloudRegion());
+ aaiCreateTasks.connectVnfToTenant(execution);
+ verify(aaiVnfResources, times(1)).connectVnfToTenant(genericVnf, gBBInput.getCloudRegion());
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java
index fcd6c30220..9894a08968 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java
@@ -40,12 +40,15 @@ import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.common.InjectionHelper;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.AAIResourcesClient;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.aai.mapper.AAIObjectMapper;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
@@ -55,6 +58,9 @@ public class AAIVnfResourcesTest extends TestDataSetup {
private GenericVnf genericVnf;
private ServiceInstance serviceInstance;
+
+ private CloudRegion cloudRegion;
+
@Mock
protected AAIResourcesClient MOCK_aaiResourcesClient;
@@ -71,6 +77,7 @@ public class AAIVnfResourcesTest extends TestDataSetup {
public void before() {
serviceInstance = buildServiceInstance();
genericVnf = buildGenericVnf();
+ cloudRegion = buildCloudRegion();
doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
}
@@ -159,4 +166,19 @@ public class AAIVnfResourcesTest extends TestDataSetup {
verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.GenericVnf.class),isA(AAIResourceUri.class));
assertEquals(inMaintFlag, true);
}
+
+ @Test
+ public void connectVnfToTenantTest() throws Exception {
+ aaiVnfResources.connectVnfToTenant(genericVnf, cloudRegion);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(eq(AAIUriFactory.createResourceUri(AAIObjectType.TENANT,
+ cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId(), cloudRegion.getTenantId())),
+ eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, genericVnf.getVnfId())));
+ }
+
+ @Test
+ public void connectVnfToCloudRegionTest() throws Exception {
+ aaiVnfResources.connectVnfToCloudRegion(genericVnf, cloudRegion);
+ verify(MOCK_aaiResourcesClient, times(1)).connect(eq(AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION,
+ cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId())), eq(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, genericVnf.getVnfId())));
+ }
}