diff options
Diffstat (limited to 'bpmn/so-bpmn-tasks')
7 files changed, 217 insertions, 28 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java index c223d3ff11..de6b75bd03 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/HomingV2.java @@ -28,9 +28,9 @@ import org.springframework.stereotype.Component; @Component public class HomingV2 { - static final String HOMING_SNIRO = "sniro"; - static final String HOMING_OOF = "oof"; - static final String HOMING_SOLUTION = "Homing_Solution"; + public static final String HOMING_SNIRO = "sniro"; + public static final String HOMING_OOF = "oof"; + public static final String HOMING_SOLUTION = "Homing_Solution"; private SniroHomingV2 sniroHomingV2; private OofHomingV2 oofHomingV2; @@ -59,6 +59,6 @@ public class HomingV2 { private boolean isSniro(BuildingBlockExecution execution) { return execution.getGeneralBuildingBlock().getRequestContext().getRequestParameters().getUserParams().stream() - .anyMatch(params -> HOMING_SNIRO.equals(params.get(HOMING_SOLUTION))); + .anyMatch(params -> HomingV2.HOMING_SNIRO.equals(params.get(HomingV2.HOMING_SOLUTION))); } } 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 22089dae1f..dab5102efd 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 @@ -31,8 +31,6 @@ import java.util.TreeSet; import java.util.UUID; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.onap.so.client.orchestration.AAIPnfResources; -import org.onap.so.logger.LoggingAnchor; import org.camunda.bpm.engine.delegate.BpmnError; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; @@ -62,12 +60,14 @@ import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAIConfigurationResources; import org.onap.so.client.orchestration.AAIInstanceGroupResources; import org.onap.so.client.orchestration.AAINetworkResources; +import org.onap.so.client.orchestration.AAIPnfResources; import org.onap.so.client.orchestration.AAIServiceInstanceResources; import org.onap.so.client.orchestration.AAIVfModuleResources; import org.onap.so.client.orchestration.AAIVnfResources; import org.onap.so.client.orchestration.AAIVolumeGroupResources; import org.onap.so.client.orchestration.AAIVpnBindingResources; import org.onap.so.logger.ErrorCode; +import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -274,18 +274,28 @@ public class AAICreateTasks { * @param str * @throws @return */ + public void createPlatformForNetwork(BuildingBlockExecution execution) { + try { + L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID); + if (network != null) { + createPlatformNetwork(network); + } + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + /** + * This method is used for separating (,) from the string. + * + * @param str + * @throws @return + */ public void createPlatform(BuildingBlockExecution execution) { try { GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); - Platform platform = vnf.getPlatform(); - if (platform != null) { - if (platform.getPlatformName() == null || "".equals(platform.getPlatformName())) { - logger.debug("PlatformName is null in input. Skipping create platform..."); - } else { - List<String> platforms = splitCDL(platform.getPlatformName()); - platforms.stream().forEach(platformName -> aaiVnfResources - .createPlatformandConnectVnf(new Platform(platformName), vnf)); - } + if (vnf != null) { + createPlatformVnf(vnf); } } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); @@ -293,6 +303,30 @@ public class AAICreateTasks { } + protected void createPlatformVnf(GenericVnf vnf) { + Platform platform = vnf.getPlatform(); + if (Strings.isNullOrEmpty(platform.getPlatformName())) { + logger.debug("PlatformName is null in input. Skipping create platform..."); + } else { + List<String> platforms = splitCDL(platform.getPlatformName()); + platforms.stream().forEach( + platformName -> aaiVnfResources.createPlatformandConnectVnf(new Platform(platformName), vnf)); + } + } + + protected void createPlatformNetwork(L3Network network) { + Platform platform = network.getPlatform(); + if (platform != null) { + if (Strings.isNullOrEmpty(platform.getPlatformName())) { + logger.debug("PlatformName is null in input. Skipping create platform..."); + } else { + List<String> platforms = splitCDL(platform.getPlatformName()); + platforms.stream().forEach( + platformName -> aaiNetworkResources.createPlatformAndConnectNetwork(platform, network)); + } + } + } + /** * This method is used for separating (,) from the string. * @@ -312,22 +346,51 @@ public class AAICreateTasks { public void createLineOfBusiness(BuildingBlockExecution execution) { try { GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); - LineOfBusiness lineOfBusiness = vnf.getLineOfBusiness(); - if (lineOfBusiness != null) { - if (lineOfBusiness.getLineOfBusinessName() == null - || "".equals(lineOfBusiness.getLineOfBusinessName())) { - logger.info("lineOfBusiness is null in input. Skipping create lineOfBusiness..."); - } else { - List<String> lineOfBussinesses = splitCDL(lineOfBusiness.getLineOfBusinessName()); - lineOfBussinesses.stream().forEach(lobName -> aaiVnfResources - .createLineOfBusinessandConnectVnf(new LineOfBusiness(lobName), vnf)); - } + if (vnf != null) { + createLineOfBusinessVnf(vnf); } } catch (Exception ex) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } + public void createLineOfBusinessForNetwork(BuildingBlockExecution execution) { + try { + L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID); + if (network != null) { + createLineOfBusinessNetwork(network); + } + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + protected void createLineOfBusinessVnf(GenericVnf vnf) { + LineOfBusiness lineOfBusiness = vnf.getLineOfBusiness(); + if (lineOfBusiness != null) { + if (Strings.isNullOrEmpty(lineOfBusiness.getLineOfBusinessName())) { + logger.info("lineOfBusiness is null in input. Skipping create lineOfBusiness..."); + } else { + List<String> lineOfBussinesses = splitCDL(lineOfBusiness.getLineOfBusinessName()); + lineOfBussinesses.stream().forEach( + lobName -> aaiVnfResources.createLineOfBusinessandConnectVnf(new LineOfBusiness(lobName), vnf)); + } + } + } + + protected void createLineOfBusinessNetwork(L3Network network) { + LineOfBusiness lineOfBusiness = network.getLineOfBusiness(); + if (lineOfBusiness != null) { + if (Strings.isNullOrEmpty(lineOfBusiness.getLineOfBusinessName())) { + logger.info("lineOfBusiness is null in input. Skipping create lineOfBusiness..."); + } else { + List<String> lineOfBussinesses = splitCDL(lineOfBusiness.getLineOfBusinessName()); + lineOfBussinesses.stream().forEach(lobName -> aaiNetworkResources + .createLineOfBusinessAndConnectNetwork(new LineOfBusiness(lobName), network)); + } + } + } + /** * This method is used for creating the volume group in A&AI. * 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 f1fbe545ce..4d5494d18c 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 @@ -118,6 +118,14 @@ public class AAIUpdateTasks { } } + /** + * BPMN access method to update status of Pnf to Assigned in AAI + * + * @param execution + */ + public void updateOrchestrationStatusAssignedPnf(BuildingBlockExecution execution) { + updateOrchestrationStatusForPnf(execution, OrchestrationStatus.ASSIGNED); + } /** * BPMN access method to update status of Pnf to Active in AAI @@ -125,11 +133,29 @@ public class AAIUpdateTasks { * @param execution */ public void updateOrchestrationStatusActivePnf(BuildingBlockExecution execution) { + updateOrchestrationStatusForPnf(execution, OrchestrationStatus.ACTIVE); + } + + /** + * BPMN access method to update status of Pnf to Register in AAI + */ + public void updateOrchestrationStatusRegisterPnf(BuildingBlockExecution execution) { + updateOrchestrationStatusForPnf(execution, OrchestrationStatus.REGISTER); + } + + /** + * BPMN access method to update status of Pnf to Registered in AAI + */ + public void updateOrchestrationStatusRegisteredPnf(BuildingBlockExecution execution) { + updateOrchestrationStatusForPnf(execution, OrchestrationStatus.REGISTERED); + } + + private void updateOrchestrationStatusForPnf(BuildingBlockExecution execution, OrchestrationStatus status) { try { Pnf pnf = extractPojosForBB.extractByKey(execution, ResourceKey.PNF); - aaiPnfResources.updateOrchestrationStatusPnf(pnf, OrchestrationStatus.ACTIVE); + aaiPnfResources.updateOrchestrationStatusPnf(pnf, status); } catch (Exception ex) { - logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusActivePnf", ex); + logger.error("Exception occurred in AAIUpdateTasks during update Orchestration Status to {}", status, ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); } } 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 11a7b83259..cf56964af3 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 @@ -90,6 +90,17 @@ public class AAIObjectMapper { } public org.onap.aai.domain.yang.Pnf mapPnf(Pnf pnf) { + if (modelMapper.getTypeMap(Pnf.class, org.onap.aai.domain.yang.Pnf.class) == null) { + modelMapper.addMappings(new PropertyMap<Pnf, org.onap.aai.domain.yang.Pnf>() { + @Override + protected void configure() { + map().setModelCustomizationId(source.getModelInfoPnf().getModelCustomizationUuid()); + map().setModelInvariantId(source.getModelInfoPnf().getModelInvariantUuid()); + map().setModelVersionId(source.getModelInfoPnf().getModelUuid()); + } + }); + } + return modelMapper.map(pnf, org.onap.aai.domain.yang.Pnf.class); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java index bc702c9fb4..3af65815a6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAINetworkResources.java @@ -30,6 +30,8 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +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.bpmn.servicedecomposition.bbobjects.Subnet; import org.onap.so.client.aai.AAIObjectPlurals; @@ -38,8 +40,8 @@ import org.onap.so.client.aai.entities.AAIEdgeLabel; 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; -import org.onap.so.client.graphinventory.entities.uri.Depth; import org.onap.so.client.aai.mapper.AAIObjectMapper; +import org.onap.so.client.graphinventory.entities.uri.Depth; import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -76,6 +78,22 @@ public class AAINetworkResources { serviceInstanceURI); } + public void createLineOfBusinessAndConnectNetwork(LineOfBusiness lineOfBusiness, L3Network network) { + AAIResourceUri lineOfBusinessURI = + AAIUriFactory.createResourceUri(AAIObjectType.LINE_OF_BUSINESS, lineOfBusiness.getLineOfBusinessName()); + AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId()); + injectionHelper.getAaiClient().createIfNotExists(lineOfBusinessURI, Optional.of(lineOfBusiness)) + .connect(networkURI, lineOfBusinessURI); + } + + public void createPlatformAndConnectNetwork(Platform platform, L3Network network) { + AAIResourceUri platformURI = + AAIUriFactory.createResourceUri(AAIObjectType.PLATFORM, platform.getPlatformName()); + AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId()); + injectionHelper.getAaiClient().createIfNotExists(platformURI, Optional.of(platform)).connect(networkURI, + platformURI); + } + public void deleteNetwork(L3Network network) { AAIResourceUri networkURI = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, network.getNetworkId()); injectionHelper.getAaiClient().delete(networkURI); 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 ae6dde6521..e26009a1de 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 @@ -139,6 +139,25 @@ public class AAIUpdateTasksTest extends BaseTaskTest { aaiUpdateTasks.updateOrchestrationStatusActiveService(execution); } + @Test + public void updateOrchestrationStatusAssignedPnfTest() throws Exception { + Pnf pnf = preparePnfAndExtractForPnf(); + doNothing().when(aaiPnfResources).updateOrchestrationStatusPnf(pnf, OrchestrationStatus.ASSIGNED); + + aaiUpdateTasks.updateOrchestrationStatusAssignedPnf(execution); + + verify(aaiPnfResources, times(1)).updateOrchestrationStatusPnf(pnf, OrchestrationStatus.ASSIGNED); + } + + @Test + public void updateOrchestrationStatusAssignedPnfExceptionTest() throws Exception { + Pnf pnf = preparePnfAndExtractForPnf(); + doThrow(RuntimeException.class).when(aaiPnfResources).updateOrchestrationStatusPnf(pnf, + OrchestrationStatus.ASSIGNED); + + expectedException.expect(BpmnError.class); + aaiUpdateTasks.updateOrchestrationStatusAssignedPnf(execution); + } @Test public void updateOrchestrationStatusActivePnfTest() throws Exception { @@ -161,6 +180,26 @@ public class AAIUpdateTasksTest extends BaseTaskTest { } @Test + public void updateOrchestrationStatusRegisterPnfTest() throws Exception { + Pnf pnf = preparePnfAndExtractForPnf(); + doNothing().when(aaiPnfResources).updateOrchestrationStatusPnf(pnf, OrchestrationStatus.REGISTER); + + aaiUpdateTasks.updateOrchestrationStatusRegisterPnf(execution); + + verify(aaiPnfResources, times(1)).updateOrchestrationStatusPnf(pnf, OrchestrationStatus.REGISTER); + } + + @Test + public void updateOrchestrationStatusRegisteredPnfTest() throws Exception { + Pnf pnf = preparePnfAndExtractForPnf(); + doNothing().when(aaiPnfResources).updateOrchestrationStatusPnf(pnf, OrchestrationStatus.REGISTERED); + + aaiUpdateTasks.updateOrchestrationStatusRegisteredPnf(execution); + + verify(aaiPnfResources, times(1)).updateOrchestrationStatusPnf(pnf, OrchestrationStatus.REGISTERED); + } + + @Test public void updateOrchestrationStatusAssignedVnfTest() throws Exception { doNothing().when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ASSIGNED); 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 821e70a8c8..dc64e4ee48 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 @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2020 Nokia + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -41,6 +43,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy; import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.Project; import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTarget; import org.onap.so.bpmn.servicedecomposition.bbobjects.SegmentationAssignment; @@ -55,6 +58,7 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoPnf; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule; import org.onap.so.db.catalog.beans.OrchestrationStatus; @@ -233,6 +237,34 @@ public class AAIObjectMapperTest { } @Test + public void pnfMap() { + final String pnfId = "PNF_id1"; + final String pnfName = "PNF_name1"; + final String modelCustomizationId = "8421fe03-fd1b-4bf7-845a-c3fe91edb03e"; + final String modelInvariantId = "341a6f84-2cf9-4942-8f9e-2472ffe4e1d8"; + final String modelVersionId = "b13a0706-46b9-4a98-a9f9-5b28431235e7"; + final OrchestrationStatus orchestrationStatus = OrchestrationStatus.PRECREATED; + + Pnf pnf = new Pnf(); + pnf.setPnfId(pnfId); + pnf.setPnfName(pnfName); + pnf.setModelInfoPnf(new ModelInfoPnf()); + pnf.getModelInfoPnf().setModelCustomizationUuid(modelCustomizationId); + pnf.getModelInfoPnf().setModelInvariantUuid(modelInvariantId); + pnf.getModelInfoPnf().setModelUuid(modelVersionId); + pnf.setOrchestrationStatus(orchestrationStatus); + + org.onap.aai.domain.yang.Pnf aaiPnf = aaiObjectMapper.mapPnf(pnf); + + assertEquals(aaiPnf.getPnfId(), pnfId); + assertEquals(aaiPnf.getPnfName(), pnfName); + assertEquals(aaiPnf.getModelCustomizationId(), modelCustomizationId); + assertEquals(aaiPnf.getModelInvariantId(), modelInvariantId); + assertEquals(aaiPnf.getModelVersionId(), modelVersionId); + assertEquals(aaiPnf.getOrchestrationStatus(), orchestrationStatus.toString()); + } + + @Test public void vfModuleMap() throws Exception { VfModule vfModule = new VfModule(); vfModule.setVfModuleId("a"); |