summaryrefslogtreecommitdiffstats
path: root/asdc-controller/src
diff options
context:
space:
mode:
authorMarcus Williams <marcus.williams@intel.com>2019-01-28 20:43:35 +0000
committerGerrit Code Review <gerrit@onap.org>2019-01-28 20:43:35 +0000
commit902b6a93925067f0bb8c7a1639b62cbd64604465 (patch)
tree1869cb1b23e0fc0f7113ca812e9d26fc8fa2a403 /asdc-controller/src
parent1f57cd06a3bf1deeb277430dba310088368c82fa (diff)
parentfe91155454a27401e8c23780fa247c0ede196747 (diff)
Merge "Merge 'origin/casablanca' into master"
Diffstat (limited to 'asdc-controller/src')
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java7
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java2
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java26
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java266
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java185
-rw-r--r--asdc-controller/src/test/resources/schema.sql11
6 files changed, 444 insertions, 53 deletions
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 9a1392bdca..ca1d0331fd 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
@@ -687,6 +687,13 @@ public class ASDCController {
try {
this.processCsarServiceArtifacts(iNotif, toscaResourceStructure);
+ IArtifactInfo iArtifact = toscaResourceStructure.getToscaArtifact();
+ String filePath = System.getProperty("mso.config.path") + "/ASDC/" + iArtifact.getArtifactVersion() + "/" + iArtifact.getArtifactName();
+ File csarFile = new File(filePath);
+ String csarFilePath = csarFile.getAbsolutePath();
+ if (bpmnInstaller.containsWorkflows(csarFilePath)) {
+ bpmnInstaller.installBpmn(csarFilePath);
+ }
for (IResourceInstance resource : iNotif.getResources()){
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java
index 179dac3c35..6ddc2a8bdd 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java
@@ -132,7 +132,7 @@ public class ToscaResourceStructure {
LOGGER.info(MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF, "***PATH", "ASDC", spoolFile.getAbsolutePath());
- sdcCsarHelper = factory.getSdcCsarHelper(spoolFile.getAbsolutePath());
+ sdcCsarHelper = factory.getSdcCsarHelper(spoolFile.getAbsolutePath(),false);
}catch(Exception e){
System.out.println("System out " + e.getMessage());
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java
index 486844ae02..cd9a121ddb 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java
@@ -27,7 +27,9 @@ import java.io.IOException;
import java.net.URI;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.Enumeration;
import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
import org.apache.commons.io.IOUtils;
@@ -109,6 +111,30 @@ public class BpmnInstaller {
}
return;
}
+
+ public boolean containsWorkflows(String csarFilePath) {
+ boolean workflowsInCsar = false;
+ try {
+ ZipFile zipFile = new ZipFile(csarFilePath);
+ Enumeration<? extends ZipEntry> zipEntries = zipFile.entries();
+ while (zipEntries.hasMoreElements()) {
+ String fileName = ((ZipEntry) zipEntries.nextElement()).getName();
+ if (fileName.endsWith(BPMN_SUFFIX)) {
+ workflowsInCsar = true;
+ break;
+ }
+ }
+ }
+ catch (Exception e) {
+ LOGGER.debug("Exception :",e);
+ LOGGER.error(MessageEnum.ASDC_ARTIFACT_CHECK_EXC,
+ csarFilePath,
+ "",
+ "",
+ e.getMessage(), "", "", MsoLogger.ErrorCode.DataError, "ASDC Unable to check CSAR entries");
+ }
+ return workflowsInCsar;
+ }
protected HttpResponse sendDeploymentRequest(String bpmnFileName) throws Exception {
HttpClient client = HttpClientBuilder.create().build();
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 e455d2da93..7951e9be76 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
@@ -25,16 +25,21 @@ package org.onap.so.asdc.installer.heat;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import java.util.Set;
+import java.util.stream.Collectors;
import org.hibernate.exception.ConstraintViolationException;
import org.hibernate.exception.LockAcquisitionException;
import org.onap.sdc.api.notification.IArtifactInfo;
import org.onap.sdc.api.notification.IResourceInstance;
import org.onap.sdc.api.notification.IStatusData;
+import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.enums.SdcTypes;
import org.onap.sdc.tosca.parser.impl.SdcPropertyNames;
import org.onap.sdc.toscaparser.api.CapabilityAssignment;
@@ -42,8 +47,12 @@ import org.onap.sdc.toscaparser.api.CapabilityAssignments;
import org.onap.sdc.toscaparser.api.Group;
import org.onap.sdc.toscaparser.api.NodeTemplate;
import org.onap.sdc.toscaparser.api.Policy;
+import org.onap.sdc.toscaparser.api.Property;
import org.onap.sdc.toscaparser.api.RequirementAssignment;
+import org.onap.sdc.toscaparser.api.RequirementAssignments;
import org.onap.sdc.toscaparser.api.elements.Metadata;
+import org.onap.sdc.toscaparser.api.functions.GetInput;
+import org.onap.sdc.toscaparser.api.parameters.Input;
import org.onap.sdc.utils.DistributionStatusEnum;
import org.onap.so.asdc.client.ASDCConfiguration;
import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
@@ -118,6 +127,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
@Component
public class ToscaResourceInstaller {
@@ -137,6 +149,7 @@ public class ToscaResourceInstaller {
protected static final String MSO = "SO";
+
@Autowired
protected ServiceRepository serviceRepo;
@@ -145,7 +158,7 @@ public class ToscaResourceInstaller {
@Autowired
protected ServiceProxyResourceCustomizationRepository serviceProxyCustomizationRepo;
-
+
@Autowired
protected CollectionResourceRepository collectionRepo;
@@ -267,9 +280,9 @@ public class ToscaResourceInstaller {
@Transactional(rollbackFor = { ArtifactInstallerException.class })
public void installTheResource(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct)
- throws ArtifactInstallerException {
+ throws ArtifactInstallerException {
VfResourceStructure vfResourceStructure = vfResourceStruct;
- extractHeatInformation(toscaResourceStruct, vfResourceStructure);
+ extractHeatInformation(toscaResourceStruct, vfResourceStructure);
// PCLO: in case of deployment failure, use a string that will represent
// the type of artifact that failed...
@@ -278,9 +291,23 @@ public class ToscaResourceInstaller {
createToscaCsar(toscaResourceStruct);
createService(toscaResourceStruct, vfResourceStruct);
Service service = toscaResourceStruct.getCatalogService();
-
+ List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
+
+
+ for (NodeTemplate nodeTemplate : vfNodeTemplatesList) {
+
+ Metadata metadata = nodeTemplate.getMetaData();
+ String serviceType = toscaResourceStruct.getCatalogService().getServiceType();
+ String vfCustomizationCategory = toscaResourceStruct.getSdcCsarHelper()
+ .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CATEGORY);
+ processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, metadata,
+ vfCustomizationCategory);
+ }
+
+ processResourceSequence(toscaResourceStruct, service);
processVFResources(toscaResourceStruct, service, vfResourceStructure);
- processAllottedResources(toscaResourceStruct, service);
+ List<NodeTemplate> allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources();
+ processAllottedResources(toscaResourceStruct, service, allottedResourceList);
processNetworks(toscaResourceStruct, service);
// process Network Collections
processNetworkCollections(toscaResourceStruct, service);
@@ -327,12 +354,136 @@ public class ToscaResourceInstaller {
}
}
+
+ List<NodeTemplate> getRequirementList(List<NodeTemplate> resultList, List<NodeTemplate> nodeTemplates,
+ ISdcCsarHelper iSdcCsarHelper) {
+
+ List<NodeTemplate> nodes = new ArrayList<NodeTemplate>();
+ nodes.addAll(nodeTemplates);
+
+ for (NodeTemplate nodeTemplate : nodeTemplates) {
+ RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate);
+ List<RequirementAssignment> reqAs = requirement.getAll();
+ for (RequirementAssignment ra : reqAs) {
+ String reqNode = ra.getNodeTemplateName();
+ for (NodeTemplate rNode : resultList) {
+ if (rNode.getName().equals(reqNode)) {
+ if(!resultList.contains(nodeTemplate)) {
+ resultList.add(nodeTemplate);
+ }
+ if(nodes.contains(nodeTemplate)) {
+ nodes.remove(nodeTemplate);
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ if (!nodes.isEmpty()) {
+ getRequirementList(resultList, nodes, iSdcCsarHelper);
+ }
+
+ return resultList;
+ }
+
+ // This method retrieve resource sequence from csar file
+ void processResourceSequence(ToscaResourceStructure toscaResourceStructure, Service service) {
+ List<String> resouceSequence = new ArrayList<String>();
+ List<NodeTemplate> resultList = new ArrayList<NodeTemplate>();
+
+ ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper();
+ List<NodeTemplate> nodeTemplates = iSdcCsarHelper.getServiceNodeTemplates();
+ List<NodeTemplate> nodes = new ArrayList<NodeTemplate>();
+ nodes.addAll(nodeTemplates);
+
+ for (NodeTemplate nodeTemplate : nodeTemplates) {
+ RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate);
+
+ if (requirement == null || requirement.getAll() == null || requirement.getAll().isEmpty()) {
+ resultList.add(nodeTemplate);
+ nodes.remove(nodeTemplate);
+ }
+ }
+
+ resultList = getRequirementList(resultList, nodes, iSdcCsarHelper);
+
+ for (NodeTemplate node : resultList) {
+ String templateName = node.getMetaData().getValue("name");
+ if (!resouceSequence.contains(templateName)) {
+ resouceSequence.add(templateName);
+ }
+ }
+
+ String resourceSeqStr = resouceSequence.stream().collect(Collectors.joining(","));
+ service.setResourceOrder(resourceSeqStr);
+ logger.debug(" resourceSeq for service uuid(" + service.getModelUUID() + ") : " + resourceSeqStr);
+ }
+
+ private static String CUSTOMIZATION_UUID = "customizationUUID";
+
+ private static String getValue(Object value, List<Input> servInputs) {
+ String output = null;
+ if(value instanceof Map) {
+ // currently this logic handles only one level of nesting.
+ return ((LinkedHashMap) value).values().toArray()[0].toString();
+ } else if(value instanceof GetInput) {
+ String inputName = ((GetInput)value).getInputName();
+
+ for(Input input : servInputs) {
+ if(input.getName().equals(inputName)) {
+ // keep both input name and default value
+ // if service input does not supplies value the use default value
+ String defaultValue = input.getDefault() != null ? (String) input.getDefault().toString() : "";
+ output = inputName + "|" + defaultValue;// return default value
+ }
+ }
+
+ } else {
+ output = value != null ? value.toString() : "";
+ }
+ return output; // return property value
+ }
+
+ String getResourceInput(ToscaResourceStructure toscaResourceStructure, String resourceCustomizationUuid) throws ArtifactInstallerException {
+ Map<String, String> resouceRequest = new HashMap<>();
+ ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper();
+
+ List<Input> serInput = iSdcCsarHelper.getServiceInputs();
+ Optional<NodeTemplate> nodeTemplateOpt = iSdcCsarHelper.getServiceNodeTemplates().stream()
+ .filter(e -> e.getMetaData().getValue(CUSTOMIZATION_UUID).equals(resourceCustomizationUuid)).findFirst();
+ if(nodeTemplateOpt.isPresent()) {
+ NodeTemplate nodeTemplate = nodeTemplateOpt.get();
+ LinkedHashMap<String, Property> resourceProperties = nodeTemplate.getProperties();
+
+ for(String key : resourceProperties.keySet()) {
+ Property property = resourceProperties.get(key);
+
+ String value = getValue(property.getValue(), serInput);
+ resouceRequest.put(key, value);
+ }
+ }
+
+ try {
+ ObjectMapper objectMapper = new ObjectMapper();
+ String jsonStr = objectMapper.writeValueAsString(resouceRequest);
+
+ jsonStr = jsonStr.replace("\"", "\\\"");
+ logger.debug("resource request for resource customization id (" + resourceCustomizationUuid + ") : " + jsonStr);
+ return jsonStr;
+ } catch (JsonProcessingException e) {
+ logger.error("resource input could not be deserialized for resource customization id ("
+ + resourceCustomizationUuid + ")");
+ throw new ArtifactInstallerException("resource input could not be parsed", e);
+ }
+ }
+
protected void processNetworks (ToscaResourceStructure toscaResourceStruct,
Service service) throws ArtifactInstallerException {
List <NodeTemplate> nodeTemplatesVLList = toscaResourceStruct.getSdcCsarHelper ().getServiceVlList ();
- if (nodeTemplatesVLList != null) {
- for (NodeTemplate vlNode : nodeTemplatesVLList) {
+ if (nodeTemplatesVLList != null) {
+ for (NodeTemplate vlNode : nodeTemplatesVLList) {
String networkResourceModelName = vlNode.getMetaData ().getValue (SdcPropertyNames.PROPERTY_NAME_NAME);
TempNetworkHeatTemplateLookup tempNetworkLookUp =
@@ -353,8 +504,8 @@ public class ToscaResourceInstaller {
} else {
throw new ArtifactInstallerException ("No HeatTemplate found for artifactUUID: "
+ tempNetworkLookUp.getHeatTemplateArtifactUuid ());
- }
- } else {
+ }
+ } else {
NetworkResourceCustomization networkCustomization = createNetwork (vlNode,
toscaResourceStruct,
null,
@@ -363,16 +514,15 @@ public class ToscaResourceInstaller {
service);
service.getNetworkCustomizations().add (networkCustomization);
logger.debug ("No NetworkResourceName found in TempNetworkHeatTemplateLookup for "
- + networkResourceModelName);
- }
-
- }
- }
+ + networkResourceModelName);
+ }
+
+ }
+ }
}
- protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service) {
- List<NodeTemplate> allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources();
-
+ protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service,
+ List<NodeTemplate> allottedResourceList) {
if (allottedResourceList != null) {
for (NodeTemplate allottedNode : allottedResourceList) {
service.getAllottedCustomizations()
@@ -478,9 +628,9 @@ public class ToscaResourceInstaller {
logger.debug("vfCustomizationUUID: " + vfCustomizationUUID
+ " matches vfNotificationResource CustomizationUUID");
- processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, vfCustomizationUUID);
- }
- else {
+ processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, metadata,
+ vfCustomizationCategory);
+ } else {
logger.debug("Notification VF ResourceCustomizationUUID: "
+ vfNotificationResource.getResourceCustomizationUUID() + " doesn't match "
+ "Tosca VF Customization UUID: " + vfCustomizationUUID);
@@ -490,40 +640,59 @@ public class ToscaResourceInstaller {
protected void processVfModules(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure,
- Service service, NodeTemplate nodeTemplate, String vfCustomizationUUID)
- throws Exception {
- logger.debug("processVfModules for vfCustomizationUUID: " + vfCustomizationUUID);
+ Service service, NodeTemplate nodeTemplate, Metadata metadata, String vfCustomizationCategory) throws Exception {
- VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service);
+ logger.debug("VF Category is : " + vfCustomizationCategory);
- if (vfResourceStructure.getVfModuleStructure() != null && !vfResourceStructure.getVfModuleStructure().isEmpty()) {
- Set<CvnfcCustomization> existingCvnfcSet = new HashSet<CvnfcCustomization>();
- Set<VnfcCustomization> existingVnfcSet = new HashSet<VnfcCustomization>();
-
- for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
-
- logger.debug("vfModuleStructure:" + vfModuleStructure.toString());
- List<org.onap.sdc.toscaparser.api.Group> vfGroups = toscaResourceStruct.getSdcCsarHelper()
- .getVfModulesByVf(vfCustomizationUUID);
- IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();
-
- logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID());
+ if(vfResourceStructure.getVfModuleStructure() != null && !vfResourceStructure.getVfModuleStructure().isEmpty())
+ {
- Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream()
- .peek(group -> logger.debug("To Csar Group VFModuleModelCustomizationUUID " + group.getMetadata().getValue("vfModuleModelCustomizationUUID")))
- .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID()))
- .findFirst();
- if (matchingObject.isPresent()) {
- VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), nodeTemplate, toscaResourceStruct,
- vfResourceStructure, vfMetadata, vnfResource,service, existingCvnfcSet, existingVnfcSet);
- vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources());
- } else {
- throw new Exception("Cannot find matching VFModule Customization in Csar for Vf_Modules_Metadata: " + vfMetadata.getVfModuleModelCustomizationUUID());
+ String vfCustomizationUUID = toscaResourceStruct.getSdcCsarHelper()
+ .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
+ logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
+
+ IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
+
+ // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before comparing their VF Modules UUID's
+ logger.debug("Checking if Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() +
+ " matches Tosca VF Customization UUID: " + vfCustomizationUUID);
+
+ if(vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())){
+
+ logger.debug("vfCustomizationUUID: " + vfCustomizationUUID + " matches vfNotificationResource CustomizationUUID");
+
+ VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service);
+
+ Set<CvnfcCustomization> existingCvnfcSet = new HashSet<CvnfcCustomization>();
+ Set<VnfcCustomization> existingVnfcSet = new HashSet<VnfcCustomization>();
+
+ for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
+
+ logger.debug("vfModuleStructure:" + vfModuleStructure.toString());
+ List<org.onap.sdc.toscaparser.api.Group> vfGroups = toscaResourceStruct
+ .getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID);
+ IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();
+
+ logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID());
+
+ Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream()
+ .peek(group -> logger.debug("To Csar Group VFModuleModelCustomizationUUID " + group.getMetadata().getValue("vfModuleModelCustomizationUUID")))
+ .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID()))
+ .findFirst();
+ if(matchingObject.isPresent()){
+ VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), nodeTemplate, toscaResourceStruct,
+ vfResourceStructure,vfMetadata, vnfResource, service, existingCvnfcSet, existingVnfcSet);
+ vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources());
+ }else
+ throw new Exception("Cannot find matching VFModule Customization in Csar for Vf_Modules_Metadata: " + vfMetadata.getVfModuleModelCustomizationUUID());
+
}
+ service.getVnfCustomizations().add(vnfResource);
+ } else{
+ logger.debug("Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match " +
+ "Tosca VF Customization UUID: " + vfCustomizationUUID);
}
}
-
- service.getVnfCustomizations().add(vnfResource);
}
public void processWatchdog(String distributionId, String servideUUID) {
@@ -762,6 +931,7 @@ public class ToscaResourceInstaller {
spCustomizationResource.setSourceService(service);
spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
serviceProxyCustomizationSet.add(spCustomizationResource);
+
toscaResourceStructure.setCatalogServiceProxyResourceCustomization(spCustomizationResource);
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java
new file mode 100644
index 0000000000..bc9275bb51
--- /dev/null
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java
@@ -0,0 +1,185 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Huawei 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.asdc.installer.heat;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.onap.sdc.toscaparser.api.Property;
+import org.onap.sdc.toscaparser.api.elements.Metadata;
+import org.onap.sdc.toscaparser.api.functions.GetInput;
+import org.onap.sdc.toscaparser.api.parameters.Input;
+import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
+import org.onap.so.asdc.installer.ToscaResourceStructure;
+import org.onap.so.db.catalog.beans.Service;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
+public class ToscaResourceInputTest {
+ @Rule
+ public MockitoRule rule = MockitoJUnit.rule();
+
+ @Mock
+ ISdcCsarHelper sdcCsarHelper;
+
+ @Mock
+ NodeTemplate nodeTemplate;
+
+ @Mock
+ Property property;
+
+ @Mock
+ GetInput getInput;
+
+ @Mock
+ Input input;
+
+ @Test
+ public void processResourceSequenceTest() {
+ ToscaResourceInstaller toscaResourceInstaller = new ToscaResourceInstaller();
+ ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure();
+ toscaResourceStructure.setSdcCsarHelper(sdcCsarHelper);
+ ArrayList<Input> inputs = new ArrayList<>();
+ Service service = new Service();
+
+ HashMap<String, Object> hashMap = new HashMap();
+ hashMap.put("name", "node1");
+
+ Metadata metadata = new Metadata(hashMap);
+ when(nodeTemplate.getMetaData()).thenReturn(metadata);
+ when(sdcCsarHelper.getServiceInputs()).thenReturn(inputs);
+ when(sdcCsarHelper.getServiceNodeTemplates()).thenReturn(Arrays.asList(nodeTemplate));
+ when(sdcCsarHelper.getRequirementsOf(any())).thenReturn(null);
+
+
+ toscaResourceInstaller.processResourceSequence(toscaResourceStructure, service);
+ assertEquals(service.getResourceOrder(), "node1");
+ }
+
+ @Test
+ public void resouceInputTest() throws ArtifactInstallerException {
+ ToscaResourceInstaller toscaResourceInstaller = new ToscaResourceInstaller();
+ ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure();
+
+ toscaResourceStructure.setSdcCsarHelper(sdcCsarHelper);
+
+ HashMap hashMap = new HashMap();
+ hashMap.put("customizationUUID", "id1");
+ Metadata metadata = new Metadata(hashMap);
+
+ LinkedHashMap propertyMap = new LinkedHashMap();
+ propertyMap.put("prop1", property);
+
+ when(sdcCsarHelper.getServiceNodeTemplates()).thenReturn(Arrays.asList(nodeTemplate));
+ when(nodeTemplate.getMetaData()).thenReturn(metadata);
+ when(nodeTemplate.getProperties()).thenReturn(propertyMap);
+ when(property.getValue()).thenReturn("value1");
+
+ String resourceInput = toscaResourceInstaller.getResourceInput(toscaResourceStructure, "id1");
+ assertEquals("{\\\"prop1\\\":\\\"value1\\\"}", resourceInput);
+ }
+
+ @Test
+ public void resouceInputGetInputTest() throws ArtifactInstallerException {
+ ToscaResourceInstaller toscaResourceInstaller = new ToscaResourceInstaller();
+ ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure();
+
+ toscaResourceStructure.setSdcCsarHelper(sdcCsarHelper);
+
+ HashMap hashMap = new HashMap();
+ hashMap.put("customizationUUID", "id1");
+ Metadata metadata = new Metadata(hashMap);
+
+ LinkedHashMap propertyMap = new LinkedHashMap();
+ propertyMap.put("prop1", property);
+
+ when(sdcCsarHelper.getServiceNodeTemplates()).thenReturn(Arrays.asList(nodeTemplate));
+ when(sdcCsarHelper.getServiceInputs()).thenReturn(Arrays.asList(input));
+ when(nodeTemplate.getMetaData()).thenReturn(metadata);
+ when(nodeTemplate.getProperties()).thenReturn(propertyMap);
+ when(property.getValue()).thenReturn(getInput);
+ when(getInput.getInputName()).thenReturn("res_key");
+ when(input.getName()).thenReturn("res_key");
+ when(input.getDefault()).thenReturn("default_value");
+
+ String resourceInput = toscaResourceInstaller.getResourceInput(toscaResourceStructure, "id1");
+ assertEquals("{\\\"prop1\\\":\\\"res_key|default_value\\\"}", resourceInput);
+ }
+
+ @Test
+ public void resouceInputGetInputDefaultIntegerTest() throws ArtifactInstallerException {
+ ToscaResourceInstaller toscaResourceInstaller = new ToscaResourceInstaller();
+ ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure();
+
+ toscaResourceStructure.setSdcCsarHelper(sdcCsarHelper);
+
+ HashMap hashMap = new HashMap();
+ hashMap.put("customizationUUID", "id1");
+ Metadata metadata = new Metadata(hashMap);
+
+ LinkedHashMap propertyMap = new LinkedHashMap();
+ propertyMap.put("prop1", property);
+
+ when(sdcCsarHelper.getServiceNodeTemplates()).thenReturn(Arrays.asList(nodeTemplate));
+ when(sdcCsarHelper.getServiceInputs()).thenReturn(Arrays.asList(input));
+ when(nodeTemplate.getMetaData()).thenReturn(metadata);
+ when(nodeTemplate.getProperties()).thenReturn(propertyMap);
+ when(property.getValue()).thenReturn(getInput);
+ when(getInput.getInputName()).thenReturn("res_key");
+ when(input.getName()).thenReturn("res_key");
+ when(input.getDefault()).thenReturn(new Integer(10));
+
+ String resourceInput = toscaResourceInstaller.getResourceInput(toscaResourceStructure, "id1");
+ assertEquals("{\\\"prop1\\\":\\\"res_key|10\\\"}", resourceInput);
+ }
+
+ @Test
+ public void resouceInputGetInputNoPropertyTest() throws ArtifactInstallerException {
+ ToscaResourceInstaller toscaResourceInstaller = new ToscaResourceInstaller();
+ ToscaResourceStructure toscaResourceStructure = new ToscaResourceStructure();
+
+ toscaResourceStructure.setSdcCsarHelper(sdcCsarHelper);
+
+ HashMap hashMap = new HashMap();
+ hashMap.put("customizationUUID", "id1");
+ Metadata metadata = new Metadata(hashMap);
+
+ LinkedHashMap propertyMap = new LinkedHashMap();
+
+ when(sdcCsarHelper.getServiceNodeTemplates()).thenReturn(Arrays.asList(nodeTemplate));
+ when(sdcCsarHelper.getServiceInputs()).thenReturn(Arrays.asList(input));
+ when(nodeTemplate.getMetaData()).thenReturn(metadata);
+ when(nodeTemplate.getProperties()).thenReturn(propertyMap);
+
+ String resourceInput = toscaResourceInstaller.getResourceInput(toscaResourceStructure, "id1");
+ assertEquals("{}", resourceInput);
+ }
+}
diff --git a/asdc-controller/src/test/resources/schema.sql b/asdc-controller/src/test/resources/schema.sql
index b17fb5d47c..17423f8434 100644
--- a/asdc-controller/src/test/resources/schema.sql
+++ b/asdc-controller/src/test/resources/schema.sql
@@ -31,6 +31,7 @@ create table `allotted_resource_customization` (
`min_instances` int(11) default null,
`max_instances` int(11) default null,
`ar_model_uuid` varchar(200) not null,
+ `resource_input` varchar(20000) default null,
`creation_timestamp` datetime not null default current_timestamp,
primary key (`model_customization_uuid`),
key `fk_allotted_resource_customization__allotted_resource1_idx` (`ar_model_uuid`),
@@ -141,11 +142,11 @@ create table `network_resource` (
`model_name` varchar(200) not null,
`model_invariant_uuid` varchar(200) default null,
`description` varchar(1200) default null,
- `heat_template_artifact_uuid` varchar(200) not null,
+ `heat_template_artifact_uuid` varchar(200) null,
`neutron_network_type` varchar(20) default null,
`model_version` varchar(20) default null,
`tosca_node_type` varchar(200) default null,
- `aic_version_min` varchar(20) not null,
+ `aic_version_min` varchar(20) null,
`aic_version_max` varchar(20) default null,
`orchestration_mode` varchar(20) default 'heat',
`resource_category` varchar(20) default null,
@@ -154,8 +155,7 @@ create table `network_resource` (
primary key (`model_uuid`),
key `fk_network_resource__temp_network_heat_template_lookup1_idx` (`model_name`),
key `fk_network_resource__heat_template1_idx` (`heat_template_artifact_uuid`),
- constraint `fk_network_resource__heat_template1` foreign key (`heat_template_artifact_uuid`) references `heat_template` (`artifact_uuid`) on delete no action on update cascade,
- constraint `fk_network_resource__temp_network_heat_template_lookup__mod_nm1` foreign key (`model_name`) references `temp_network_heat_template_lookup` (`network_resource_model_name`) on delete no action on update no action
+ constraint `fk_network_resource__heat_template1` foreign key (`heat_template_artifact_uuid`) references `heat_template` (`artifact_uuid`) on delete no action on update cascade
) engine=innodb default charset=latin1;
@@ -171,6 +171,7 @@ create table `network_resource_customization` (
`network_scope` varchar(45) default null,
`creation_timestamp` datetime not null default current_timestamp,
`network_resource_model_uuid` varchar(200) not null,
+ `resource_input` varchar(20000) default null,
primary key (`model_customization_uuid`),
key `fk_network_resource_customization__network_resource1_idx` (`network_resource_model_uuid`),
constraint `fk_network_resource_customization__network_resource1` foreign key (`network_resource_model_uuid`) references `network_resource` (`model_uuid`) on delete cascade on update cascade
@@ -207,6 +208,7 @@ create table `service` (
`environment_context` varchar(200) default null,
`workload_context` varchar(200) default null,
`service_category` varchar(200) default null,
+ `resource_order` varchar(200) default null,
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
@@ -396,6 +398,7 @@ create table `vnf_resource_customization` (
`creation_timestamp` datetime not null default current_timestamp,
`vnf_resource_model_uuid` varchar(200) not null,
`multi_stage_design` varchar(20) default null,
+ `resource_input` varchar(20000) default null,
primary key (`model_customization_uuid`),
key `fk_vnf_resource_customization__vnf_resource1_idx` (`vnf_resource_model_uuid`),
constraint `fk_vnf_resource_customization__vnf_resource1` foreign key (`vnf_resource_model_uuid`) references `vnf_resource` (`model_uuid`) on delete cascade on update cascade