diff options
Diffstat (limited to 'bpmn/so-bpmn-tasks')
9 files changed, 85 insertions, 37 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIQueryTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIQueryTasks.java index beffa25249..0079b351f2 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIQueryTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIQueryTasks.java @@ -49,7 +49,6 @@ import org.springframework.stereotype.Component; public class AAIQueryTasks { private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, AAIQueryTasks.class); - private static final String NETWORK_RESULT_WRAPPER_KEY = "l3NetworkAAIResultWrapper"; private static final String ERROR_MSG = "No relationships were returned from AAIResultWrapper.getRelationships()"; @Autowired private ExtractPojosForBB extractPojosForBB; @@ -58,23 +57,6 @@ public class AAIQueryTasks { @Autowired private AAINetworkResources aaiNetworkResources; private static final ModelMapper modelMapper = new ModelMapper(); - - /** - * BPMN access method to query L3Network object in AAI by it's Id - * - * @param execution - * @throws Exception - */ - public void getNetworkWrapperById(BuildingBlockExecution execution) { - try { - L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, - execution.getLookupMap().get(ResourceKey.NETWORK_ID)); - AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network); - execution.setVariable(NETWORK_RESULT_WRAPPER_KEY, aaiResultWrapper); - } catch (Exception ex) { - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); - } - } /** * BPMN access method to query data for VPN bindings from the AAI result wrapper. @@ -85,9 +67,9 @@ public class AAIQueryTasks { public void queryNetworkVpnBinding(BuildingBlockExecution execution) { try { - org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); - - AAIResultWrapper aaiResultWrapper = execution.getVariable(NETWORK_RESULT_WRAPPER_KEY); + L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, + execution.getLookupMap().get(ResourceKey.NETWORK_ID)); + AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network); Optional<Relationships> networkRelationships = aaiResultWrapper.getRelationships(); if (!networkRelationships.isPresent()) { throw (new Exception(ERROR_MSG)); @@ -120,7 +102,9 @@ public class AAIQueryTasks { public void getNetworkVpnBinding(BuildingBlockExecution execution) { try { - AAIResultWrapper aaiResultWrapper = execution.getVariable(NETWORK_RESULT_WRAPPER_KEY); + L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, + execution.getLookupMap().get(ResourceKey.NETWORK_ID)); + AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network); CreateNetworkRequest createNetworkRequest = execution.getVariable("createNetworkRequest"); Optional<Relationships> networkRelationships = aaiResultWrapper.getRelationships(); @@ -174,9 +158,9 @@ public class AAIQueryTasks { */ public void queryNetworkPolicy(BuildingBlockExecution execution) { try { - L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); - - AAIResultWrapper aaiResultWrapper = execution.getVariable(NETWORK_RESULT_WRAPPER_KEY); + L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, + execution.getLookupMap().get(ResourceKey.NETWORK_ID)); + AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network); Optional<Relationships> networkRelationships = aaiResultWrapper.getRelationships(); if (!networkRelationships.isPresent()) { throw (new Exception(ERROR_MSG)); @@ -187,7 +171,7 @@ public class AAIQueryTasks { for(AAIResourceUri netPolicyUri : netPoliciesUriList) { Optional<NetworkPolicy> oNetPolicy = aaiNetworkResources.getNetworkPolicy(netPolicyUri); if(oNetPolicy.isPresent()) { - l3Network.getNetworkPolicies().add(modelMapper.map(oNetPolicy.get(), org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy.class)); + l3network.getNetworkPolicies().add(modelMapper.map(oNetPolicy.get(), org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy.class)); } } } @@ -205,9 +189,9 @@ public class AAIQueryTasks { */ public void queryNetworkTableRef(BuildingBlockExecution execution) { try { - L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, execution.getLookupMap().get(ResourceKey.NETWORK_ID)); - - AAIResultWrapper aaiResultWrapper = execution.getVariable(NETWORK_RESULT_WRAPPER_KEY); + L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID, + execution.getLookupMap().get(ResourceKey.NETWORK_ID)); + AAIResultWrapper aaiResultWrapper = aaiNetworkResources.queryNetworkWrapperById(l3network); Optional<Relationships> networkRelationships = aaiResultWrapper.getRelationships(); if (!networkRelationships.isPresent()) { throw (new Exception(ERROR_MSG)); @@ -219,7 +203,7 @@ public class AAIQueryTasks { Optional<RouteTableReference> oRouteTableReference = aaiNetworkResources.getRouteTable(routeTableUri); if(oRouteTableReference.isPresent()) { org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference mappedRouteTableReference = modelMapper.map(oRouteTableReference.get(), org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference.class); - l3Network.getContrailNetworkRouteTableReferences().add(mappedRouteTableReference); + l3network.getContrailNetworkRouteTableReferences().add(mappedRouteTableReference); } } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java index 9c1fba62e9..b059a77641 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java @@ -144,9 +144,11 @@ public class AAIUpdateTasks { public void updateHeatStackIdVolumeGroup(BuildingBlockExecution execution) { try { GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock(); + String heatStackId = execution.getVariable("heatStackId"); VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID, execution.getLookupMap().get(ResourceKey.VOLUME_GROUP_ID)); CloudRegion cloudRegion = gBBInput.getCloudRegion(); + volumeGroup.setHeatStackId(heatStackId); aaiVolumeGroupResources.updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion); } catch (Exception ex) { @@ -296,8 +298,10 @@ public class AAIUpdateTasks { public void updateHeatStackIdVfModule(BuildingBlockExecution execution) { try { + String heatStackId = execution.getVariable("heatStackId"); VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); + vfModule.setHeatStackId(heatStackId); aaiVfModuleResources.updateHeatStackIdVfModule(vfModule, vnf); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java index 0b712452fd..554af37924 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java @@ -65,6 +65,7 @@ public class VnfAdapterImpl { execution.setVariable("isDebugLogEnabled", "true"); execution.setVariable("mso-request-id", gBBInput.getRequestContext().getMsoRequestId()); execution.setVariable("mso-service-instance-id", serviceInstance.getServiceInstanceId()); + execution.setVariable("heatStackId", null); } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } @@ -80,23 +81,25 @@ public class VnfAdapterImpl { String heatStackId = ((CreateVfModuleResponse) vnfRestResponse).getVfModuleStackId(); if(!StringUtils.isEmpty(heatStackId)) { vfModule.setHeatStackId(heatStackId); + execution.setVariable("heatStackId", heatStackId); } } else if(vnfRestResponse instanceof DeleteVfModuleResponse) { VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID, execution.getLookupMap().get(ResourceKey.VF_MODULE_ID)); Boolean vfModuleDelete = ((DeleteVfModuleResponse) vnfRestResponse).getVfModuleDeleted(); if(null!= vfModuleDelete && vfModuleDelete) { vfModule.setHeatStackId(null); + execution.setVariable("heatStackId", null); } } else if(vnfRestResponse instanceof CreateVolumeGroupResponse) { VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID, execution.getLookupMap().get(ResourceKey.VOLUME_GROUP_ID)); String heatStackId = ((CreateVolumeGroupResponse) vnfRestResponse).getVolumeGroupStackId(); if(!StringUtils.isEmpty(heatStackId)) { volumeGroup.setHeatStackId(heatStackId); + execution.setVariable("heatStackId", heatStackId); }else{ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "HeatStackId is missing from create VolumeGroup Vnf Adapter response."); } - } - execution.setVariable("generalBuildingBlock", execution.getGeneralBuildingBlock()); + } } } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); 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 c6a63e1431..0fa0c69118 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 @@ -88,6 +88,7 @@ public class WorkflowAction { private static final String VOLUMEGROUP = "VolumeGroup"; private static final String NETWORK = "Network"; private static final String NETWORKCOLLECTION = "NetworkCollection"; + private static final String CONFIGURATION = "Configuration"; private static final String ASSIGNINSTANCE = "assignInstance"; private static final String CREATEINSTANCE = "createInstance"; private static final String USERPARAMSERVICE = "service"; @@ -136,6 +137,7 @@ public class WorkflowAction { RequestDetails requestDetails = sIRequest.getRequestDetails(); Resource resource = extractResourceIdAndTypeFromUri(uri); WorkflowType resourceType = resource.getResourceType(); + execution.setVariable("resourceName", resourceType.toString()); String resourceId = ""; if (resource.isGenerated()) { resourceId = validateResourceIdInAAI(resource.getResourceId(), resourceType, @@ -240,7 +242,7 @@ public class WorkflowAction { } if (resourceType == WorkflowType.SERVICE && (requestAction.equals(CREATEINSTANCE) || requestAction.equals(ASSIGNINSTANCE)) - && !resourceCounter.stream().filter(x -> VNF.equals(x.getResourceType())).collect(Collectors.toList()).isEmpty()) { + && !resourceCounter.stream().filter(x -> WorkflowType.VNF.equals(x.getResourceType())).collect(Collectors.toList()).isEmpty()) { execution.setVariable("homing", true); execution.setVariable("calledHoming", false); } @@ -802,6 +804,12 @@ public class WorkflowAction { .collect(Collectors.toList()).get(i).getResourceId(), apiVersion, resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null)); } + } else if (orchFlow.getFlowName().contains(CONFIGURATION)) { + for (int i = 0; i < resourceCounter.stream().filter(x -> WorkflowType.CONFIGURATION == x.getResourceType()).collect(Collectors.toList()).size(); i++) { + flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resourceCounter.stream().filter(x -> WorkflowType.CONFIGURATION == x.getResourceType()) + .collect(Collectors.toList()).get(i).getResourceId(), apiVersion, resourceId, + requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null)); + } } else { flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, "", apiVersion, resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, null)); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java index 94dfdcc747..8661c8e91e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java @@ -96,6 +96,7 @@ public class AAIObjectMapper { map().setModelInvariantId(source.getModelInfoVfModule().getModelInvariantUUID()); map().setModelVersionId(source.getModelInfoVfModule().getModelUUID()); map().setPersonaModelVersion(source.getModelInfoVfModule().getModelInvariantUUID()); + map().setIsBaseVfModule(source.getModelInfoVfModule().getIsBaseBoolean()); } }); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java index c9433a6212..b45752957e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java @@ -204,11 +204,13 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ @Test public void updateHeatStackIdVfModuleTest() throws Exception { + execution.setVariable("heatStackId", "newHeatStackId"); doNothing().when(aaiVfModuleResources).updateHeatStackIdVfModule(vfModule, genericVnf); aaiUpdateTasks.updateHeatStackIdVfModule(execution); verify(aaiVfModuleResources, times(1)).updateHeatStackIdVfModule(vfModule, genericVnf); + assertEquals("newHeatStackId", vfModule.getHeatStackId()); } @Test @@ -270,11 +272,13 @@ public class AAIUpdateTasksTest extends BaseTaskTest{ } @Test public void updateHeatStackIdVolumeGroupTest() throws Exception { + execution.setVariable("heatStackId", "newHeatStackId"); doNothing().when(aaiVolumeGroupResources).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion); aaiUpdateTasks.updateHeatStackIdVolumeGroup(execution); verify(aaiVolumeGroupResources, times(1)).updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion); + assertEquals("newHeatStackId", volumeGroup.getHeatStackId()); } @Test 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 283f8881c7..3869988c40 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 @@ -427,14 +427,20 @@ public class WorkflowActionTest extends BaseTaskTest { orch12.setFlowName("ActivateVfModuleBB"); orchFlows.add(orch12); OrchestrationFlow orch13 = new OrchestrationFlow(); - orch13.setFlowName("ActivateVnfBB"); + orch13.setFlowName("AssignFabricConfigurationBB"); orchFlows.add(orch13); OrchestrationFlow orch14 = new OrchestrationFlow(); - orch14.setFlowName("ActivateNetworkCollectionBB"); + orch14.setFlowName("ActivateFabricConfigurationBB"); orchFlows.add(orch14); OrchestrationFlow orch15 = new OrchestrationFlow(); - orch15.setFlowName("ActivateServiceInstanceBB"); + orch15.setFlowName("ActivateVnfBB"); orchFlows.add(orch15); + OrchestrationFlow orch16 = new OrchestrationFlow(); + orch16.setFlowName("ActivateNetworkCollectionBB"); + orchFlows.add(orch16); + OrchestrationFlow orch17 = new OrchestrationFlow(); + orch17.setFlowName("ActivateServiceInstanceBB"); + orchFlows.add(orch17); Service service = new Service(); doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a"); @@ -772,7 +778,7 @@ public class WorkflowActionTest extends BaseTaskTest { assertEquals(UUID.randomUUID().toString().length(),ebbs.get(14).getWorkflowResourceIds().getVnfId().length()); assertEquals(ebbs.get(15).getBuildingBlock().getBpmnFlowName(),"ActivateServiceInstanceBB"); assertEquals(3,ebbs.get(0).getWorkflowResourceIds().getServiceInstanceId().length()); - + assertEquals(true, execution.getVariable("homing")); } @Test diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java index 6edda44c0a..c3b0048e07 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java @@ -245,6 +245,32 @@ public class AAIObjectMapperTest{ assertThat(reqMapper1, sameBeanAs(AAIVfModule)); } + + @Test + public void vfModuleBaseMap() throws Exception { + VfModule vfModule = new VfModule(); + vfModule.setVfModuleId("a"); + vfModule.setVfModuleName("b"); + vfModule.setOrchestrationStatus(OrchestrationStatus.ASSIGNED); + ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule(); + modelInfoVfModule.setModelCustomizationUUID("f"); + modelInfoVfModule.setModelInvariantUUID("g"); + modelInfoVfModule.setModelUUID("h"); + modelInfoVfModule.setIsBaseBoolean(true); + vfModule.setModelInfoVfModule(modelInfoVfModule); + + org.onap.aai.domain.yang.VfModule AAIVfModule = aaiObjectMapper.mapVfModule(vfModule); + + String jsonToCompare = new String(Files.readAllBytes(Paths.get(JSON_FILE_LOCATION + "aaiVfModuleBaseMap.json"))); + + ObjectMapper omapper = new ObjectMapper(); + org.onap.aai.domain.yang.VfModule reqMapper1 = omapper.readValue( + jsonToCompare, + org.onap.aai.domain.yang.VfModule.class); + + assertThat(reqMapper1, sameBeanAs(AAIVfModule)); + + } @Test public void testMapInstanceGroup() { diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/aaiVfModuleBaseMap.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/aaiVfModuleBaseMap.json new file mode 100644 index 0000000000..9637e00fe1 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/aaiVfModuleBaseMap.json @@ -0,0 +1,12 @@ +{ + + "modelCustomizationId" : "f", + "vfModuleId" : "a", + "vfModuleName" : "b", + "modelInvariantId" : "g", + "modelVersionId" : "h", + "orchestrationStatus" : "Assigned", + "personaModelVersion" : "g", + "isBaseVfModule" : true + +}
\ No newline at end of file |