summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/main
diff options
context:
space:
mode:
authorSmokowski, Steven <steve.smokowski@att.com>2020-04-01 10:41:17 -0400
committerBenjamin, Max (mb388a) <mb388a@att.com>2020-04-17 12:05:16 -0400
commitfbb984e6a8823ca26eae20a65c6d261feac02b7b (patch)
tree00e6f3c385587a351ab644112ffca733f77465e7 /bpmn/so-bpmn-tasks/src/main
parenteceef88af7a5e13a7840059004116e8b6cbf35ac (diff)
openstack inventory capture
Begin heatbridge refactor initial check in of heatbridge Additional commits of heatbridge Update Heat bridge to write more AAI data Update to utlize HeatBrdige to populate AAI Adjust simulator endpoints to work again Remove not needed BB Test case, fix tc Refactor how AAI relationships are being built Issue-ID: SO-2777 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: Iffccc24e18b278188c3fe98bcb1ad9685229d0a2
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/vfmodule/CreateVFModule.java86
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/vfmodule/DeleteVFModule.java51
2 files changed, 137 insertions, 0 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/vfmodule/CreateVFModule.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/vfmodule/CreateVFModule.java
new file mode 100644
index 0000000000..4b1e40917a
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/vfmodule/CreateVFModule.java
@@ -0,0 +1,86 @@
+package org.onap.so.bpmn.infrastructure.vfmodule;
+
+import java.util.Optional;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.aai.AAIObjectPlurals;
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.AAIResourcesClient;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
+import org.onap.so.client.aai.entities.Relationships;
+import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.cloud.resource.beans.CloudInformation;
+import org.onap.so.cloud.resource.beans.NodeType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+
+@Component
+public class CreateVFModule {
+
+ private static final Logger logger = LoggerFactory.getLogger(CreateVFModule.class);
+
+ @Autowired
+ protected ExceptionBuilder exceptionUtil;
+
+ @Autowired
+ protected ExtractPojosForBB extractPojosForBB;
+
+ public void createInventoryVariable(BuildingBlockExecution execution) {
+ try {
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ CloudInformation cloudInformation = new CloudInformation();
+ cloudInformation.setOwner(gBBInput.getCloudRegion().getCloudOwner());
+ cloudInformation.setRegionId(gBBInput.getCloudRegion().getLcpCloudRegionId());
+ cloudInformation.setTenantId(gBBInput.getTenant().getTenantId());
+ cloudInformation.setTenantName(gBBInput.getTenant().getTenantName());
+ cloudInformation.setTenantContext(gBBInput.getTenant().getTenantContext());
+ cloudInformation.setTemplateInstanceId(execution.getVariable("heatStackId"));
+ cloudInformation.setNodeType(getNodeType(gBBInput.getCloudRegion()));
+ cloudInformation.setVnfName(vnf.getVnfName());
+ cloudInformation.setVnfId(vnf.getVnfId());
+ cloudInformation.setVfModuleId(vfModule.getVfModuleId());
+ execution.setVariable("cloudInformation", cloudInformation);
+ } catch (Exception e) {
+ logger.error("Error building CloudInformation Object for NC Inventory", e);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e);
+ }
+ }
+
+ protected NodeType getNodeType(CloudRegion cloudRegion) {
+ AAIResourceUri cloudRegionUri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION,
+ cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId());
+ AAIResourcesClient client = getAAIClient();
+ Optional<Relationships> relationships = client.get(cloudRegionUri).getRelationships();
+ if (relationships.isPresent()) {
+ AAIPluralResourceUri networkTechsGreenfieldUri = AAIUriFactory
+ .createResourceUri(AAIObjectType.CLOUD_REGION, cloudRegion.getCloudOwner(),
+ cloudRegion.getLcpCloudRegionId())
+ .relatedTo(AAIObjectPlurals.NETWORK_TECHNOLOGY)
+ .queryParam("network-technology-name", NodeType.GREENFIELD.getNetworkTechnologyName());
+
+ AAIResultWrapper networkTechsGreenfield = client.get(networkTechsGreenfieldUri);
+ if (networkTechsGreenfield != null && !networkTechsGreenfield.isEmpty()) {
+ return NodeType.GREENFIELD;
+ }
+ }
+ return NodeType.BROWNFIELD;
+ }
+
+ protected AAIResourcesClient getAAIClient() {
+ return new AAIResourcesClient();
+ }
+
+}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/vfmodule/DeleteVFModule.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/vfmodule/DeleteVFModule.java
new file mode 100644
index 0000000000..ef9b06fe8c
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/vfmodule/DeleteVFModule.java
@@ -0,0 +1,51 @@
+package org.onap.so.bpmn.infrastructure.vfmodule;
+
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.cloud.resource.beans.CloudInformation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class DeleteVFModule {
+
+ private static final Logger logger = LoggerFactory.getLogger(DeleteVFModule.class);
+
+ @Autowired
+ private ExceptionBuilder exceptionUtil;
+
+ @Autowired
+ private ExtractPojosForBB extractPojosForBB;
+
+ public void createInventoryVariable(BuildingBlockExecution execution) {
+ try {
+ VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
+ CloudInformation cloudInformation = new CloudInformation();
+ cloudInformation.setOwner(gBBInput.getCloudRegion().getCloudOwner());
+ cloudInformation.setRegionId(gBBInput.getCloudRegion().getLcpCloudRegionId());
+ cloudInformation.setTenantId(gBBInput.getTenant().getTenantId());
+ cloudInformation.setTenantName(gBBInput.getTenant().getTenantName());
+ cloudInformation.setTenantContext(gBBInput.getTenant().getTenantContext());
+ cloudInformation.setTemplateInstanceId(vfModule.getHeatStackId());
+ cloudInformation.setVnfName(vnf.getVnfName());
+ cloudInformation.setVnfId(vnf.getVnfId());
+ cloudInformation.setVfModuleId(vfModule.getVfModuleId());
+
+ execution.setVariable("cloudInformation", cloudInformation);
+ } catch (Exception e) {
+ logger.error("Error building CloudInformation Object for NC Inventory", e);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e);
+ }
+ }
+
+
+}