summaryrefslogtreecommitdiffstats
path: root/adapters/mso-openstack-adapters/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-openstack-adapters/src/main')
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java23
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryTask.java3
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java52
3 files changed, 46 insertions, 32 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java
index 15c5eda054..1f0422b0b2 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java
@@ -47,20 +47,19 @@ public class DeleteAAIInventory {
@Autowired
protected Environment env;
- public void heatbridge(CloudInformation cloudInformation, boolean dryrun) {
+ public void heatbridge(CloudInformation cloudInformation) {
try {
- if (!dryrun) {
- logger.debug("Heatbridge delete executing");
+ logger.debug("Heatbridge delete executing");
+
+ CloudSite cloudSite = cloudConfig.getCloudSite(cloudInformation.getRegionId())
+ .orElseThrow(() -> new MsoCloudSiteNotFound(cloudInformation.getRegionId()));
+ CloudIdentity cloudIdentity = cloudSite.getIdentityService();
+ HeatBridgeApi heatBridgeClient =
+ new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity, cloudInformation.getOwner(),
+ cloudInformation.getRegionId(), cloudSite.getRegionId(), cloudInformation.getTenantId());
+ heatBridgeClient.authenticate();
+ heatBridgeClient.deleteVfModuleData(cloudInformation.getVnfId(), cloudInformation.getVfModuleId());
- CloudSite cloudSite = cloudConfig.getCloudSite(cloudInformation.getRegionId())
- .orElseThrow(() -> new MsoCloudSiteNotFound(cloudInformation.getRegionId()));
- CloudIdentity cloudIdentity = cloudSite.getIdentityService();
- HeatBridgeApi heatBridgeClient = new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity,
- cloudInformation.getOwner(), cloudInformation.getRegionId(), cloudSite.getRegionId(),
- cloudInformation.getTenantId());
- heatBridgeClient.authenticate();
- heatBridgeClient.deleteVfModuleData(cloudInformation.getVnfId(), cloudInformation.getVfModuleId());
- }
} catch (Exception ex) {
logger.debug("Heatbrige failed for stackId: " + cloudInformation.getTemplateInstanceId(), ex);
}
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryTask.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryTask.java
index c5feee2089..10faa2b08f 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryTask.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryTask.java
@@ -60,14 +60,13 @@ public class DeleteInventoryTask extends ExternalTaskUtils {
protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
mdcSetup.setupMDC(externalTask);
- boolean inventoryException = false;
String externalTaskId = externalTask.getId();
CloudInformation cloudInformation = externalTask.getVariable("cloudInformation");
boolean success = true;
if (cloudInformation != null) {
Integer retryCount = externalTask.getRetries();
try {
- deleteInventory.heatbridge(cloudInformation, env.getProperty("heatBridgeDryrun", Boolean.class, true));
+ deleteInventory.heatbridge(cloudInformation);
} catch (Exception e) {
logger.error("Error during inventory of stack", e);
success = false;
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 f37555392a..b6b468be1e 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
@@ -42,6 +42,7 @@ import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
+import javax.ws.rs.NotFoundException;
import javax.ws.rs.WebApplicationException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.validator.routines.InetAddressValidator;
@@ -473,27 +474,34 @@ public class HeatBridgeImpl implements HeatBridgeApi {
Objects.requireNonNull(vnfId, "Null vnf-id!");
Objects.requireNonNull(vfModuleId, "Null vf-module-id!");
try {
- Optional<VfModule> vfModule = resourcesClient.get(VfModule.class,
- AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId).depth(Depth.ONE));
- logger.debug("vfModule is present: {}", vfModule.isPresent());
- if (vfModule.isPresent()) {
-
- AAIResultWrapper resultWrapper = new AAIResultWrapper(vfModule.get());
- Optional<Relationships> relationships = resultWrapper.getRelationships();
- logger.debug("relationships is present: {}", relationships.isPresent());
- if (relationships.isPresent()) {
- List<AAIResourceUri> vserverUris = relationships.get().getRelatedUris(AAIObjectType.VSERVER);
- logger.debug("vserverList isEmpty: {}", vserverUris.isEmpty());
- createTransactionToDeleteSriovPfFromPserver(vserverUris);
-
- if (!vserverUris.isEmpty()) {
- for (AAIResourceUri vserverUri : vserverUris) {
- logger.debug("Deleting Vservers: {}", vserverUri.toString());
+ Optional<VfModule> vfModule = resourcesClient.get(
+ AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId, NotFoundException.class)
+ .depth(Depth.ONE))
+ .asBean(VfModule.class);
+
+ AAIResultWrapper resultWrapper = new AAIResultWrapper(vfModule.get());
+ Optional<Relationships> relationships = resultWrapper.getRelationships();
+ logger.debug("VfModule contains relationships in AAI: {}", relationships.isPresent());
+ if (relationships.isPresent()) {
+ List<AAIResourceUri> vserverUris = relationships.get().getRelatedUris(AAIObjectType.VSERVER);
+ logger.debug("VServer contains {} relationships in AAI", vserverUris.size());
+ createTransactionToDeleteSriovPfFromPserver(vserverUris);
+
+ if (!vserverUris.isEmpty()) {
+ for (AAIResourceUri vserverUri : vserverUris) {
+ if (env.getProperty("heatBridgeDryrun", Boolean.class, true)) {
+ logger.debug("Would delete Vserver: {}", vserverUri.build().toString());
+ } else {
resourcesClient.delete(vserverUri);
}
}
}
}
+
+ } catch (NotFoundException e) {
+ String msg = "Failed to commit delete heatbridge data transaction";
+ logger.debug(msg + " with error: " + e);
+ throw new HeatBridgeException(msg, e);
} catch (Exception e) {
String msg = "Failed to commit delete heatbridge data transaction";
logger.debug(msg + " with error: " + e);
@@ -516,8 +524,16 @@ public class HeatBridgeImpl implements HeatBridgeApi {
if (pciIds.contains(sriovPf.getPfPciId())) {
logger.debug("creating transaction to delete SR-IOV PF: " + pIf.getInterfaceName()
+ " from PServer: " + pserverName);
- resourcesClient.delete(AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_PF,
- pserverName, pIf.getInterfaceName(), sriovPf.getPfPciId()));
+ if (env.getProperty("heatBridgeDryrun", Boolean.class, true)) {
+ logger.debug("Would delete Sriov Pf: {}",
+ AAIUriFactory
+ .createResourceUri(AAIObjectType.SRIOV_PF, pserverName,
+ pIf.getInterfaceName(), sriovPf.getPfPciId())
+ .build().toString());
+ } else {
+ resourcesClient.delete(AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_PF,
+ pserverName, pIf.getInterfaceName(), sriovPf.getPfPciId()));
+ }
}
}));
}