diff options
Diffstat (limited to 'adapters')
7 files changed, 86 insertions, 40 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/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/openstack/AaiClientPropertiesImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/AaiClientPropertiesImpl.java index cd32cc208a..79d5824de7 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/AaiClientPropertiesImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/AaiClientPropertiesImpl.java @@ -34,6 +34,7 @@ public class AaiClientPropertiesImpl implements AAIProperties { private String auth; private String key; private Long readTimeout; + private Long connectionTimeout; private boolean enableCaching; private Long cacheMaxAge; private static final String SYSTEM_NAME = "MSO"; @@ -43,7 +44,8 @@ public class AaiClientPropertiesImpl implements AAIProperties { aaiEndpoint = context.getEnvironment().getProperty("aai.endpoint"); this.auth = context.getEnvironment().getProperty("aai.auth"); this.key = context.getEnvironment().getProperty("mso.msoKey"); - this.readTimeout = context.getEnvironment().getProperty("aai.readTimeout", Long.class, new Long(60000)); + this.readTimeout = context.getEnvironment().getProperty("aai.readTimeout", Long.class, 60000L); + this.connectionTimeout = context.getEnvironment().getProperty("aai.connectionTimeout", Long.class, 60000L); this.enableCaching = context.getEnvironment().getProperty("aai.caching.enabled", Boolean.class, false); this.cacheMaxAge = context.getEnvironment().getProperty("aai.caching.maxAge", Long.class, 60000L); } @@ -79,6 +81,11 @@ public class AaiClientPropertiesImpl implements AAIProperties { } @Override + public Long getConnectionTimeout() { + return this.connectionTimeout; + } + + @Override public boolean isCachingEnabled() { return this.enableCaching; } 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`) |