summaryrefslogtreecommitdiffstats
path: root/adapters
diff options
context:
space:
mode:
Diffstat (limited to 'adapters')
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java30
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java3
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java2
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java2
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java1
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceMapper.java128
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java76
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/manual/Migrate_Distrobution_Status.sql11
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.6.6__Add_Column_For_Distrobution_Status.sql1
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/ServiceMapperTest.java134
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java1
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/resources/ExpectedService.json52
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/AllTestsTestSuite.java (renamed from adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/AllTestsTestSuite.java)2
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/schema.sql2
14 files changed, 425 insertions, 20 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java
index 0a0f2787da..dd43837c76 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java
@@ -109,6 +109,8 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin {
private static final String DELETE_DEPLOYMENT = "DeleteDeployment";
private static final String TERMINATED = "terminated";
private static final String CANCELLED = "cancelled";
+ private static final String UNINSTALL = "uninstall";
+ private static final String UPLOAD_BLUEPRINT = "UPLOAD_BLUEPRINT";
// Fetch cloud configuration each time (may be cached in CloudConfig class)
@Autowired
@@ -181,11 +183,11 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin {
Map<String, Object> expandedInputs = new HashMap<>(inputs);
String platform = cloudSite.get().getPlatform();
- if (platform == null || platform.equals("") || platform.equalsIgnoreCase("OPENSTACK")) {
+ if (platform == null || platform.isEmpty() || ("OPENSTACK").equalsIgnoreCase(platform)) {
// Create the Cloudify OpenstackConfig with the credentials
OpenstackConfig openstackConfig = getOpenstackConfig(cloudSite.get(), tenantId);
expandedInputs.put("openstack_config", openstackConfig);
- } else if (platform.equalsIgnoreCase("AZURE")) {
+ } else if (("AZURE").equalsIgnoreCase(platform)) {
// Create Cloudify AzureConfig with the credentials
AzureConfig azureConfig = getAzureConfig(cloudSite.get(), tenantId);
expandedInputs.put("azure_config", azureConfig);
@@ -265,7 +267,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin {
try {
// Run the uninstall to undo the install
- Execution uninstallWorkflow = executeWorkflow(cloudify, deploymentId, "uninstall", null,
+ Execution uninstallWorkflow = executeWorkflow(cloudify, deploymentId, UNINSTALL, null,
pollForCompletion, deletePollTimeout, deletePollInterval);
if (uninstallWorkflow.getStatus().equals(TERMINATED)) {
@@ -306,7 +308,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin {
try {
// Run the uninstall to undo the install.
// Always try to run it, as it should be idempotent
- executeWorkflow(cloudify, deploymentId, "uninstall", null, pollForCompletion, deletePollTimeout,
+ executeWorkflow(cloudify, deploymentId, UNINSTALL, null, pollForCompletion, deletePollTimeout,
deletePollInterval);
// Delete the deployment itself
@@ -402,7 +404,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin {
GetExecution queryExecution = cloudify.executions().byId(executionId);
command = "query";
- while (!timedOut && !(status.equals(TERMINATED) || status.equals("failed") || status.equals(CANCELLED))) {
+ while (!timedOut && !(status.equals(TERMINATED) || ("failed").equals(status) || status.equals(CANCELLED))) {
// workflow is still running; check for timeout
if (pollTimeout <= 0) {
logger.debug("workflow {} timed out on deployment {}", execution.getWorkflowId(),
@@ -425,7 +427,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin {
// Success!
logger.debug("Workflow '{}' completed successfully on deployment '{}'", workflowId, deploymentId);
return execution;
- } else if (status.equals("failed")) {
+ } else if (("failed").equals(status)) {
// Workflow failed. Log it and return the execution object (don't throw exception here)
logger.error("{} Cloudify workflow failure: {} {} Execute Workflow: Failed: {}",
MessageEnum.RA_CREATE_STACK_ERR, execution.getError(),
@@ -665,7 +667,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin {
try {
uninstallWorkflow =
- executeWorkflow(cloudify, deploymentId, "uninstall", null, true, pollTimeout, deletePollInterval);
+ executeWorkflow(cloudify, deploymentId, UNINSTALL, null, true, pollTimeout, deletePollInterval);
if (uninstallWorkflow.getStatus().equals(TERMINATED)) {
// Successful uninstall.
@@ -812,7 +814,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin {
try {
// Put the root directory
- String rootDir = blueprintId + ((blueprintId.endsWith("/") ? "" : "/"));
+ String rootDir = blueprintId + (blueprintId.endsWith("/") ? "" : "/");
zipOut.putNextEntry(new ZipEntry(rootDir));
zipOut.closeEntry();
@@ -836,13 +838,13 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin {
Blueprint blueprint = uploadRequest.execute();
logger.debug("Successfully uploaded blueprint {}", blueprint.getId());
} catch (CloudifyResponseException | CloudifyConnectException e) {
- throw cloudifyExceptionToMsoException(e, "UPLOAD_BLUEPRINT");
+ throw cloudifyExceptionToMsoException(e, UPLOAD_BLUEPRINT);
} catch (RuntimeException e) {
// Catch-all
- throw runtimeExceptionToMsoException(e, "UPLOAD_BLUEPRINT");
+ throw runtimeExceptionToMsoException(e, UPLOAD_BLUEPRINT);
} catch (IOException e) {
// for try-with-resources
- throw ioExceptionToMsoException(e, "UPLOAD_BLUEPRINT");
+ throw ioExceptionToMsoException(e, UPLOAD_BLUEPRINT);
}
return true;
@@ -960,14 +962,14 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin {
String type = templateParam.getParamType();
logger.debug("Parameter: {} is of type {}", templateParam.getParamName(), type);
- if (type.equalsIgnoreCase("number")) {
+ if (("number").equalsIgnoreCase(type)) {
try {
return Integer.valueOf(inputValue.toString());
} catch (Exception e) {
logger.debug("Unable to convert {} to an integer!", inputValue);
return null;
}
- } else if (type.equalsIgnoreCase("json")) {
+ } else if (("json").equalsIgnoreCase(type)) {
try {
if (inputValue instanceof String) {
return JSON_MAPPER.readTree(inputValue.toString());
@@ -978,7 +980,7 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin {
logger.debug("Unable to convert {} to a JsonNode!", inputValue);
return null;
}
- } else if (type.equalsIgnoreCase("boolean")) {
+ } else if (("boolean").equalsIgnoreCase(type)) {
return new Boolean(inputValue.toString());
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java
index c9a548d5f1..79c042b10b 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoCommonUtils.java
@@ -67,9 +67,6 @@ public class MsoCommonUtils {
protected <T> T executeAndRecordOpenstackRequest(OpenStackRequest<T> request) {
- int limit;
-
- long start = System.currentTimeMillis();
String requestType;
if (request.getClass().getEnclosingClass() != null) {
requestType =
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java
index db73d4afec..0e526e59fb 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java
@@ -24,6 +24,7 @@ import javax.annotation.PostConstruct;
import javax.ws.rs.ApplicationPath;
import org.glassfish.jersey.server.ResourceConfig;
import org.onap.so.adapters.catalogdb.rest.CatalogDbAdapterRest;
+import org.onap.so.adapters.catalogdb.rest.ServiceRestImpl;
import org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging;
import org.springframework.context.annotation.Configuration;
import io.swagger.jaxrs.config.BeanConfig;
@@ -40,6 +41,7 @@ public class JerseyConfiguration extends ResourceConfig {
register(ApiListingResource.class);
register(SwaggerSerializers.class);
register(JaxRsFilterLogging.class);
+ register(ServiceRestImpl.class);
BeanConfig beanConfig = new BeanConfig();
beanConfig.setVersion("1.0.2");
beanConfig.setSchemes(new String[] {"http"});
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java
index e5241a4e95..a0d822d394 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java
@@ -49,6 +49,7 @@ public class QueryServiceVnfs extends CatalogQuery {
+ "\t\"nfFunction\" : <NF_FUNCTION>,\n" + "\t\"nfType\" : <NF_TYPE>,\n"
+ "\t\"nfRole\" : <NF_ROLE>,\n" + "\t\"nfNamingCode\" : <NF_NAMING_CODE>,\n"
+ "\t\"multiStageDesign\" : <MULTI_STEP_DESIGN>,\n"
+ + "\t\"vnfcInstGroupOrder\" : <VNFC_INSTANCE_GROUP_ORDER>,\n"
+ "\t\"resourceInput\" : <RESOURCE_INPUT>,\n" + "<_VFMODULES_>,\n" + "<_GROUPS_>\n" + "\t}";
public QueryServiceVnfs() {
@@ -118,6 +119,7 @@ public class QueryServiceVnfs extends CatalogQuery {
put(valueMap, "NF_TYPE", o.getNfType());
put(valueMap, "NF_ROLE", o.getNfRole());
put(valueMap, "NF_NAMING_CODE", o.getNfNamingCode());
+ put(valueMap, "VNFC_INSTANCE_GROUP_ORDER", o.getVnfcInstanceGroupOrder());
put(valueMap, "MULTI_STEP_DESIGN", o.getMultiStageDesign());
put(valueMap, "RESOURCE_INPUT", o.getResourceInput());
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java
index 6cc53e6ec9..589f119337 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java
@@ -279,6 +279,7 @@ public class CatalogDbAdapterRest {
@QueryParam("serviceModelUuid") String modelUUID,
@QueryParam("serviceModelInvariantUuid") String modelInvariantUUID,
@QueryParam("serviceModelVersion") String modelVersion) {
+
QueryServiceMacroHolder qryResp;
int respStatus = HttpStatus.SC_OK;
String uuid = "";
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceMapper.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceMapper.java
new file mode 100644
index 0000000000..dd18767762
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceMapper.java
@@ -0,0 +1,128 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.catalogdb.rest;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.onap.so.db.catalog.beans.HeatEnvironment;
+import org.onap.so.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.rest.catalog.beans.Service;
+import org.onap.so.rest.catalog.beans.VfModule;
+import org.onap.so.rest.catalog.beans.Vnf;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+
+
+@Component
+public class ServiceMapper {
+ private static final Logger logger = LoggerFactory.getLogger(ServiceMapper.class);
+
+ public Service mapService(org.onap.so.db.catalog.beans.Service service, int depth) {
+ Service restService = new Service();
+ restService.setCategory(service.getCategory());
+ restService.setCreated(service.getCreated());
+ restService.setDescription(service.getDescription());
+ restService.setDistrobutionStatus(service.getDistrobutionStatus());
+ restService.setEnvironmentContext(service.getEnvironmentContext());
+ restService.setModelInvariantId(service.getModelInvariantUUID());
+ restService.setModelName(service.getModelName());
+ restService.setModelVersionId(service.getModelUUID());
+ restService.setModelVersion(service.getModelVersion());
+ restService.setServiceRole(service.getServiceRole());
+ restService.setServiceType(service.getServiceType());
+ restService.setWorkloadContext(service.getWorkloadContext());
+ if (depth > 0)
+ restService.setVnf(mapVnfs(service, depth));
+ return restService;
+ }
+
+ private List<Vnf> mapVnfs(org.onap.so.db.catalog.beans.Service service, int depth) {
+ List<Vnf> vnfs = new ArrayList<>();
+ logger.info("Vnf Count : {}", service.getVnfCustomizations().size());
+ service.getVnfCustomizations().parallelStream().forEach(vnf -> vnfs.add(mapVnf(vnf, depth)));
+ return vnfs;
+ }
+
+ private Vnf mapVnf(org.onap.so.db.catalog.beans.VnfResourceCustomization vnfResourceCustomization, int depth) {
+ Vnf vnf = new Vnf();
+ vnf.setAvailabilityZoneMaxCount(vnfResourceCustomization.getAvailabilityZoneMaxCount());
+ vnf.setCategory(vnfResourceCustomization.getVnfResources().getCategory());
+ vnf.setCloudVersionMax(vnfResourceCustomization.getVnfResources().getAicVersionMax());
+ vnf.setCloudVersionMin(vnfResourceCustomization.getVnfResources().getAicVersionMin());
+ vnf.setMaxInstances(vnfResourceCustomization.getMaxInstances());
+ vnf.setMinInstances(vnfResourceCustomization.getMinInstances());
+ vnf.setModelCustomizationId(vnfResourceCustomization.getModelCustomizationUUID());
+ vnf.setModelInstanceName(vnfResourceCustomization.getModelInstanceName());
+ vnf.setModelInvariantId(vnfResourceCustomization.getVnfResources().getModelInvariantId());
+ vnf.setModelName(vnfResourceCustomization.getVnfResources().getModelName());
+ vnf.setModelVersionId(vnfResourceCustomization.getVnfResources().getModelUUID());
+ vnf.setModelVersion(vnfResourceCustomization.getVnfResources().getModelVersion());
+ vnf.setMultiStageDesign(vnfResourceCustomization.getMultiStageDesign());
+ vnf.setNfFunction(vnfResourceCustomization.getNfFunction());
+ vnf.setNfNamingCode(vnfResourceCustomization.getNfNamingCode());
+ vnf.setNfRole(vnfResourceCustomization.getNfRole());
+ vnf.setOrchestrationMode(vnfResourceCustomization.getVnfResources().getOrchestrationMode());
+ vnf.setSubCategory(vnfResourceCustomization.getVnfResources().getSubCategory());
+ vnf.setToscaNodeType(vnfResourceCustomization.getVnfResources().getToscaNodeType());
+ if (depth > 1) {
+ vnf.setVfModule(mapVfModules(vnfResourceCustomization, depth));
+ }
+ return vnf;
+ }
+
+ private List<VfModule> mapVfModules(VnfResourceCustomization vnfResourceCustomization, int depth) {
+ List<VfModule> vfModules = new ArrayList<>();
+ vnfResourceCustomization.getVfModuleCustomizations().parallelStream()
+ .forEach(vfModule -> vfModules.add(mapVfModule(vfModule)));
+ return vfModules;
+ }
+
+ private VfModule mapVfModule(VfModuleCustomization vfModuleCust) {
+ VfModule vfModule = new VfModule();
+ vfModule.setAvailabilityZoneCount(vfModuleCust.getAvailabilityZoneCount());
+ vfModule.setCreated(vfModuleCust.getCreated());
+ vfModule.setDescription(vfModuleCust.getVfModule().getDescription());
+ vfModule.setInitialCount(vfModuleCust.getInitialCount());
+ vfModule.setIsBase(vfModuleCust.getVfModule().getIsBase());
+ vfModule.setIsVolumeGroup(getIsVolumeGroup(vfModuleCust));
+ vfModule.setMaxInstances(vfModuleCust.getMaxInstances());
+ vfModule.setMinInstances(vfModuleCust.getMinInstances());
+ vfModule.setLabel(vfModuleCust.getLabel());
+ vfModule.setModelCustomizationId(vfModuleCust.getModelCustomizationUUID());
+ vfModule.setModelInvariantId(vfModuleCust.getVfModule().getModelInvariantUUID());
+ vfModule.setModelName(vfModuleCust.getVfModule().getModelName());
+ vfModule.setModelVersionId(vfModuleCust.getVfModule().getModelUUID());
+ vfModule.setModelVersion(vfModuleCust.getVfModule().getModelVersion());
+ return vfModule;
+ }
+
+ private boolean getIsVolumeGroup(VfModuleCustomization vfModuleCust) {
+ boolean isVolumeGroup = false;
+ HeatEnvironment envt = vfModuleCust.getVolumeHeatEnv();
+ if (envt != null) {
+ isVolumeGroup = true;
+ }
+ return isVolumeGroup;
+ }
+
+}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java
new file mode 100644
index 0000000000..1ca8998396
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.catalogdb.rest;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.onap.so.db.catalog.data.repository.ServiceRepository;
+import org.onap.so.rest.catalog.beans.Service;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+import com.google.common.base.Strings;
+import io.swagger.annotations.ApiOperation;
+
+@Path("/v1/")
+@Component
+public class ServiceRestImpl {
+
+ @Autowired
+ private ServiceRepository serviceRepo;
+
+ @Autowired
+ private ServiceMapper serviceMapper;
+
+ @GET
+ @Path("/services/{modelUUID}")
+ @Produces({MediaType.APPLICATION_JSON})
+ @Transactional(readOnly = true)
+ public Service findService(@PathParam("modelUUID") String modelUUID, @QueryParam("depth") int depth) {
+ org.onap.so.db.catalog.beans.Service service = serviceRepo.findOneByModelUUID(modelUUID);
+ return serviceMapper.mapService(service, depth);
+ }
+
+ @GET
+ @Path("/services")
+ @ApiOperation(value = "Find Service Models", response = Service.class, responseContainer = "List")
+ @Produces({MediaType.APPLICATION_JSON})
+ @Transactional(readOnly = true)
+ public List<Service> queryServices(@QueryParam("modelName") String modelName,
+ @QueryParam("distributionStatus") String distributionStatus, @QueryParam("depth") int depth) {
+ List<Service> services = new ArrayList<>();
+ List<org.onap.so.db.catalog.beans.Service> serviceFromDB = new ArrayList<>();
+ if (!Strings.isNullOrEmpty(modelName) && !Strings.isNullOrEmpty(distributionStatus)) {
+ serviceFromDB = serviceRepo.findByModelNameAndDistrobutionStatus(modelName, distributionStatus);
+ } else if (!Strings.isNullOrEmpty(modelName)) {
+ serviceFromDB = serviceRepo.findByModelName(modelName);
+ }
+ serviceFromDB.stream().forEach(serviceDB -> services.add(serviceMapper.mapService(serviceDB, depth)));
+ return services;
+ }
+}
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/manual/Migrate_Distrobution_Status.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/manual/Migrate_Distrobution_Status.sql
new file mode 100644
index 0000000000..4a9c2cce9f
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/manual/Migrate_Distrobution_Status.sql
@@ -0,0 +1,11 @@
+
+UPDATE catalogdb.service serv SET OVERALL_DISTRIBUTION_STATUS =(
+SELECT wds.DISTRIBUTION_ID_STATUS
+FROM requestdb.watchdog_distributionid_status wds
+INNER JOIN requestdb.watchdog_service_mod_ver_id_lookup wdlook
+ON wds.DISTRIBUTION_ID = wdlook.DISTRIBUTION_ID
+WHERE wdlook.SERVICE_MODEL_VERSION_ID = serv.MODEL_UUID
+ORDER BY wdlook.MODIFY_TIME DESC LIMIT 1);
+
+UPDATE catalogdb.service SET OVERALL_DISTRIBUTION_STATUS = 'DISTRIBUTION_COMPLETE_OK'
+WHERE service.OVERALL_DISTRIBUTION_STATUS = NULL; \ No newline at end of file
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.6.6__Add_Column_For_Distrobution_Status.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.6.6__Add_Column_For_Distrobution_Status.sql
new file mode 100644
index 0000000000..ae416ffbfe
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.6.6__Add_Column_For_Distrobution_Status.sql
@@ -0,0 +1 @@
+ALTER TABLE catalogdb.service ADD COLUMN IF NOT EXISTS OVERALL_DISTRIBUTION_STATUS varchar(45); \ No newline at end of file
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/ServiceMapperTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/ServiceMapperTest.java
new file mode 100644
index 0000000000..b8161de6b2
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/ServiceMapperTest.java
@@ -0,0 +1,134 @@
+package org.onap.so.adapters.catalogdb.catalogrest;
+
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.junit.Test;
+import org.onap.so.adapters.catalogdb.rest.ServiceMapper;
+import org.onap.so.db.catalog.beans.HeatTemplate;
+import org.onap.so.db.catalog.beans.HeatTemplateParam;
+import org.onap.so.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.rest.catalog.beans.Service;
+import wiremock.com.fasterxml.jackson.core.JsonParseException;
+import wiremock.com.fasterxml.jackson.databind.JsonMappingException;
+import wiremock.com.fasterxml.jackson.databind.ObjectMapper;
+
+public class ServiceMapperTest {
+
+ private ServiceMapper serviceMapper = new ServiceMapper();
+
+ @Test
+ public void service_map_test() throws JsonParseException, JsonMappingException, IOException {
+ Service actual = serviceMapper.mapService(getTestService(), 2);
+ assertThat(actual, sameBeanAs(getExpectedService()));
+ }
+
+ private Service getExpectedService() throws JsonParseException, JsonMappingException, IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ return mapper.readValue(getJson("ExpectedService.json"), Service.class);
+ }
+
+
+ private org.onap.so.db.catalog.beans.Service getTestService() {
+ org.onap.so.db.catalog.beans.Service testService = new org.onap.so.db.catalog.beans.Service();
+ testService.setCategory("category");
+ testService.setDescription("description");
+ testService.setDistrobutionStatus("distrobutionStatus");
+ testService.setEnvironmentContext("environmentContext");
+ testService.setModelInvariantUUID("modelInvariantUUID");
+ testService.setModelName("modelName");
+ testService.setModelUUID("modelUUID");
+ testService.setModelVersion("modelVersion");
+ testService.setServiceType("serviceType");
+ testService.setServiceRole("serviceRole");
+ testService.getVnfCustomizations().add(getTestVnfCustomization());
+ return testService;
+ }
+
+ private org.onap.so.db.catalog.beans.VnfResourceCustomization getTestVnfCustomization() {
+ org.onap.so.db.catalog.beans.VnfResourceCustomization test =
+ new org.onap.so.db.catalog.beans.VnfResourceCustomization();
+ test.setId(1);
+ test.setAvailabilityZoneMaxCount(11);
+ test.setMaxInstances(3);
+ test.setMinInstances(1);
+ test.setModelCustomizationUUID("modelCustomizationUUID");
+ test.setModelInstanceName("modelInstanceName");
+ test.setMultiStageDesign("multiStageDesign");
+ test.setNfFunction("nfFunction");
+ test.setNfNamingCode("nfNamingCode");
+ test.setNfRole("nfRole");
+ test.setNfType("nfType");
+ test.setService(new org.onap.so.db.catalog.beans.Service());
+ test.setVnfResources(getTestVnfResource());
+ test.setVfModuleCustomizations(getTestVfModuleCust());
+ return test;
+ }
+
+ private List<VfModuleCustomization> getTestVfModuleCust() {
+ List<VfModuleCustomization> test = new ArrayList<>();
+ VfModuleCustomization testVfMod = new VfModuleCustomization();
+ testVfMod.setAvailabilityZoneCount(10);
+ testVfMod.setInitialCount(1);
+ testVfMod.setLabel("label");
+ testVfMod.setMaxInstances(3);
+ testVfMod.setMinInstances(1);
+ testVfMod.setModelCustomizationUUID("modelCustomizationUUID");
+ org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
+ vfModule.setDescription("description");
+ vfModule.setIsBase(false);
+ vfModule.setModelInvariantUUID("modelInvariantUUID");
+ vfModule.setModelName("modelName");
+ vfModule.setModelUUID("modelUUID");
+ vfModule.setModelVersion("modelVersion");
+ HeatTemplate moduleHeatTemplate = new HeatTemplate();
+ moduleHeatTemplate.setArtifactChecksum("artifactChecksum");
+ moduleHeatTemplate.setArtifactUuid("artifactUuid");
+ List<HeatTemplate> childTemplates;
+ // moduleHeatTemplate.setChildTemplates(childTemplates);
+ moduleHeatTemplate.setDescription("description");
+ Set<HeatTemplateParam> parameters = new HashSet<>();
+ HeatTemplateParam heatParam = new HeatTemplateParam();
+ heatParam.setHeatTemplateArtifactUuid("heatTemplateArtifactUuid");
+ heatParam.setParamAlias("paramAlias");
+ heatParam.setParamName("paramName");
+ heatParam.setParamType("paramType");
+ heatParam.setRequired(false);
+ parameters.add(heatParam);
+ moduleHeatTemplate.setParameters(parameters);
+ moduleHeatTemplate.setTemplateBody("templateBody");
+ moduleHeatTemplate.setTemplateName("templateName");
+ moduleHeatTemplate.setTimeoutMinutes(1000);
+ moduleHeatTemplate.setVersion("version");
+ vfModule.setModuleHeatTemplate(moduleHeatTemplate);
+ testVfMod.setVfModule(vfModule);
+ test.add(testVfMod);
+ return test;
+ }
+
+ private org.onap.so.db.catalog.beans.VnfResource getTestVnfResource() {
+ org.onap.so.db.catalog.beans.VnfResource test = new org.onap.so.db.catalog.beans.VnfResource();
+ test.setCategory("category");
+ test.setDescription("description");
+ test.setModelInvariantUUID("modelInvariantUUID");
+ test.setModelName("modelName");
+ test.setModelUUID("modelUUID");
+ test.setModelVersion("modelVersion");
+ test.setAicVersionMax("cloudVersionMax");
+ test.setAicVersionMin("cloudVersionMin");
+ test.setOrchestrationMode("orchestrationMode");
+ test.setSubCategory("subCategory");
+ test.setToscaNodeType("toscaNodeType");
+ return test;
+ }
+
+ private String getJson(String filename) throws IOException {
+ return new String(Files.readAllBytes(Paths.get("src/test/resources/" + filename)));
+ }
+}
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 51b44b0d3a..4127d07c5f 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
@@ -289,7 +289,6 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
Assert.assertNotNull(vnfResource.getModelInvariantId());
Assert.assertNotNull(vnfResource.getModelVersion());
Assert.assertNotNull(vnfResource.getHeatTemplates());
- Assert.assertNotNull(vnfResource.getVnfResourceCustomizations());
Assert.assertEquals("vSAMP10a", vnfResource.getModelName());
}
diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/ExpectedService.json b/adapters/mso-catalog-db-adapter/src/test/resources/ExpectedService.json
new file mode 100644
index 0000000000..cc5145f0e3
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/test/resources/ExpectedService.json
@@ -0,0 +1,52 @@
+{
+ "modelName": "modelName",
+ "description": "description",
+ "modelVersionId": "modelUUID",
+ "modelInvariantId": "modelInvariantUUID",
+ "modelVersion": "modelVersion",
+ "serviceType": "serviceType",
+ "serviceRole": "serviceRole",
+ "environmentContext": "environmentContext",
+ "category": "category",
+ "distrobutionStatus": "distrobutionStatus",
+ "vnf": [
+ {
+ "modelName": "modelName",
+ "modelVersionId": "modelUUID",
+ "modelInvariantId": "modelInvariantUUID",
+ "modelVersion": "modelVersion",
+ "modelCustomizationId": "modelCustomizationUUID",
+ "modelInstanceName": "modelInstanceName",
+ "minInstances": 1,
+ "maxInstances": 3,
+ "availabilityZoneMaxCount": 11,
+ "toscaNodeType": "toscaNodeType",
+ "nfFunction": "nfFunction",
+ "nfRole": "nfRole",
+ "nfNamingCode": "nfNamingCode",
+ "multiStageDesign": "multiStageDesign",
+ "orchestrationMode": "orchestrationMode",
+ "cloudVersionMin": "cloudVersionMin",
+ "cloudVersionMax": "cloudVersionMax",
+ "category": "category",
+ "subCategory": "subCategory",
+ "vfModule": [
+ {
+ "modelVersionId": "modelUUID",
+ "modelInvariantId": "modelInvariantUUID",
+ "modelName": "modelName",
+ "modelVersion": "modelVersion",
+ "description": "description",
+ "isBase": false,
+ "modelCustomizationId": "modelCustomizationUUID",
+ "label": "label",
+ "minInstances": 1,
+ "maxInstances": 3,
+ "initialCount": "1",
+ "availabilityZoneCount": 10,
+ "isVolumeGroup": false
+ }
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/AllTestsTestSuite.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/AllTestsTestSuite.java
index a7bddd3ada..a9365a3946 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/AllTestsTestSuite.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/AllTestsTestSuite.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.adapters.vnf;
+package org.onap.so;
import org.junit.runner.RunWith;
import com.googlecode.junittoolbox.SuiteClasses;
diff --git a/adapters/mso-openstack-adapters/src/test/resources/schema.sql b/adapters/mso-openstack-adapters/src/test/resources/schema.sql
index c700e78868..83023e53db 100644
--- a/adapters/mso-openstack-adapters/src/test/resources/schema.sql
+++ b/adapters/mso-openstack-adapters/src/test/resources/schema.sql
@@ -717,7 +717,6 @@ CREATE TABLE `northbound_request_ref_lookup` (
`MAX_API_VERSION` double DEFAULT NULL,
`IS_TOPLEVELFLOW` tinyint(1) DEFAULT NULL,
`CLOUD_OWNER` varchar(200) NOT NULL,
- `service_type` varchar(50) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `UK_northbound_request_ref_lookup` (`MIN_API_VERSION`,`REQUEST_SCOPE`,`ACTION`,`IS_ALACARTE`,`MACRO_ACTION`,`CLOUD_OWNER`)
) ENGINE=InnoDB AUTO_INCREMENT=86 DEFAULT CHARSET=latin1;
@@ -804,6 +803,7 @@ CREATE TABLE `service` (
`WORKLOAD_CONTEXT` varchar(200) DEFAULT NULL,
`SERVICE_CATEGORY` varchar(200) DEFAULT NULL,
`RESOURCE_ORDER` varchar(200) default NULL,
+ OVERALL_DISTRIBUTION_STATUS varchar(45),
PRIMARY KEY (`MODEL_UUID`),
KEY `fk_service__tosca_csar1_idx` (`TOSCA_CSAR_ARTIFACT_UUID`),
CONSTRAINT `fk_service__tosca_csar1` FOREIGN KEY (`TOSCA_CSAR_ARTIFACT_UUID`) REFERENCES `tosca_csar` (`ARTIFACT_UUID`) ON DELETE CASCADE ON UPDATE CASCADE