summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java4
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceMacroHolder.java2
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceNetworks.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/resources/db/migration/V4.22__AddResourceInput.sql13
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/schema.sql4
-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/heat/ToscaResourceInstaller.java153
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java1
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java136
-rw-r--r--asdc-controller/src/test/resources/schema.sql4
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql4
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResourceCustomization.java11
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkResourceCustomization.java11
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/Service.java11
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java11
-rw-r--r--mso-catalog-db/src/test/resources/schema.sql6
17 files changed, 368 insertions, 9 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java
index 7a215a9458..859666f446 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java
@@ -52,7 +52,8 @@ public class QueryAllottedResourceCustomization extends CatalogQuery {
"\t\t\"nfFunction\" : <NF_FUNCTION>,\n"+
"\t\t\"nfType\" : <NF_TYPE>,\n"+
"\t\t\"nfRole\" : <NF_ROLE>,\n"+
- "\t\t\"nfNamingCode\" : <NF_NAMING_CODE>\n"+
+ "\t\t\"nfNamingCode\" : <NF_NAMING_CODE>,\n"+
+ "\t\t\"resourceInput\" : <RESOURCE_INPUT>\n"+
"\t}";
public QueryAllottedResourceCustomization() {
@@ -125,6 +126,7 @@ public class QueryAllottedResourceCustomization extends CatalogQuery {
put(valueMap, "PROVIDING_SERVICE_MODEL_INVARIANT_UUID", o.getProvidingServiceModelInvariantUUID());
put(valueMap, "PROVIDING_SERVICE_MODEL_UUID", o.getProvidingServiceModelUUID());
put(valueMap, "PROVIDING_SERVICE_MODEL_NAME", o.getProvidingServiceModelName());
+ put(valueMap, "RESOURCE_INPUT", o.getResourceInput());
sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap));
sep = ",\n";
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 3b50871a8d..edbf9749c6 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
@@ -45,6 +45,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"+
@@ -81,6 +82,7 @@ public class QueryServiceMacroHolder extends CatalogQuery {
put(valueMap, "SERVICE_ROLE", service.getServiceRole());
put(valueMap, "ENVIRONMENT_CONTEXT", service.getEnvironmentContext());
put(valueMap, "WORKLOAD_CONTEXT", service.getWorkloadContext());
+ put(valueMap, "RESOURCE_ORDER", service.getResourceOrder());
String subitem;
subitem = new QueryServiceVnfs(service.getVnfCustomizations()).JSON2(true, true);
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceNetworks.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceNetworks.java
index a2256f724a..f7457fda4a 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceNetworks.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceNetworks.java
@@ -50,6 +50,7 @@ public class QueryServiceNetworks extends CatalogQuery {
"\t\t\"toscaNodeType\" : <TOSCA_NODE_TYPE>,\n"+
"\t\t\"networkType\" : <NETWORK_TYPE>,\n"+
"\t\t\"networkTechnology\" : <NETWORK_TECHNOLOGY>,\n"+
+ "\t\t\"resourceInput\" : <RESOURCE_INPUT>,\n"+
"\t\t\"networkRole\" : <NETWORK_ROLE>,\n"+
"\t\t\"networkScope\" : <NETWORK_SCOPE>\n"+
"\t}";
@@ -116,6 +117,7 @@ public class QueryServiceNetworks extends CatalogQuery {
put(valueMap, "NETWORK_ROLE", o.getNetworkRole());
put(valueMap, "NETWORK_SCOPE", o.getNetworkScope());
put(valueMap, "NETWORK_TECHNOLOGY", o.getNetworkTechnology());
+ put(valueMap, "RESOURCE_INPUT", o.getResourceInput());
sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap));
sep = ",\n";
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 82b6aa2aeb..4170047e0b 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
@@ -53,6 +53,7 @@ public class QueryServiceVnfs extends CatalogQuery {
"\t\"nfRole\" : <NF_ROLE>,\n"+
"\t\"nfNamingCode\" : <NF_NAMING_CODE>,\n"+
"\t\"multiStageDesign\" : <MULTI_STEP_DESIGN>,\n"+
+ "\t\"resourceInput\" : <RESOURCE_INPUT>,\n"+
"<_VFMODULES_>\n" +
"\t}";
@@ -119,6 +120,7 @@ public class QueryServiceVnfs extends CatalogQuery {
put(valueMap, "NF_ROLE", o.getNfRole());
put(valueMap, "NF_NAMING_CODE", o.getNfNamingCode());
put(valueMap, "MULTI_STEP_DESIGN", o.getMultiStageDesign());
+ put(valueMap, "RESOURCE_INPUT", o.getResourceInput());
String subitem = new QueryVfModule(vrNull ? null : o.getVfModuleCustomizations()).JSON2(true, true);
valueMap.put("_VFMODULES_", subitem.replaceAll("(?m)^", "\t\t"));
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.22__AddResourceInput.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.22__AddResourceInput.sql
new file mode 100644
index 0000000000..10d8789328
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.22__AddResourceInput.sql
@@ -0,0 +1,13 @@
+use catalogdb;
+
+ALTER TABLE service
+ADD RESOURCE_ORDER varchar(255);
+
+ALTER TABLE vnf_resource_customization
+ADD RESOURCE_INPUT varchar(2000);
+
+ALTER TABLE network_resource_customization
+ADD RESOURCE_INPUT varchar(2000);
+
+ALTER TABLE allotted_resource_customization
+ADD RESOURCE_INPUT varchar(2000); \ No newline at end of file
diff --git a/adapters/mso-openstack-adapters/src/test/resources/schema.sql b/adapters/mso-openstack-adapters/src/test/resources/schema.sql
index a051417cc1..eff5c632fa 100644
--- a/adapters/mso-openstack-adapters/src/test/resources/schema.sql
+++ b/adapters/mso-openstack-adapters/src/test/resources/schema.sql
@@ -28,6 +28,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(2000) 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`),
@@ -168,6 +169,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(2000) 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
@@ -203,6 +205,7 @@ create table `service` (
`service_role` varchar(200) default null,
`environment_context` varchar(200) default null,
`workload_context` 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
@@ -381,6 +384,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(2000) 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
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 030035157d..c7c6ecacc0 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
@@ -134,7 +134,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/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
index 529ce30357..c26d4ad0b3 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,24 @@ 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 com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
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.impl.SdcPropertyNames;
import org.onap.sdc.tosca.parser.impl.SdcTypes;
import org.onap.sdc.toscaparser.api.CapabilityAssignment;
@@ -42,8 +50,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;
@@ -284,6 +296,7 @@ public class ToscaResourceInstaller {
createService(toscaResourceStruct, vfResourceStruct);
Service service = toscaResourceStruct.getCatalogService();
+ processResourceSequence(toscaResourceStruct, service);
processVFResources(toscaResourceStruct, service, vfResourceStructure);
processAllottedResources(toscaResourceStruct, service);
processNetworks(toscaResourceStruct, service);
@@ -332,6 +345,129 @@ 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() : "";
+ 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);
+
+ 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 ();
@@ -366,7 +502,8 @@ public class ToscaResourceInstaller {
null,
null,
service);
- service.getNetworkCustomizations().add (networkCustomization);
+ networkCustomization.setResourceInput(getResourceInput(toscaResourceStruct, networkCustomization.getModelCustomizationUUID()));
+ service.getNetworkCustomizations().add (networkCustomization);
logger.debug ("No NetworkResourceName found in TempNetworkHeatTemplateLookup for "
+ networkResourceModelName);
}
@@ -375,13 +512,14 @@ public class ToscaResourceInstaller {
}
}
- protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service) {
+ protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service) throws ArtifactInstallerException {
List<NodeTemplate> allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources();
if (allottedResourceList != null) {
- for (NodeTemplate allottedNode : allottedResourceList) {
- service.getAllottedCustomizations()
- .add(createAllottedResource(allottedNode, toscaResourceStruct, service));
+ for (NodeTemplate allottedNode : allottedResourceList) {
+ AllottedResourceCustomization allottedResource = createAllottedResource(allottedNode, toscaResourceStruct, service);
+ allottedResource.setResourceInput(getResourceInput(toscaResourceStruct, allottedResource.getModelCustomizationUUID()));
+ service.getAllottedCustomizations().add(allottedResource);
}
}
}
@@ -528,6 +666,7 @@ public class ToscaResourceInstaller {
}
}
+ vnfResource.setResourceInput(getResourceInput(toscaResourceStruct, vnfResource.getModelCustomizationUUID()));
service.getVnfCustomizations().add(vnfResource);
}
@@ -1696,7 +1835,7 @@ public class ToscaResourceInstaller {
}
protected AllottedResourceCustomization createAllottedResource(NodeTemplate nodeTemplate,
- ToscaResourceStructure toscaResourceStructure, Service service) {
+ ToscaResourceStructure toscaResourceStructure, Service service) throws ArtifactInstallerException {
AllottedResourceCustomization allottedResourceCustomization = allottedCustomizationRepo
.findOneByModelCustomizationUUID(
nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
@@ -1713,6 +1852,8 @@ public class ToscaResourceInstaller {
allottedResourceCustomization.setAllottedResource(allottedResource);
allottedResource.getAllotedResourceCustomization().add(allottedResourceCustomization);
}
+
+ allottedResourceCustomization.setResourceInput(getResourceInput(toscaResourceStructure, allottedResourceCustomization.getModelCustomizationUUID()));
return allottedResourceCustomization;
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java
index 1944c3af73..e61957d8c2 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java
@@ -148,6 +148,7 @@ public class ASDCRestInterfaceTest extends BaseTest {
AllottedResourceCustomization arCustomization = new AllottedResourceCustomization();
arCustomization.setModelCustomizationUUID("f62bb612-c5d4-4406-865c-0abec30631ba");
arCustomization.setModelInstanceName("rege1802pnf 0");
+ arCustomization.setResourceInput("{}");
arCustomizationSet.add(arCustomization);
arCustomization.setAllottedResource(expectedService);
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..cecf70f916
--- /dev/null
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java
@@ -0,0 +1,136 @@
+/*-
+ * ============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(resourceInput, "{\"prop1\":\"value1\"}");
+ }
+
+ @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(resourceInput, "{\"prop1\":\"res_key|default_value\"}");
+ }
+}
diff --git a/asdc-controller/src/test/resources/schema.sql b/asdc-controller/src/test/resources/schema.sql
index 0372887f15..58772c4998 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(2000) 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`),
@@ -171,6 +172,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(2000) 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 +209,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 +399,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(2000) 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
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
index 381330b928..e1719550b1 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
@@ -30,6 +30,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(2000) 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`),
@@ -170,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(2000) 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
@@ -206,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
@@ -395,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(2000) 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
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResourceCustomization.java
index 00ddf35a5f..04b93c3886 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResourceCustomization.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/AllottedResourceCustomization.java
@@ -93,6 +93,9 @@ public class AllottedResourceCustomization implements Serializable {
@Column(name = "MAX_INSTANCES")
private Integer maxInstances;
+ @Column(name = "RESOURCE_INPUT")
+ private String resourceInput;
+
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "AR_MODEL_UUID")
private AllottedResource allottedResource;
@@ -241,4 +244,12 @@ public class AllottedResourceCustomization implements Serializable {
public void setMaxInstances(Integer maxInstances) {
this.maxInstances = maxInstances;
}
+
+ public String getResourceInput() {
+ return resourceInput;
+ }
+
+ public void setResourceInput(String resourceInput) {
+ this.resourceInput = resourceInput;
+ }
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkResourceCustomization.java
index 7afeac7710..1e3b6fc220 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkResourceCustomization.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/NetworkResourceCustomization.java
@@ -99,6 +99,9 @@ public class NetworkResourceCustomization implements Serializable {
@Column(name = "NETWORK_ROLE")
private String networkRole;
+ @Column(name = "RESOURCE_INPUT")
+ private String resourceInput;
+
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "NETWORK_RESOURCE_MODEL_UUID")
private NetworkResource networkResource = null;
@@ -168,4 +171,12 @@ public class NetworkResourceCustomization implements Serializable {
public String getNetworkRole() {
return this.networkRole;
}
+
+ public String getResourceInput() {
+ return resourceInput;
+ }
+
+ public void setResourceInput(String resourceInput) {
+ this.resourceInput = resourceInput;
+ }
}
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 6eb453805b..28ff778d44 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
@@ -92,6 +92,9 @@ public class Service implements Serializable {
@Column(name = "SERVICE_CATEGORY")
private String category;
+ @Column(name = "RESOURCE_ORDER")
+ private String resourceOrder;
+
@OneToMany(cascade = CascadeType.ALL)
@JoinTable(name = "network_resource_customization_to_service", joinColumns = @JoinColumn(name = "SERVICE_MODEL_UUID"), inverseJoinColumns = @JoinColumn(name = "RESOURCE_MODEL_CUSTOMIZATION_UUID"))
private List<NetworkResourceCustomization> networkCustomizations;
@@ -332,4 +335,12 @@ public class Service implements Serializable {
public void setWorkloadContext(String workloadContext) {
this.workloadContext = workloadContext;
}
+
+ public String getResourceOrder() {
+ return resourceOrder;
+ }
+
+ public void setResourceOrder(String resourceOrder) {
+ this.resourceOrder = resourceOrder;
+ }
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java
index d286bc0727..53e8c9613e 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfResourceCustomization.java
@@ -97,6 +97,9 @@ public class VnfResourceCustomization implements Serializable {
@Column(name = "MULTI_STAGE_DESIGN")
private String multiStageDesign;
+ @Column(name = "RESOURCE_INPUT")
+ private String resourceInput;
+
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "VNF_RESOURCE_MODEL_UUID")
private VnfResource vnfResources;
@@ -283,4 +286,12 @@ public class VnfResourceCustomization implements Serializable {
public void setCvnfcCustomization(List<CvnfcCustomization> cvnfcCustomization) {
this.cvnfcCustomization = cvnfcCustomization;
}
+
+ public String getResourceInput() {
+ return resourceInput;
+ }
+
+ public void setResourceInput(String resourceInput) {
+ this.resourceInput = resourceInput;
+ }
}
diff --git a/mso-catalog-db/src/test/resources/schema.sql b/mso-catalog-db/src/test/resources/schema.sql
index 6eaad260ea..9ee24d78ad 100644
--- a/mso-catalog-db/src/test/resources/schema.sql
+++ b/mso-catalog-db/src/test/resources/schema.sql
@@ -69,6 +69,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(2000) 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`),
@@ -209,6 +210,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(2000) 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
@@ -245,6 +247,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
@@ -434,6 +437,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(2000) 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
@@ -744,7 +748,7 @@ create table if not exists `collection_network_resource_customization` (
`network_type` varchar(45) null,
`network_role` varchar(200) null,
`network_scope` varchar(45) null,
-`creation_timestamp` datetime not null default current_timestamp,
+`creation_timestamp` datetime not null default current_timestamp,
`network_resource_model_uuid` varchar(200) not null, `instance_group_model_uuid` varchar(200) null,
`crc_model_customization_uuid` varchar(200) not null, primary key
(`model_customization_uuid`, `crc_model_customization_uuid`),