summaryrefslogtreecommitdiffstats
path: root/adapters/mso-openstack-adapters
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-openstack-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
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/schema.sql8
4 files changed, 38 insertions, 28 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()) {
diff --git a/adapters/mso-openstack-adapters/src/test/resources/schema.sql b/adapters/mso-openstack-adapters/src/test/resources/schema.sql
index 3357fec109..44fbbd9be6 100644
--- a/adapters/mso-openstack-adapters/src/test/resources/schema.sql
+++ b/adapters/mso-openstack-adapters/src/test/resources/schema.sql
@@ -648,7 +648,7 @@ CREATE TABLE `network_resource` (
`TOSCA_NODE_TYPE` varchar(200) DEFAULT NULL,
`AIC_VERSION_MIN` varchar(20) NULL,
`AIC_VERSION_MAX` varchar(20) DEFAULT NULL,
- `ORCHESTRATION_MODE` varchar(20) DEFAULT 'HEAT',
+ `ORCHESTRATION_MODE` varchar(20) NOT NULL DEFAULT 'HEAT',
`CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`RESOURCE_CATEGORY` varchar(200) DEFAULT NULL,
`RESOURCE_SUB_CATEGORY` varchar(200) DEFAULT NULL,
@@ -958,8 +958,8 @@ CREATE TABLE `vf_module_customization` (
`ID` int(13) NOT NULL AUTO_INCREMENT,
`MODEL_CUSTOMIZATION_UUID` varchar(200) NOT NULL,
`LABEL` varchar(200) DEFAULT NULL,
- `INITIAL_COUNT` int(11) DEFAULT '0',
- `MIN_INSTANCES` int(11) DEFAULT '0',
+ `INITIAL_COUNT` int(11) NOT NULL DEFAULT '0',
+ `MIN_INSTANCES` int(11) NOT NULL DEFAULT '0',
`MAX_INSTANCES` int(11) DEFAULT NULL,
`AVAILABILITY_ZONE_COUNT` int(11) DEFAULT NULL,
`HEAT_ENVIRONMENT_ARTIFACT_UUID` varchar(200) DEFAULT NULL,
@@ -1233,7 +1233,7 @@ CREATE TABLE IF NOT EXISTS `workflow` (
`RESOURCE_TARGET` varchar(200) NOT NULL,
`SOURCE` varchar(200) NOT NULL,
`TIMEOUT_MINUTES` int(11) DEFAULT NULL,
- `ARTIFACT_CHECKSUM` varchar(200) DEFAULT 'MANUAL RECORD',
+ `ARTIFACT_CHECKSUM` varchar(200) NOT NULL DEFAULT 'MANUAL RECORD',
`CREATION_TIMESTAMP` datetime NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (`ID`),
UNIQUE KEY `UK_workflow` (`ARTIFACT_UUID`,`NAME`,`VERSION`,`SOURCE`)