aboutsummaryrefslogtreecommitdiffstats
path: root/adapters
diff options
context:
space:
mode:
authorBenjamin, Max <max.benjamin@att.com>2021-01-14 10:22:44 -0500
committerBenjamin, Max (mb388a) <mb388a@att.com>2021-01-14 10:22:45 -0500
commitab3a4f747eb2aba6114624aaaf53cb83b46a2e32 (patch)
treea8a52432448afb2a65f16192873f774698aff2df /adapters
parente998ae0a7cd16f53ade786fc83140d2e78e0892e (diff)
allow deleteL3Network logic to be overridden
allow deleteL3Network logic to be overridden created public method for heatbridge client to allow custom implementation Issue-ID: SO-3482 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: Icc5f3e649629a29dedbcbe2dda7f5a5d70978a59
Diffstat (limited to 'adapters')
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java10
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/DeleteAAIInventory.java10
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java38
3 files changed, 34 insertions, 24 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java
index 14d0b0afc4..0dd7635506 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java
@@ -70,9 +70,7 @@ public class CreateAAIInventory {
List<String> oobMgtNetNames = new ArrayList<>();
- HeatBridgeApi heatBridgeClient = new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity,
- cloudInformation.getOwner(), cloudInformation.getRegionId(), cloudSite.getRegionId(),
- cloudInformation.getTenantId(), cloudInformation.getNodeType());
+ HeatBridgeApi heatBridgeClient = createClient(getAaiClient(), cloudSite, cloudIdentity, cloudInformation);
heatBridgeClient.authenticate();
@@ -128,6 +126,12 @@ public class CreateAAIInventory {
heatBridgeClient.submitToAai(env.getProperty("heatBridgeDryrun", Boolean.class, false));
}
+ public HeatBridgeApi createClient(AAIResourcesClient client, CloudSite cloudSite, CloudIdentity cloudIdentity,
+ CloudInformation cloudInformation) {
+ return new HeatBridgeImpl(client, cloudIdentity, cloudInformation.getOwner(), cloudInformation.getRegionId(),
+ cloudSite.getRegionId(), cloudInformation.getTenantId(), cloudInformation.getNodeType());
+ }
+
protected AAIResourcesClient getAaiClient() {
if (aaiClient == null)
return new AAIResourcesClient();
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/DeleteAAIInventory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/DeleteAAIInventory.java
index f904788de3..f9bbf4a75d 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/DeleteAAIInventory.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/DeleteAAIInventory.java
@@ -59,13 +59,17 @@ public class DeleteAAIInventory {
return;
}
CloudIdentity cloudIdentity = cloudSite.getIdentityService();
- HeatBridgeApi heatBridgeClient = new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity,
- cloudInformation.getOwner(), cloudInformation.getRegionId(), cloudSite.getRegionId(),
- cloudInformation.getTenantId(), cloudInformation.getNodeType());
+ HeatBridgeApi heatBridgeClient = createClient(getAaiClient(), cloudSite, cloudIdentity, cloudInformation);
heatBridgeClient.authenticate();
heatBridgeClient.deleteVfModuleData(cloudInformation.getVnfId(), cloudInformation.getVfModuleId());
}
+ public HeatBridgeApi createClient(AAIResourcesClient client, CloudSite cloudSite, CloudIdentity cloudIdentity,
+ CloudInformation cloudInformation) {
+ return new HeatBridgeImpl(client, cloudIdentity, cloudInformation.getOwner(), cloudInformation.getRegionId(),
+ cloudSite.getRegionId(), cloudInformation.getTenantId(), cloudInformation.getNodeType());
+ }
+
protected AAIResourcesClient getAaiClient() {
if (aaiClient == null)
return new AAIResourcesClient();
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java
index 9b20139969..0512912b9f 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java
@@ -61,9 +61,8 @@ import org.onap.aai.domain.yang.Pserver;
import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.RelationshipList;
import org.onap.aai.domain.yang.SriovPf;
-import org.onap.aai.domain.yang.Subnets;
import org.onap.aai.domain.yang.SriovVf;
-import org.onap.aai.domain.yang.VfModule;
+import org.onap.aai.domain.yang.Subnets;
import org.onap.aai.domain.yang.Vlan;
import org.onap.aai.domain.yang.Vserver;
import org.onap.aaiclient.client.aai.AAIDSLQueryClient;
@@ -734,27 +733,15 @@ public class HeatBridgeImpl implements HeatBridgeApi {
Objects.requireNonNull(vnfId, "Null vnf-id!");
Objects.requireNonNull(vfModuleId, "Null vf-module-id!");
try {
- Optional<VfModule> vfModule = resourcesClient.get(AAIUriFactory
+ AAIResultWrapper vfModule = resourcesClient.get(AAIUriFactory
.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId).vfModule(vfModuleId))
- .depth(Depth.ONE), NotFoundException.class).asBean(VfModule.class);
+ .depth(Depth.ONE), NotFoundException.class);
- AAIResultWrapper resultWrapper = new AAIResultWrapper(vfModule.get());
- Optional<Relationships> relationships = resultWrapper.getRelationships();
+ Optional<Relationships> relationships = vfModule.getRelationships();
logger.debug("VfModule contains relationships in AAI: {}", relationships.isPresent());
if (relationships.isPresent()) {
- List<AAIResourceUri> l3NetworkUris = relationships.get().getRelatedUris(Types.L3_NETWORK);
- logger.debug("L3Network contains {} relationships in AAI", l3NetworkUris.size());
-
- if (!l3NetworkUris.isEmpty()) {
- for (AAIResourceUri l3NetworkUri : l3NetworkUris) {
- if (env.getProperty("heatBridgeDryrun", Boolean.class, true)) {
- logger.debug("Would delete L3Network: {}", l3NetworkUri.build().toString());
- } else {
- resourcesClient.delete(l3NetworkUri);
- }
- }
- }
+ deleteL3Networks(relationships.get());
List<AAIResourceUri> vserverUris = relationships.get().getRelatedUris(Types.VSERVER);
logger.debug("VServer contains {} relationships in AAI", vserverUris.size());
@@ -782,6 +769,21 @@ public class HeatBridgeImpl implements HeatBridgeApi {
}
}
+ protected void deleteL3Networks(Relationships relationships) {
+ List<AAIResourceUri> l3NetworkUris = relationships.getRelatedUris(Types.L3_NETWORK);
+ logger.debug("L3Network contains {} relationships in AAI", l3NetworkUris.size());
+
+ if (!l3NetworkUris.isEmpty()) {
+ for (AAIResourceUri l3NetworkUri : l3NetworkUris) {
+ if (env.getProperty("heatBridgeDryrun", Boolean.class, true)) {
+ logger.debug("Would delete L3Network: {}", l3NetworkUri.build().toString());
+ } else {
+ resourcesClient.delete(l3NetworkUri);
+ }
+ }
+ }
+ }
+
private void createTransactionToDeleteSriovPfFromPserver(List<AAIResourceUri> vserverUris) {
Map<String, List<String>> pserverToPciIdMap = getPserverToPciIdMap(vserverUris);
for (Map.Entry<String, List<String>> entry : pserverToPciIdMap.entrySet()) {