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
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 14d0b0a..0dd7635 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 @@
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 @@
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 f904788..f9bbf4a 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 @@
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 9b20139..0512912 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.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 @@
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 @@
}
}
+ 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()) {