aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceInfo.java7
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java8
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceProxyCustomization.java124
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java59
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java187
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java22
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/utils/ASDCLoggingVisitorImpl.java4
-rw-r--r--asdc-controller/src/test/resources/schema.sql28
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java14
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/rest/beans/ServiceMacroHolder.java49
10 files changed, 413 insertions, 89 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceInfo.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceInfo.java
index b1911654c4..6c1c81c6ef 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceInfo.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceInfo.java
@@ -65,6 +65,9 @@ public class QueryServiceInfo extends CatalogQuery {
@Override
public String JSON2(boolean isArray, boolean isEmbed) {
+ if (serviceInfo == null) {
+ return "\"serviceInfo\": null";
+ }
StringBuilder sb = new StringBuilder();
sb.append("\"serviceInfo\": ");
sb.append("\n");
@@ -73,8 +76,8 @@ public class QueryServiceInfo extends CatalogQuery {
put(valueMap, "ID", null == serviceInfo ? null : serviceInfo.getId());
put(valueMap, "SERVICE_INPUT", null == serviceInfo ? null : serviceInfo.getServiceInput());
put(valueMap, "SERVICE_PROPERTIES", null == serviceInfo ? null : serviceInfo.getServiceProperties());
- // String subitem = new QueryServiceArtifact(service.getServiceArtifactList()).JSON2(true, true);
- // valueMap.put("_SERVICEARTIFACT_", subitem.replaceAll("(?m)^", "\t\t"));m
+ String subitem = new QueryServiceArtifact(service.getServiceArtifactList()).JSON2(true, true);
+ valueMap.put("_SERVICEARTIFACT_", subitem.replaceAll("(?m)^", "\t\t"));
sb.append(this.setTemplate(TEMPLATE, valueMap));
sb.append("}");
return sb.toString();
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java
index 0eb7d0418e..d5aa472c8d 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java
@@ -40,7 +40,7 @@ public class QueryServiceMacroHolder extends CatalogQuery {
+ "\t\"serviceType\" : <SERVICE_TYPE>,\n" + "\t\"serviceRole\" : <SERVICE_ROLE>,\n"
+ "\t\"environmentContext\" : <ENVIRONMENT_CONTEXT>,\n" + "\t\"resourceOrder\" : <RESOURCE_ORDER>,\n"
+ "\t\"workloadContext\" : <WORKLOAD_CONTEXT>,\n" + "<_SERVICEVNFS_>,\n" + "<_SERVICENETWORKS_>,\n"
- + "<_SERVICEALLOTTEDRESOURCES_>\n" + "\t}}";
+ + "<_SERVICEINFO_>,\n" + "<_SERVICEPROXY_>,\n" + "<_SERVICEALLOTTEDRESOURCES_>\n" + "\t}}";
public QueryServiceMacroHolder() {
super();
@@ -94,6 +94,12 @@ public class QueryServiceMacroHolder extends CatalogQuery {
subitem = new QueryAllottedResourceCustomization(service.getAllottedCustomizations()).JSON2(true, true);
valueMap.put("_SERVICEALLOTTEDRESOURCES_", subitem.replaceAll(LINE_BEGINNING, "\t"));
+ subitem = new QueryServiceInfo(serviceMacroHolder.getServiceInfo()).JSON2(true, true);
+ valueMap.put("_SERVICEINFO_", subitem.replaceAll(LINE_BEGINNING, "\t"));
+
+ subitem = new QueryServiceProxyCustomization(service.getServiceProxyCustomizations()).JSON2(true, true);
+ valueMap.put("_SERVICEPROXY_", subitem.replaceAll(LINE_BEGINNING, "\t"));
+
buf.append(this.setTemplate(TEMPLATE, valueMap));
return buf.toString();
}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceProxyCustomization.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceProxyCustomization.java
new file mode 100644
index 0000000000..94cf304120
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceProxyCustomization.java
@@ -0,0 +1,124 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (c) 2019, CMCC Technologies Co., Ltd.
+ * ================================================================================
+ * 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.catalogrest;
+
+import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@XmlRootElement(name = "serviceProxyCustomizations")
+public class QueryServiceProxyCustomization extends CatalogQuery {
+
+ protected static Logger logger = LoggerFactory.getLogger(QueryServiceProxyCustomization.class);
+
+ private List<ServiceProxyResourceCustomization> serviceProxyResourceCustomizationList;
+
+ private static final String TEMPLATE =
+ "\t{\n" + "\t\t\"modelInfo\" : {\n" + "\t\t\t\"modelName\" : <MODEL_NAME>,\n"
+ + "\t\t\t\"modelUuid\" : <MODEL_UUID>,\n"
+ + "\t\t\t\"modelInvariantUuid\" : <MODEL_INVARIANT_UUID>,\n"
+ + "\t\t\t\"modelVersion\" : <MODEL_VERSION>,\n"
+ + "\t\t\t\"modelCustomizationUuid\" : <MODEL_CUSTOMIZATION_UUID>,\n"
+ + "\t\t\t\"modelInstanceName\" : <MODEL_INSTANCE_NAME>\n" + "\t},\n"
+ + "\t\t\"toscaNodeType\" : <TOSCA_NODE_TYPE>,\n"
+ + "\t\t\"description\" : <DESCRIPTION>,\n"
+ + "\t\t\"sourceModelUuid\" : <SOURCE_SERVICE_MODEL_UUID>\n" + "\t}";
+
+ public QueryServiceProxyCustomization() {
+ super();
+ this.serviceProxyResourceCustomizationList = new ArrayList<>();
+ }
+
+ public QueryServiceProxyCustomization(
+ List<ServiceProxyResourceCustomization> serviceProxyResourceCustomizationList) {
+ this.serviceProxyResourceCustomizationList = serviceProxyResourceCustomizationList;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+
+ boolean first = true;
+ int i = 1;
+ for (ServiceProxyResourceCustomization o : serviceProxyResourceCustomizationList) {
+ sb.append(i).append("\t");
+ if (!first)
+ sb.append("\n");
+
+ first = false;
+ sb.append(o);
+ }
+ return sb.toString();
+ }
+
+ @Override
+ public String JSON2(boolean isArray, boolean isEmbed) {
+ StringBuilder sb = new StringBuilder();
+ if (!isEmbed && isArray)
+ sb.append("{ ");
+ if (isArray)
+ sb.append("\"serviceProxy\": [");
+ Map<String, String> valueMap = new HashMap<>();
+ String sep = "";
+ boolean first = true;
+
+ if (this.serviceProxyResourceCustomizationList != null) {
+ for (ServiceProxyResourceCustomization o : serviceProxyResourceCustomizationList) {
+ if (first)
+ sb.append("\n");
+
+ first = false;
+
+ boolean arNull = o == null;
+
+ put(valueMap, "MODEL_CUSTOMIZATION_UUID", arNull ? null : o.getModelCustomizationUUID());
+ put(valueMap, "MODEL_INSTANCE_NAME", arNull ? null : o.getModelInstanceName());
+ put(valueMap, "MODEL_UUID", arNull ? null : o.getModelUUID());
+ put(valueMap, "MODEL_INVARIANT_UUID", arNull ? null : o.getModelInvariantUUID());
+ put(valueMap, "MODEL_VERSION", arNull ? null : o.getModelVersion());
+ put(valueMap, "MODEL_NAME", arNull ? null : o.getModelName());
+ put(valueMap, "TOSCA_NODE_TYPE", arNull ? null : o.getToscaNodeType());
+ put(valueMap, "DESCRIPTION", arNull ? null : o.getDescription());
+ put(valueMap, "SOURCE_SERVICE_MODEL_UUID", (String) (arNull ? null
+ : o.getSourceService() == null ? null : o.getSourceService().getModelUUID()));
+
+ sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap));
+ sep = ",\n";
+ }
+ }
+ if (!first)
+ sb.append("\n");
+
+ if (isArray)
+ sb.append("]");
+
+ if (!isEmbed && isArray)
+ sb.append("}");
+
+ return sb.toString();
+ }
+
+}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
index c9d4f4d92f..e084cfec18 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
@@ -39,6 +39,9 @@ import java.nio.charset.StandardCharsets;
import java.nio.file.Paths;
import java.util.List;
import java.util.Optional;
+import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
+import org.onap.so.asdc.util.ZipParser;
import org.onap.so.logger.LoggingAnchor;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.sdc.api.IDistributionClient;
@@ -737,6 +740,7 @@ public class ASDCController {
protected void processResourceNotification(INotificationData iNotif) {
// For each artifact, create a structure describing the VFModule in a ordered flat level
+ ResourceStructure resourceStructure = null;
String msoConfigPath = getMsoConfigPath();
ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure(msoConfigPath);
DistributionStatusEnum deployStatus = DistributionStatusEnum.DEPLOY_OK;
@@ -748,8 +752,8 @@ public class ASDCController {
if (isCsarAlreadyDeployed(iNotif, toscaResourceStructure)) {
return;
}
-
- ResourceStructure resourceStructure = null;
+ // process NsstResource
+ this.processNsstNotification(iNotif, toscaResourceStructure);
for (IResourceInstance resource : iNotif.getResources()) {
String resourceType = resource.getResourceType();
@@ -914,6 +918,23 @@ public class ASDCController {
"processCsarServiceArtifacts", ErrorCode.BusinessProcessError.getValue(),
"Exception in processCsarServiceArtifacts", e);
}
+ } else if (artifact.getArtifactType().equals(ASDCConfiguration.OTHER)) {
+ try {
+ IDistributionClientDownloadResult resultArtifact =
+ this.downloadTheArtifact(artifact, iNotif.getDistributionID());
+
+ writeArtifactToFile(artifact, resultArtifact);
+
+ toscaResourceStructure.setToscaArtifact(artifact);
+
+ toscaResourceStructure.setServiceVersion(iNotif.getServiceVersion());
+
+ } catch (ASDCDownloadException e) {
+ logger.error(LoggingAnchor.SIX, MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception caught during processCsarServiceArtifacts", "ASDC",
+ "processCsarServiceArtifacts", ErrorCode.BusinessProcessError.getValue(),
+ "Exception in processCsarServiceArtifacts", e);
+ }
}
@@ -940,4 +961,38 @@ public class ASDCController {
}
return UNKNOWN;
}
+
+ private void processNsstNotification(INotificationData iNotif, ToscaResourceStructure toscaResourceStructure) {
+ Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
+ try {
+ if (serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY).equalsIgnoreCase("NSST")) {
+
+ String artifactContent = null;
+ List<IArtifactInfo> serviceArtifacts = iNotif.getServiceArtifacts();
+ Optional<IArtifactInfo> artifactOpt = serviceArtifacts.stream()
+ .filter(e -> e.getArtifactType().equalsIgnoreCase("OTHER")).findFirst();
+ if (artifactOpt.isPresent()) {
+ IArtifactInfo artifactInfo = artifactOpt.get();
+ logger.debug("Ready to parse this serviceArtifactUUID: " + artifactInfo.getArtifactUUID());
+ String filePath = Paths.get(getMsoConfigPath(), "ASDC", artifactInfo.getArtifactVersion(),
+ artifactInfo.getArtifactName()).normalize().toString();
+ ZipParser zipParserInstance = ZipParser.getInstance();
+ artifactContent = zipParserInstance.parseJsonForZip(filePath);
+ logger.debug(
+ "serviceArtifact parsing success! serviceArtifactUUID: " + artifactInfo.getArtifactUUID());
+ } else {
+ logger.debug("serviceArtifact is null");
+ }
+ ResourceStructure resourceStructure = new VfResourceStructure(iNotif, new ResourceInstance());
+ resourceStructure.setResourceType(ResourceType.OTHER);
+ toscaInstaller.installTheNsstService(toscaResourceStructure, (VfResourceStructure) resourceStructure,
+ artifactContent);
+ }
+ } catch (IOException e) {
+ logger.error("serviceArtifact parse failure for service uuid: "
+ + serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
+ } catch (Exception e) {
+ logger.error("error NSST process resource failure ", e);
+ }
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
index 263118d1b3..3175839725 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
@@ -54,6 +54,7 @@ import org.onap.sdc.tosca.parser.enums.EntityTemplateType;
import org.onap.sdc.tosca.parser.enums.SdcTypes;
import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
import org.onap.sdc.toscaparser.api.CapabilityAssignment;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
import org.onap.sdc.toscaparser.api.Property;
import org.onap.sdc.toscaparser.api.RequirementAssignment;
import org.onap.sdc.toscaparser.api.elements.Metadata;
@@ -74,64 +75,8 @@ import org.onap.so.asdc.installer.VfModuleStructure;
import org.onap.so.asdc.installer.VfResourceStructure;
import org.onap.so.asdc.installer.bpmn.WorkflowResource;
import org.onap.so.asdc.util.YamlEditor;
-import org.onap.so.db.catalog.beans.AllottedResource;
-import org.onap.so.db.catalog.beans.AllottedResourceCustomization;
-import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
-import org.onap.so.db.catalog.beans.CollectionResource;
-import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
-import org.onap.so.db.catalog.beans.ConfigurationResource;
-import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization;
-import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
-import org.onap.so.db.catalog.beans.CvnfcCustomization;
-import org.onap.so.db.catalog.beans.HeatEnvironment;
-import org.onap.so.db.catalog.beans.HeatFiles;
-import org.onap.so.db.catalog.beans.HeatTemplate;
-import org.onap.so.db.catalog.beans.HeatTemplateParam;
-import org.onap.so.db.catalog.beans.InstanceGroup;
-import org.onap.so.db.catalog.beans.InstanceGroupType;
-import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
-import org.onap.so.db.catalog.beans.NetworkInstanceGroup;
-import org.onap.so.db.catalog.beans.NetworkResource;
-import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
-import org.onap.so.db.catalog.beans.PnfResource;
-import org.onap.so.db.catalog.beans.PnfResourceCustomization;
-import org.onap.so.db.catalog.beans.Service;
-import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization;
-import org.onap.so.db.catalog.beans.SubType;
-import org.onap.so.db.catalog.beans.TempNetworkHeatTemplateLookup;
-import org.onap.so.db.catalog.beans.ToscaCsar;
-import org.onap.so.db.catalog.beans.VFCInstanceGroup;
-import org.onap.so.db.catalog.beans.VfModule;
-import org.onap.so.db.catalog.beans.VfModuleCustomization;
-import org.onap.so.db.catalog.beans.VnfResource;
-import org.onap.so.db.catalog.beans.VnfResourceCustomization;
-import org.onap.so.db.catalog.beans.VnfcCustomization;
-import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
-import org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository;
-import org.onap.so.db.catalog.data.repository.AllottedResourceRepository;
-import org.onap.so.db.catalog.data.repository.CollectionResourceCustomizationRepository;
-import org.onap.so.db.catalog.data.repository.CollectionResourceRepository;
-import org.onap.so.db.catalog.data.repository.ConfigurationResourceCustomizationRepository;
-import org.onap.so.db.catalog.data.repository.ConfigurationResourceRepository;
-import org.onap.so.db.catalog.data.repository.CvnfcCustomizationRepository;
-import org.onap.so.db.catalog.data.repository.ExternalServiceToInternalServiceRepository;
-import org.onap.so.db.catalog.data.repository.HeatEnvironmentRepository;
-import org.onap.so.db.catalog.data.repository.HeatFilesRepository;
-import org.onap.so.db.catalog.data.repository.HeatTemplateRepository;
-import org.onap.so.db.catalog.data.repository.InstanceGroupRepository;
-import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository;
-import org.onap.so.db.catalog.data.repository.NetworkResourceRepository;
-import org.onap.so.db.catalog.data.repository.PnfCustomizationRepository;
-import org.onap.so.db.catalog.data.repository.PnfResourceRepository;
-import org.onap.so.db.catalog.data.repository.ServiceProxyResourceCustomizationRepository;
-import org.onap.so.db.catalog.data.repository.ServiceRepository;
-import org.onap.so.db.catalog.data.repository.TempNetworkHeatTemplateRepository;
-import org.onap.so.db.catalog.data.repository.ToscaCsarRepository;
-import org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository;
-import org.onap.so.db.catalog.data.repository.VFModuleRepository;
-import org.onap.so.db.catalog.data.repository.VnfResourceRepository;
-import org.onap.so.db.catalog.data.repository.VnfcCustomizationRepository;
-import org.onap.so.db.catalog.data.repository.VnfcInstanceGroupCustomizationRepository;
+import org.onap.so.db.catalog.beans.*;
+import org.onap.so.db.catalog.data.repository.*;
import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus;
import org.onap.so.db.request.beans.WatchdogDistributionStatus;
import org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup;
@@ -271,6 +216,9 @@ public class ToscaResourceInstaller {
protected PnfCustomizationRepository pnfCustomizationRepository;
@Autowired
+ protected ServiceInfoRepository serviceInfoRepository;
+
+ @Autowired
protected WorkflowResource workflowResource;
@Autowired
@@ -445,6 +393,7 @@ public class ToscaResourceInstaller {
createToscaCsar(toscaResourceStruct);
createService(toscaResourceStruct, vfResourceStruct);
Service service = toscaResourceStruct.getCatalogService();
+ ServiceInfo serviceInfo = createServiceInfo(toscaResourceStruct, service);
List<IEntityDetails> vfEntityList = getEntityDetails(toscaResourceStruct,
EntityQuery.newBuilder(SdcTypes.VF), TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE), false);
@@ -474,8 +423,9 @@ public class ToscaResourceInstaller {
processServiceProxyAndConfiguration(toscaResourceStruct, service);
logger.info("Saving Service: {} ", service.getModelName());
- service = serviceRepo.save(service);
- correlateConfigCustomResources(service);
+ ServiceInfo serviceResult = serviceInfoRepository.save(serviceInfo);
+ Service resultService = serviceResult.getService();
+ correlateConfigCustomResources(resultService);
workflowResource.processWorkflows(vfResourceStructure);
@@ -2912,5 +2862,122 @@ public class ToscaResourceInstaller {
return new Timestamp(new Date().getTime());
}
+ private String getServiceInput(ToscaResourceStructure toscaResourceStructure) {
+ String serviceInput = null;
+
+ List<Object> serviceInputList;
+ ISdcCsarHelper sdcCsarHelper = toscaResourceStructure.getSdcCsarHelper();
+ List<Input> serviceInputs = sdcCsarHelper.getServiceInputs();
+ if (!serviceInputs.isEmpty()) {
+ serviceInputList = new ArrayList<>();
+ serviceInputs.forEach(input -> {
+ Map<String, Object> serviceInputMap = new HashMap<>();
+ serviceInputMap.put("name", input.getName());
+ serviceInputMap.put("type", input.getType());
+ serviceInputMap.put("default", input.getDefault() == null ? "" : input.getDefault());
+ serviceInputMap.put("required", input.isRequired());
+ serviceInputList.add(serviceInputMap);
+
+ });
+ ObjectMapper objectMapper = new ObjectMapper();
+ try {
+ serviceInput = objectMapper.writeValueAsString(serviceInputList);
+ serviceInput = serviceInput.replace("\"", "\\\"");
+ } catch (JsonProcessingException e) {
+ logger.error("service input could not be deserialized for service uuid: "
+ + sdcCsarHelper.getServiceMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ }
+ } else {
+ logger.debug("serviceInput is null");
+ }
+ return serviceInput;
+ }
+
+ @Transactional(rollbackFor = {ArtifactInstallerException.class})
+ public void installTheNsstService(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct,
+ String artifactContent) {
+ createToscaCsar(toscaResourceStruct);
+ createService(toscaResourceStruct, vfResourceStruct);
+ Service service = toscaResourceStruct.getCatalogService();
+ ServiceInfo serviceInfo = createServiceInfo(toscaResourceStruct, service);
+ createServiceArtifact(service, vfResourceStruct, artifactContent);
+ serviceInfoRepository.save(serviceInfo);
+ }
+
+ private void createServiceArtifact(Service service, VfResourceStructure vfResourceStruct, String artifactContent) {
+ List<ServiceArtifact> serviceArtifactList = new ArrayList<>();
+ ServiceArtifact serviceArtifact;
+ List<IArtifactInfo> artifactInfoList = vfResourceStruct.getNotification().getServiceArtifacts().stream()
+ .filter(artifact -> artifact.getArtifactType().equalsIgnoreCase("OTHER")).collect(Collectors.toList());
+ for (IArtifactInfo artifactInfo : artifactInfoList) {
+ serviceArtifact = new ServiceArtifact();
+ serviceArtifact.setArtifactUUID(artifactInfo.getArtifactUUID());
+ serviceArtifact.setName(artifactInfo.getArtifactName());
+ serviceArtifact.setType(artifactInfo.getArtifactType());
+ serviceArtifact.setVersion(artifactInfo.getArtifactVersion());
+ serviceArtifact.setDescription(artifactInfo.getArtifactDescription());
+ serviceArtifact.setChecksum(artifactInfo.getArtifactChecksum());
+ serviceArtifact.setContent(artifactContent);
+ serviceArtifact.setService(service);
+ serviceArtifactList.add(serviceArtifact);
+ }
+ service.setServiceArtifactList(serviceArtifactList);
+ }
+
+ private ServiceInfo createServiceInfo(ToscaResourceStructure toscaResourceStruct, Service service) {
+ ServiceInfo serviceInfo = new ServiceInfo();
+ String serviceInput = getServiceInput(toscaResourceStruct);
+ serviceInfo.setServiceInput(serviceInput);
+
+ String serviceProperties = getServiceProperties(toscaResourceStruct);
+ serviceInfo.setServiceProperties(serviceProperties);
+
+ serviceInfo.setService(service);
+ return serviceInfo;
+ }
+
+ private String getServiceProperties(ToscaResourceStructure toscaResourceStruct) {
+ String propertiesJson = null;
+ ObjectMapper objectMapper = new ObjectMapper();
+ ISdcCsarHelper helper = toscaResourceStruct.getSdcCsarHelper();
+ String typeName = helper.getServiceSubstitutionMappingsTypeName();
+ Optional<NodeTemplate> nodeTemplate = helper.getServiceNodeTemplates().stream().findAny();
+ List<Object> serviceProperties = new ArrayList<>();
+ Map<String, Object> servicePropertiesMap;
+ if (nodeTemplate.isPresent()) {
+ LinkedHashMap<String, Object> customDef = nodeTemplate.get().getCustomDef();
+ Optional<String> machKey =
+ customDef.keySet().stream().filter(key -> key.equalsIgnoreCase(typeName)).findFirst();
+ if (machKey.isPresent()) {
+ Object obj = customDef.get(machKey.get());
+ try {
+ if (obj instanceof Map) {
+ Object properties = ((HashMap) obj).get("properties");
+ if (null != properties) {
+ for (Object propertyName : ((Map) properties).keySet()) {
+ servicePropertiesMap = new HashMap<>();
+ servicePropertiesMap.put("name", propertyName);
+ Object object = ((Map) properties).get(propertyName);
+ for (Object entry : ((Map) object).entrySet()) {
+ servicePropertiesMap.put((String) ((Map.Entry) entry).getKey(),
+ ((Map.Entry) entry).getValue());
+ }
+ servicePropertiesMap.remove("description");
+ serviceProperties.add(servicePropertiesMap);
+ }
+ propertiesJson = objectMapper.writeValueAsString(serviceProperties);
+ propertiesJson = propertiesJson.replace("\"", "\\\"");
+ }
+ }
+ } catch (JsonProcessingException e) {
+ logger.error("serviceProperties could not be deserialized for service uuid: "
+ + nodeTemplate.get().getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ }
+ }
+ } else {
+ logger.debug("ServiceNodeTemplates is null");
+ }
+ return propertiesJson;
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
index c25c4c2828..b8a2d01b49 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
@@ -75,19 +75,8 @@ import org.onap.so.asdc.installer.ToscaResourceStructure;
import org.onap.so.asdc.installer.VfModuleStructure;
import org.onap.so.asdc.installer.VfResourceStructure;
import org.onap.so.asdc.installer.bpmn.WorkflowResource;
-import org.onap.so.db.catalog.beans.ConfigurationResource;
-import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization;
-import org.onap.so.db.catalog.beans.Service;
-import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization;
-import org.onap.so.db.catalog.beans.ToscaCsar;
-import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
-import org.onap.so.db.catalog.data.repository.ConfigurationResourceCustomizationRepository;
-import org.onap.so.db.catalog.data.repository.InstanceGroupRepository;
-import org.onap.so.db.catalog.data.repository.ServiceRepository;
-import org.onap.so.db.catalog.data.repository.ToscaCsarRepository;
-import org.onap.so.db.catalog.data.repository.VFModuleRepository;
-import org.onap.so.db.catalog.data.repository.VnfResourceRepository;
-import org.onap.so.db.catalog.data.repository.VnfcInstanceGroupCustomizationRepository;
+import org.onap.so.db.catalog.beans.*;
+import org.onap.so.db.catalog.data.repository.*;
import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus;
import org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatusRepository;
import org.springframework.beans.factory.annotation.Autowired;
@@ -325,8 +314,6 @@ public class ToscaResourceInstallerTest extends BaseTest {
notificationData.setServiceUUID("serviceUUID1");
notificationData.setWorkloadContext("workloadContext1");
-
-
String serviceType = "test-type1";
String serviceRole = "test-role1";
String category = "Network L3+";
@@ -356,6 +343,7 @@ public class ToscaResourceInstallerTest extends BaseTest {
doReturn(resourceCustomizationUUID).when(metadata).getValue("vfModuleModelCustomizationUUID");
ServiceRepository serviceRepo = spy(ServiceRepository.class);
+ ServiceInfoRepository serviceInfoRepo = spy(ServiceInfoRepository.class);
VnfResourceRepository vnfRepo = spy(VnfResourceRepository.class);
doReturn(null).when(vnfRepo).findResourceByModelUUID(uuid);
@@ -366,6 +354,7 @@ public class ToscaResourceInstallerTest extends BaseTest {
WorkflowResource workflowResource = spy(WorkflowResource.class);
ReflectionTestUtils.setField(toscaInstaller, "serviceRepo", serviceRepo);
+ ReflectionTestUtils.setField(toscaInstaller, "serviceInfoRepository", serviceInfoRepo);
ReflectionTestUtils.setField(toscaInstaller, "vnfRepo", vnfRepo);
ReflectionTestUtils.setField(toscaInstaller, "vfModuleRepo", vfModuleRepo);
ReflectionTestUtils.setField(toscaInstaller, "instanceGroupRepo", instanceGroupRepo);
@@ -436,7 +425,10 @@ public class ToscaResourceInstallerTest extends BaseTest {
assertNotNull(service);
service.setModelVersion("1.0");
+ ServiceInfo serviceInfo = new ServiceInfo();
+ serviceInfo.setService(service);
doReturn(service).when(serviceRepo).save(service);
+ doReturn(serviceInfo).when(serviceInfoRepo).save(any(ServiceInfo.class));
WatchdogComponentDistributionStatusRepository watchdogCDStatusRepository =
spy(WatchdogComponentDistributionStatusRepository.class);
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/utils/ASDCLoggingVisitorImpl.java b/asdc-controller/src/test/java/org/onap/so/asdc/utils/ASDCLoggingVisitorImpl.java
index 53d163a5bc..02c0f2dbf7 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/utils/ASDCLoggingVisitorImpl.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/utils/ASDCLoggingVisitorImpl.java
@@ -7,9 +7,9 @@
* 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.
diff --git a/asdc-controller/src/test/resources/schema.sql b/asdc-controller/src/test/resources/schema.sql
index 0821ebc97c..d051d1a56c 100644
--- a/asdc-controller/src/test/resources/schema.sql
+++ b/asdc-controller/src/test/resources/schema.sql
@@ -1378,6 +1378,34 @@ CREATE TABLE IF NOT EXISTS `activity_spec_to_user_parameters` (
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;
+CREATE TABLE IF NOT EXISTS `service_info` (
+ `ID` int (11) AUTO_INCREMENT,
+ `SERVICE_INPUT` varchar (5000),
+ `SERVICE_PROPERTIES` varchar (5000),
+ PRIMARY KEY (`ID`)
+)ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+CREATE TABLE IF NOT EXISTS `service_artifact`(
+ `ARTIFACT_UUID` varchar (200) NOT NULL,
+ `TYPE` varchar (200) NOT NULL,
+ `NAME` varchar (200) NOT NULL,
+ `VERSION` varchar (200) NOT NULL,
+ `DESCRIPTION` varchar (200) DEFAULT NULL,
+ `CONTENT` LONGTEXT DEFAULT NULL,
+ `CHECKSUM` varchar (200) DEFAULT NULL,
+ `CREATION_TIMESTAMP` DATETIME DEFAULT CURRENT_TIMESTAMP,
+ `SERVICE_MODEL_UUID` varchar (200) NOT NULL,
+ PRIMARY KEY (`ARTIFACT_UUID`),
+ CONSTRAINT `fk_service_artifact_service_info1` FOREIGN KEY (`SERVICE_MODEL_UUID`) REFERENCES `service` (`MODEL_UUID`) ON DELETE CASCADE ON UPDATE CASCADE
+)ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+CREATE TABLE IF NOT EXISTS `service_to_service_info` (
+ `SERVICE_MODEL_UUID` varchar (200) NOT NULL,
+ `SERVICE_INFO_ID` INT (11) NOT NULL,
+ PRIMARY KEY (`SERVICE_MODEL_UUID`,`SERVICE_INFO_ID`),
+ CONSTRAINT `fk_service_to_service_info__service1` FOREIGN KEY (`SERVICE_MODEL_UUID`) REFERENCES `service` (`MODEL_UUID`) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT `fk_service_to_service_info__service_info1` FOREIGN KEY (`SERVICE_INFO_ID`) REFERENCES `service_info` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE
+)ENGINE=InnoDB DEFAULT CHARSET=latin1;
--------START Request DB SCHEMA --------
CREATE DATABASE requestdb;
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java
index ab40cefb4e..0d7a6dbd1f 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java
@@ -136,6 +136,9 @@ public class Service implements Serializable {
@JoinColumn(name = "TOSCA_CSAR_ARTIFACT_UUID")
private ToscaCsar csar;
+ @OneToMany(cascade = CascadeType.ALL, mappedBy = "service")
+ private List<ServiceArtifact> serviceArtifactList;
+
@Column(name = "NAMING_POLICY")
private String namingPolicy;
@@ -371,6 +374,17 @@ public class Service implements Serializable {
this.csar = csar;
}
+ public List<ServiceArtifact> getServiceArtifactList() {
+ if (serviceArtifactList == null) {
+ serviceArtifactList = new ArrayList<>();
+ }
+ return serviceArtifactList;
+ }
+
+ public void setServiceArtifactList(List<ServiceArtifact> serviceArtifactList) {
+ this.serviceArtifactList = serviceArtifactList;
+ }
+
public String getWorkloadContext() {
return this.workloadContext;
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/rest/beans/ServiceMacroHolder.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/rest/beans/ServiceMacroHolder.java
index f9cbb0d462..ec4e922c8f 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/rest/beans/ServiceMacroHolder.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/rest/beans/ServiceMacroHolder.java
@@ -20,14 +20,10 @@
package org.onap.so.db.catalog.rest.beans;
+import com.openpojo.business.annotation.BusinessKey;
+import org.onap.so.db.catalog.beans.*;
import java.io.Serializable;
import java.util.ArrayList;
-import org.onap.so.db.catalog.beans.AllottedResourceCustomization;
-import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
-import org.onap.so.db.catalog.beans.Service;
-import org.onap.so.db.catalog.beans.VnfResource;
-import org.onap.so.db.catalog.beans.VnfResourceCustomization;
-import com.openpojo.business.annotation.BusinessKey;
/*
* A simple holder for Service and its associated elements: VnfResource, 1-n VfModule, Network TBD
@@ -42,6 +38,8 @@ public class ServiceMacroHolder implements Serializable {
private ArrayList<NetworkResourceCustomization> networkResourceCustomizations;
private ArrayList<AllottedResourceCustomization> allottedResourceCustomizations;
private ArrayList<VnfResourceCustomization> vnfResourceCustomizations;
+ private ArrayList<ServiceProxyResourceCustomization> serviceProxyResourceCustomizations;
+ private ServiceInfo serviceInfo;
public ServiceMacroHolder() {
@@ -51,6 +49,8 @@ public class ServiceMacroHolder implements Serializable {
this.networkResourceCustomizations = new ArrayList<>();
this.allottedResourceCustomizations = new ArrayList<>();
this.vnfResourceCustomizations = new ArrayList<>();
+ this.serviceProxyResourceCustomizations = new ArrayList<>();
+ this.serviceInfo = null;
}
public ServiceMacroHolder(Service service) {
@@ -66,6 +66,14 @@ public class ServiceMacroHolder implements Serializable {
this.service = service;
}
+ public ServiceInfo getServiceInfo() {
+ return serviceInfo;
+ }
+
+ public void setServiceInfo(ServiceInfo serviceInfo) {
+ this.serviceInfo = serviceInfo;
+ }
+
public void setVnfResources(ArrayList<VnfResource> vnfResources) {
this.vnfResources = vnfResources;
}
@@ -139,6 +147,15 @@ public class ServiceMacroHolder implements Serializable {
}
}
+ public void addServiceProxyResourceCustomization(ServiceProxyResourceCustomization sprc) {
+ if (this.serviceProxyResourceCustomizations != null) {
+ this.serviceProxyResourceCustomizations.add(sprc);
+ } else {
+ this.serviceProxyResourceCustomizations = new ArrayList<>();
+ this.serviceProxyResourceCustomizations.add(sprc);
+ }
+ }
+
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
@@ -148,6 +165,11 @@ public class ServiceMacroHolder implements Serializable {
} else {
sb.append("service: null");
}
+ if (this.serviceInfo != null) {
+ sb.append("serviceInfo: " + this.serviceInfo.toString());
+ } else {
+ sb.append("serviceInfo: null");
+ }
if (this.vnfResourceCustomizations != null && this.vnfResourceCustomizations.size() > 0) {
int i = 0;
sb.append("VnfResources: ");
@@ -180,6 +202,13 @@ public class ServiceMacroHolder implements Serializable {
sb.append("ARC[" + i++ + "]: " + arc.toString());
}
}
+ if (this.serviceProxyResourceCustomizations != null && this.serviceProxyResourceCustomizations.size() > 0) {
+ int i = 0;
+ sb.append("ServiceProxyResourceCustomizations:");
+ for (ServiceProxyResourceCustomization sprc : this.serviceProxyResourceCustomizations) {
+ sb.append("SPRC[" + i++ + "]: " + sprc.toString());
+ }
+ }
return sb.toString();
}
@@ -202,6 +231,12 @@ public class ServiceMacroHolder implements Serializable {
this.allottedResourceCustomizations = allottedResourceCustomizations;
}
+ public ArrayList<ServiceProxyResourceCustomization> getServiceProxyResourceCustomizations() {
+ return serviceProxyResourceCustomizations;
+ }
-
+ public void setServiceProxyResourceCustomizations(
+ ArrayList<ServiceProxyResourceCustomization> serviceProxyResourceCustomizations) {
+ this.serviceProxyResourceCustomizations = serviceProxyResourceCustomizations;
+ }
}