From b58f841d09e1d832ea4aeae1334f151a98a1f4c8 Mon Sep 17 00:00:00 2001 From: "Smokowski, Steven" Date: Mon, 3 Feb 2020 14:48:24 -0500 Subject: modifications to create network to add lob Add platform and line of business to network Update to split out network Issue-ID: SO-2637 Signed-off-by: Benjamin, Max (mb388a) Change-Id: I5cbc3bc77986b6d4d420d2158df46924fcd74c0b --- .../infrastructure/aai/tasks/AAICreateTasks.java | 105 ++++++++++++++++----- .../client/orchestration/AAINetworkResources.java | 20 +++- 2 files changed, 103 insertions(+), 22 deletions(-) (limited to 'bpmn/so-bpmn-tasks/src/main/java/org') 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; @@ -268,6 +268,23 @@ public class AAICreateTasks { } } + /** + * This method is used for separating (,) from the string. + * + * @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. * @@ -277,15 +294,8 @@ public class AAICreateTasks { 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 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 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 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 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 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 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/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); -- cgit 1.2.3-korg