diff options
Diffstat (limited to 'adapters')
10 files changed, 114 insertions, 64 deletions
diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/NvfmAdapterUtils.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/NvfmAdapterUtils.java index a46ad8ffd4..367d8b244f 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/NvfmAdapterUtils.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/NvfmAdapterUtils.java @@ -27,9 +27,13 @@ import org.slf4j.Logger; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -public class NvfmAdapterUtils { +public final class NvfmAdapterUtils { private static Logger logger = getLogger(NvfmAdapterUtils.class); + private NvfmAdapterUtils() { + throw new IllegalStateException("Utility class"); + } + public static JsonObject child(final JsonObject parent, final String name) { return childElement(parent, name).getAsJsonObject(); } diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/EtsiPackageProvider.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/EtsiPackageProvider.java index c5164c1833..ec46af45cd 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/EtsiPackageProvider.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/EtsiPackageProvider.java @@ -63,13 +63,13 @@ public class EtsiPackageProvider { } private String getVnfNodeProperty(final String csarId, final String propertyName) { - logger.debug("Getting " + propertyName + " from " + csarId); + logger.debug("Getting {} from {}", propertyName, csarId); final byte[] onapPackage = getPackage(csarId); try { final String vnfdLocation = getVnfdLocation(new ByteArrayInputStream(onapPackage)); final String onapVnfdContent = getFileInZip(new ByteArrayInputStream(onapPackage), vnfdLocation).toString(); - logger.debug("VNFD CONTENTS: " + onapVnfdContent); + logger.debug("VNFD CONTENTS: {}", onapVnfdContent); final JsonObject root = new Gson().toJsonTree(new Yaml().load(onapVnfdContent)).getAsJsonObject(); final JsonObject topologyTemplates = child(root, "topology_template"); @@ -79,14 +79,14 @@ public class EtsiPackageProvider { String propertyValue = null; if ("tosca.nodes.nfv.VNF".equals(type)) { final JsonObject properties = child(child, "properties"); - logger.debug("properties: " + properties.toString()); - + logger.debug("properties: {}", properties); propertyValue = properties.get(propertyName).getAsJsonPrimitive().getAsString(); + if (propertyValue == null) { + propertyValue = getValueFromNodeTypeDefinition(root, type, propertyName); + } + return propertyValue; } - if (propertyValue == null) { - propertyValue = getValueFromNodeTypeDefinition(root, type, propertyName); - } - return propertyValue; + } } catch (final Exception e) { @@ -102,10 +102,10 @@ public class EtsiPackageProvider { if ("tosca.nodes.nfv.VNF".equals(childElement(nodeType, "derived_from").getAsString())) { final JsonObject properties = child(nodeType, "properties"); - logger.debug("properties: " + properties.toString()); + logger.debug("properties: {}", properties); final JsonObject property = child(properties, propertyName); - logger.debug("property: " + property.toString()); - logger.debug("property default: " + childElement(property, "default").toString()); + logger.debug("property: {}", property); + logger.debug("property default: {}", childElement(property, "default")); return childElement(property, "default").getAsJsonPrimitive().getAsString(); } return null; diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/vnfm/VnfmServiceProviderImpl.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/vnfm/VnfmServiceProviderImpl.java index 6ad5c16e4c..6e0978a106 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/vnfm/VnfmServiceProviderImpl.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/vnfm/VnfmServiceProviderImpl.java @@ -40,10 +40,14 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import com.google.common.base.Optional; +import java.util.List; @Service public class VnfmServiceProviderImpl implements VnfmServiceProvider { private static final Logger logger = LoggerFactory.getLogger(VnfmServiceProviderImpl.class); + private static final String MESSAGE_RESULTED_IN_EXCEPTION = " resulted in exception"; + private static final String MESSAGE_REQUEST = ", request: "; + private static final String MESSAGE_TERMINATE_REQUEST_TO = "Terminate request to "; private final VnfmServiceProviderConfiguration vnfmServiceProviderConfiguration; private final VnfmUrlProvider urlProvider; @@ -63,25 +67,24 @@ public class VnfmServiceProviderImpl implements VnfmServiceProvider { @Override public String instantiateVnf(final EsrVnfm vnfm, final String vnfSelfLink, final InstantiateVnfRequest instantiateVnfRequest) { - logger.debug("Sending instantiate request " + instantiateVnfRequest + " to : " + vnfSelfLink); - + logger.debug("Sending instantiate request {} to : {}", instantiateVnfRequest, vnfSelfLink); ResponseEntity<Void> response = null; try { response = getHttpServiceProvider(vnfm).postHttpRequest(instantiateVnfRequest, vnfSelfLink + "/instantiate", Void.class); } catch (final Exception exception) { final String errorMessage = - "Instantiate request to " + vnfSelfLink + " resulted in exception" + instantiateVnfRequest; - logger.error(errorMessage, exception); + "Instantiate request to " + vnfSelfLink + MESSAGE_RESULTED_IN_EXCEPTION + instantiateVnfRequest; + logger.error(errorMessage); throw new VnfmRequestFailureException(errorMessage, exception); } if (response.getStatusCode() != HttpStatus.ACCEPTED) { final String errorMessage = "Instantiate request to " + vnfSelfLink + " returned status code: " - + response.getStatusCode() + ", request: " + instantiateVnfRequest; + + response.getStatusCode() + MESSAGE_REQUEST + instantiateVnfRequest; logger.error(errorMessage); throw new VnfmRequestFailureException(errorMessage); } - final String locationHeader = response.getHeaders().get("Location").iterator().next(); + String locationHeader = getLocationHeader(response); return locationHeader.substring(locationHeader.lastIndexOf("/") + 1); } @@ -96,13 +99,13 @@ public class VnfmServiceProviderImpl implements VnfmServiceProvider { logger.info("Subscribing for notifications response {}", response); } catch (final Exception exception) { final String errorMessage = - "Subscription to VNFM " + vnfm.getVnfmId() + " resulted in exception" + subscriptionRequest; - logger.error(errorMessage, exception); + "Subscription to VNFM " + vnfm.getVnfmId() + MESSAGE_RESULTED_IN_EXCEPTION + subscriptionRequest; + logger.error(errorMessage); throw new VnfmRequestFailureException(errorMessage, exception); } if (response.getStatusCode() != HttpStatus.CREATED) { final String errorMessage = "Subscription to VNFM " + vnfm.getVnfmId() + " returned status code: " - + response.getStatusCode() + ", request: " + subscriptionRequest; + + response.getStatusCode() + MESSAGE_REQUEST + subscriptionRequest; logger.error(errorMessage); throw new VnfmRequestFailureException(errorMessage); } @@ -112,8 +115,7 @@ public class VnfmServiceProviderImpl implements VnfmServiceProvider { @Override public String terminateVnf(final EsrVnfm vnfm, final String vnfSelfLink, final TerminateVnfRequest terminateVnfRequest) { - logger.debug("Sending terminate request " + terminateVnfRequest + " to : " + vnfSelfLink); - + logger.debug("Sending terminate request {} to : {}", terminateVnfRequest, vnfSelfLink); ResponseEntity<Void> response = null; try { response = getHttpServiceProvider(vnfm).postHttpRequest(terminateVnfRequest, vnfSelfLink + "/terminate", @@ -124,26 +126,26 @@ public class VnfmServiceProviderImpl implements VnfmServiceProvider { if (vnf.getInstantiationState().equals(InstantiationStateEnum.NOT_INSTANTIATED)) { return JobManager.ALREADY_COMPLETED_OPERATION_ID; } else { - final String errorMessage = - "Terminate request to " + vnfSelfLink + " resulted in exception" + terminateVnfRequest; + final String errorMessage = MESSAGE_TERMINATE_REQUEST_TO + vnfSelfLink + + MESSAGE_RESULTED_IN_EXCEPTION + terminateVnfRequest; logger.error(errorMessage, restProcessingException); throw new VnfmRequestFailureException(errorMessage, restProcessingException); } } } catch (final Exception exception) { final String errorMessage = - "Terminate request to " + vnfSelfLink + " resulted in exception" + terminateVnfRequest; - logger.error(errorMessage, exception); + MESSAGE_TERMINATE_REQUEST_TO + vnfSelfLink + MESSAGE_RESULTED_IN_EXCEPTION + terminateVnfRequest; + logger.error(errorMessage); throw new VnfmRequestFailureException(errorMessage, exception); } checkIfResponseIsAcceptable(response, vnfSelfLink, terminateVnfRequest); - final String locationHeader = response.getHeaders().get("Location").iterator().next(); + String locationHeader = getLocationHeader(response); return locationHeader.substring(locationHeader.lastIndexOf("/") + 1); } @Override public void deleteVnf(final EsrVnfm vnfm, final String vnfSelfLink) { - logger.debug("Sending delete request to : " + vnfSelfLink); + logger.debug("Sending delete request to : {}", vnfSelfLink); final ResponseEntity<Void> response = getHttpServiceProvider(vnfm).deleteHttpRequest(vnfSelfLink, Void.class); if (response.getStatusCode() != HttpStatus.NO_CONTENT) { throw new VnfmRequestFailureException( @@ -165,8 +167,8 @@ public class VnfmServiceProviderImpl implements VnfmServiceProvider { return getHttpServiceProvider(vnfm).post(createVnfRequest, url, InlineResponse201.class); } catch (final Exception exception) { final String errorMessage = - "Create request to vnfm:" + vnfm.getVnfmId() + " resulted in exception" + createVnfRequest; - logger.error(errorMessage, exception); + "Create request to vnfm:" + vnfm.getVnfmId() + MESSAGE_RESULTED_IN_EXCEPTION + createVnfRequest; + logger.error(errorMessage); throw new VnfmRequestFailureException(errorMessage, exception); } } @@ -174,14 +176,14 @@ public class VnfmServiceProviderImpl implements VnfmServiceProvider { private void checkIfResponseIsAcceptable(final ResponseEntity<Void> response, final String vnfSelfLink, final TerminateVnfRequest terminateVnfRequest) { if (response == null) { - final String errorMessage = - "Terminate request to " + vnfSelfLink + ", response is null, " + "request: " + terminateVnfRequest; + final String errorMessage = MESSAGE_TERMINATE_REQUEST_TO + vnfSelfLink + ", response is null, " + + "request: " + terminateVnfRequest; logger.error(errorMessage); throw new VnfmRequestFailureException(errorMessage); } if (response.getStatusCode() != HttpStatus.ACCEPTED) { - final String errorMessage = "Terminate request to " + vnfSelfLink + ", returned status code: " - + response.getStatusCode() + ", request: " + terminateVnfRequest; + final String errorMessage = MESSAGE_TERMINATE_REQUEST_TO + vnfSelfLink + ", returned status code: " + + response.getStatusCode() + MESSAGE_REQUEST + terminateVnfRequest; logger.error(errorMessage); throw new VnfmRequestFailureException(errorMessage); } @@ -191,4 +193,11 @@ public class VnfmServiceProviderImpl implements VnfmServiceProvider { return vnfmServiceProviderConfiguration.getHttpRestServiceProvider(vnfm); } + private String getLocationHeader(ResponseEntity<Void> response) { + List<String> headers = response.getHeaders().get("Location"); + if ((headers == null) || (headers.isEmpty())) { + throw new VnfmRequestFailureException("No headers found in response"); + } + return headers.iterator().next(); + } } diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.9__EnforceNotNullWithDefaults.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.9__EnforceNotNullWithDefaults.sql new file mode 100644 index 0000000000..068ffc447e --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V8.9__EnforceNotNullWithDefaults.sql @@ -0,0 +1,25 @@ +use catalogdb; + +UPDATE network_resource SET ORCHESTRATION_MODE = 'HEAT' WHERE ORCHESTRATION_MODE IS NULL; +UPDATE vf_module_customization SET INITIAL_COUNT = '0' WHERE INITIAL_COUNT IS NULL; +UPDATE vf_module_customization SET MIN_INSTANCES = '0' WHERE MIN_INSTANCES IS NULL; +UPDATE workflow SET ARTIFACT_CHECKSUM = 'RECORD' WHERE ARTIFACT_CHECKSUM IS NULL; +UPDATE identity_services SET ADMIN_PROJECT_DOMAIN_NAME = 'Default' WHERE ADMIN_PROJECT_DOMAIN_NAME IS NULL; +UPDATE vnf_resource_customization SET SKIP_POST_INSTANTIATION_CONFIGURATION = true WHERE SKIP_POST_INSTANTIATION_CONFIGURATION IS NULL; +UPDATE pnf_resource_customization SET SKIP_POST_INSTANTIATION_CONFIGURATION = true WHERE SKIP_POST_INSTANTIATION_CONFIGURATION IS NULL; +UPDATE vnf_resource_customization SET NF_DATA_VALID = 0 WHERE NF_DATA_VALID IS NULL; +UPDATE cloud_sites SET SUPPORT_FABRIC = 1 WHERE SUPPORT_FABRIC IS NULL; +UPDATE service SET SKIP_POST_INSTANTIATION_CONFIGURATION = true WHERE SKIP_POST_INSTANTIATION_CONFIGURATION IS NULL; +UPDATE vf_module_customization SET SKIP_POST_INSTANTIATION_CONFIGURATION = true WHERE SKIP_POST_INSTANTIATION_CONFIGURATION IS NULL; + +ALTER TABLE network_resource MODIFY ORCHESTRATION_MODE varchar(20) NOT NULL DEFAULT 'HEAT'; +ALTER TABLE vf_module_customization MODIFY INITIAL_COUNT int(11) NOT NULL DEFAULT '0'; +ALTER TABLE vf_module_customization MODIFY MIN_INSTANCES int(11) NOT NULL DEFAULT '0'; +ALTER TABLE workflow MODIFY ARTIFACT_CHECKSUM VARCHAR(200) NOT NULL DEFAULT 'MANUAL RECORD'; +ALTER TABLE identity_services MODIFY ADMIN_PROJECT_DOMAIN_NAME varchar(255) NOT NULL DEFAULT 'Default'; +ALTER TABLE vnf_resource_customization MODIFY SKIP_POST_INSTANTIATION_CONFIGURATION boolean NOT NULL DEFAULT true; +ALTER TABLE pnf_resource_customization MODIFY SKIP_POST_INSTANTIATION_CONFIGURATION boolean NOT NULL DEFAULT true; +ALTER TABLE vnf_resource_customization MODIFY NF_DATA_VALID tinyint(1) NOT NULL DEFAULT 0; +ALTER TABLE cloud_sites MODIFY SUPPORT_FABRIC bit(1) NOT NULL DEFAULT 1; +ALTER TABLE service MODIFY SKIP_POST_INSTANTIATION_CONFIGURATION boolean NOT NULL DEFAULT true; +ALTER TABLE vf_module_customization MODIFY SKIP_POST_INSTANTIATION_CONFIGURATION boolean NOT NULL DEFAULT true;
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java index d6f2c6dbcc..c202170235 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java @@ -197,7 +197,8 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { assertNotNull(vnfResourceCustomization.getVnfResources()); assertNotNull(vnfResourceCustomization.getVfModuleCustomizations()); assertEquals("vSAMP10a", vnfResourceCustomization.getVnfResources().getModelName()); - assertTrue("skip post instantiation configuration", vnfResourceCustomization.isSkipPostInstConf()); + assertTrue("skip post instantiation configuration", + vnfResourceCustomization.isSkipPostInstConf().booleanValue()); } @Test diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/ExpectedService.json b/adapters/mso-catalog-db-adapter/src/test/resources/ExpectedService.json index 2dc83c8963..c99b185557 100644 --- a/adapters/mso-catalog-db-adapter/src/test/resources/ExpectedService.json +++ b/adapters/mso-catalog-db-adapter/src/test/resources/ExpectedService.json @@ -31,6 +31,7 @@ "cloudVersionMax": "cloudVersionMax", "category": "category", "subCategory": "subCategory", + "nfDataValid": false, "vfModule": [ { "modelVersionId": "modelUUID", 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`) |