diff options
author | Seshu Kumar M <seshu.kumar.m@huawei.com> | 2021-10-27 13:08:31 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2021-10-27 13:08:31 +0000 |
commit | 14b2c366cdd21de0debded85c7144421c6549388 (patch) | |
tree | 867c9cbfb749663e95acdfd20126b0d3fdc9d374 /bpmn | |
parent | 067a334104fda927d56c0f8cbd1c9fadafadb08c (diff) | |
parent | a01bad71f9e8de0effb443bd0266c5c9db033bdf (diff) |
Merge "Add missing code for enabling VNF LCM features"
Diffstat (limited to 'bpmn')
6 files changed, 54 insertions, 7 deletions
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 f36c5a2915..10cea171ce 100755 --- 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 @@ -289,11 +289,12 @@ public class WorkflowAction { List<Resource> resourceList = new ArrayList<>(); List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>(); - if (resourceType == WorkflowType.SERVICE || isVNFCreateOrDelete(resourceType, requestAction)) { + if (resourceType == WorkflowType.SERVICE || isVNFCreate(resourceType, requestAction)) { resourceList = serviceEBBLoader.getResourceListForService(sIRequest, requestAction, execution, serviceInstanceId, resourceId, aaiResourceIds); - } else if (resourceType == WorkflowType.VNF && (REPLACEINSTANCE.equalsIgnoreCase(requestAction) - || (RECREATE_INSTANCE.equalsIgnoreCase(requestAction)))) { + } else if (resourceType == WorkflowType.VNF + && (DELETE_INSTANCE.equalsIgnoreCase(requestAction) || REPLACEINSTANCE.equalsIgnoreCase(requestAction) + || (RECREATE_INSTANCE.equalsIgnoreCase(requestAction)))) { vnfEBBLoader.traverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(), workflowResourceIds.getVnfId(), aaiResourceIds); } else if (resourceType == WorkflowType.VNF && UPDATE_INSTANCE.equalsIgnoreCase(requestAction)) { @@ -363,9 +364,8 @@ public class WorkflowAction { return flowsToExecute; } - private boolean isVNFCreateOrDelete(WorkflowType resourceType, String requestAction) { - return resourceType == WorkflowType.VNF - && (CREATE_INSTANCE.equalsIgnoreCase(requestAction) || DELETE_INSTANCE.equalsIgnoreCase(requestAction)); + private boolean isVNFCreate(WorkflowType resourceType, String requestAction) { + return resourceType == WorkflowType.VNF && CREATE_INSTANCE.equalsIgnoreCase(requestAction); } private void setExecutionVariables(DelegateExecution execution, List<ExecuteBuildingBlock> flowsToExecute, diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java index c000e9475c..b5ad8d8c03 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java @@ -25,6 +25,7 @@ package org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader; import com.fasterxml.jackson.core.JsonProcessingException; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.javatuples.Pair; +import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.Relationship; import org.onap.aai.domain.yang.ServiceInstance; import org.onap.aai.domain.yang.VpnBinding; @@ -248,7 +249,9 @@ public class ServiceEBBLoader { } for (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf : serviceInstanceMSO.getVnfs()) { aaiResourceIds.add(new Pair<>(WorkflowType.VNF, vnf.getVnfId())); + GenericVnf genericVnf = bbInputSetupUtils.getAAIGenericVnf(vnf.getVnfId()); Resource vnfResource = new Resource(WorkflowType.VNF, vnf.getVnfId(), false, serviceResource); + vnfResource.setVnfCustomizationId(genericVnf.getModelCustomizationId()); resourceList.add(vnfResource); traverseVnfModules(resourceList, vnfResource, aaiResourceIds, vnf); if (vnf.getVolumeGroups() != null) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java index c1d1d7ad5a..b950eb41be 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java @@ -40,6 +40,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; import org.onap.so.client.exception.ExceptionBuilder; @@ -165,6 +166,8 @@ public class VnfEBBLoader { aaiResourceIds.add(new Pair<>(WorkflowType.VFMODULE, vfModule.getVfModuleId())); Resource vfModuleResource = new Resource(WorkflowType.VFMODULE, vfModule.getVfModuleId(), false, vnfResource); + Optional.ofNullable(vfModule.getModelInfoVfModule()).map(ModelInfoVfModule::getIsBaseBoolean) + .ifPresent(vfModuleResource::setBaseVfModule); resourceList.add(vfModuleResource); findConfigurationsInsideVfModule(execution, vnf.getVnfId(), vfModule.getVfModuleId(), resourceList, vfModuleResource, aaiResourceIds); 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 021bac3a7a..52196aae49 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 @@ -66,7 +66,9 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.Mockito; import org.mockito.Spy; +import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.Relationship; import org.onap.aai.domain.yang.RelationshipList; import org.onap.aai.domain.yang.ServiceInstance; @@ -409,6 +411,7 @@ public class WorkflowActionTest extends BaseTaskTest { doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("si0"); doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI); + doReturn(Mockito.mock(GenericVnf.class)).when(bbSetupUtils).getAAIGenericVnf(any()); when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, false, "my-custom-cloud-owner")).thenReturn(northBoundRequest); workflowAction.selectExecutionList(execution); @@ -931,6 +934,7 @@ public class WorkflowActionTest extends BaseTaskTest { doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123"); doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI); + doReturn(Mockito.mock(GenericVnf.class)).when(bbSetupUtils).getAAIGenericVnf(any()); when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, false, "my-custom-cloud-owner")).thenReturn(northBoundRequest); workflowAction.selectExecutionList(execution); @@ -1011,6 +1015,7 @@ public class WorkflowActionTest extends BaseTaskTest { doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123"); doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI); + doReturn(Mockito.mock(GenericVnf.class)).when(bbSetupUtils).getAAIGenericVnf(any()); when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, false, "my-custom-cloud-owner")).thenReturn(northBoundRequest); workflowAction.selectExecutionList(execution); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java index 7a26422eb9..2725626c1a 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java @@ -41,6 +41,7 @@ import org.onap.so.bpmn.infrastructure.workflow.tasks.Resource; import org.onap.so.bpmn.infrastructure.workflow.tasks.VrfBondingServiceException; import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowType; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; import org.onap.so.client.exception.ExceptionBuilder; @@ -206,13 +207,16 @@ public class ServiceEBBLoaderTest extends BaseTaskTest { serviceInstanceAAI.setServiceInstanceId(resourceId); org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstance = setServiceInstance(); - setGenericVnf(); + GenericVnf genericVnf = setGenericVnf(); setVfModule(true); setVolumeGroup(); setL3Network(); setCollection(); setConfiguration(); + org.onap.aai.domain.yang.GenericVnf genericVnfAai = new org.onap.aai.domain.yang.GenericVnf(); + genericVnfAai.setModelCustomizationId(genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid()); + Configuration config = new Configuration(); config.setConfigurationId("testConfigurationId2"); serviceInstance.getConfigurations().add(config); @@ -236,6 +240,7 @@ public class ServiceEBBLoaderTest extends BaseTaskTest { aaiConfiguration2.setRelationshipList(relationshipList1); try { + doReturn(genericVnfAai).when(mockBbInputSetupUtils).getAAIGenericVnf(genericVnf.getVnfId()); doReturn(serviceInstanceAAI).when(mockBbInputSetupUtils).getAAIServiceInstanceById(resourceId); doReturn(serviceInstance).when(mockBbInputSetup).getExistingServiceInstance(serviceInstanceAAI); doReturn(Optional.of(aaiConfiguration1)).when(mockAaiConfigurationResources) diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoaderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoaderTest.java index a9bfde9bab..78a9628243 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoaderTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoaderTest.java @@ -32,8 +32,11 @@ import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; import org.javatuples.Pair; import org.junit.Before; import org.junit.Test; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowType; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; import org.onap.so.client.exception.ExceptionBuilder; @@ -41,6 +44,7 @@ import org.onap.so.bpmn.infrastructure.workflow.tasks.Resource; import java.util.ArrayList; import java.util.List; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; @@ -82,4 +86,31 @@ public class VnfEBBLoaderTest { cut.traverseAAIVnf(delegateExecution, resourceList, serviceId, vnfId, aaiResourceIds); assertEquals(WorkflowType.SERVICE, resourceList.get(0).getResourceType()); } + + @Test + public void traverseAAIVnf_should_add_vnfs_and_vfmodules() throws Exception { + List<Resource> resourceList = new ArrayList<>(); + List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>(); + + GenericVnf genericVnf = mock(GenericVnf.class); + doReturn(vnfId).when(genericVnf).getVnfId(); + + VfModule vfModule = mock(VfModule.class); + ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule(); + modelInfoVfModule.setIsBaseBoolean(true); + doReturn(modelInfoVfModule).when(vfModule).getModelInfoVfModule(); + + doReturn(serviceInstanceAAI).when(bbInputSetupUtils).getAAIServiceInstanceById(serviceId); + doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI); + doReturn(List.of(genericVnf)).when(serviceInstanceMSO).getVnfs(); + doReturn(List.of(vfModule)).when(genericVnf).getVfModules(); + cut = new VnfEBBLoader(bbInputSetupUtils, bbInputSetup, workflowActionUtils, exceptionBuilder); + + cut.traverseAAIVnf(delegateExecution, resourceList, serviceId, vnfId, aaiResourceIds); + + assertEquals(3, resourceList.size()); + assertEquals(WorkflowType.VNF, resourceList.get(1).getResourceType()); + assertEquals(WorkflowType.VFMODULE, resourceList.get(2).getResourceType()); + assertTrue(resourceList.get(2).isBaseVfModule()); + } } |