aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/DataEntity.java8
-rw-r--r--jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/NodeTemplate.java14
-rw-r--r--jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/SubstitutionMappings.java21
-rw-r--r--jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/TopologyTemplate.java6
-rw-r--r--jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/parameters/Input.java37
-rw-r--r--sdc-distribution-ci/src/main/java/org/openecomp/test/CsarToscaTester.java21
-rw-r--r--sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java28
7 files changed, 66 insertions, 69 deletions
diff --git a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/DataEntity.java b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/DataEntity.java
index a96b36a..a081f89 100644
--- a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/DataEntity.java
+++ b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/DataEntity.java
@@ -52,12 +52,14 @@ public class DataEntity {
ExceptionCollector.appendWarning(String.format(
"TypeMismatchError: \"%s\" is not a map. The type is \"%s\"",
value.toString(),dataType.getType()));
-
- if (value instanceof List)
+
+ if (value instanceof List && ((List) value).size() > 0) {
value = ((List) value).get(0);
+ }
- if (!(value instanceof LinkedHashMap))
+ if (!(value instanceof LinkedHashMap)) {
return value;
+ }
}
diff --git a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/NodeTemplate.java b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/NodeTemplate.java
index 2c9d981..4d0baaf 100644
--- a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/NodeTemplate.java
+++ b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/NodeTemplate.java
@@ -467,19 +467,9 @@ public class NodeTemplate extends EntityTemplate {
@Override
public String toString() {
- return "NodeTemplate{" +
- //"templates=" + templates +
- //", customDef=" + customDef +
- //", availableRelTpls=" + availableRelTpls +
- //", availableRelTypes=" + availableRelTypes +
- //", related=" + related +
- //", relationshipTpl=" + relationshipTpl +
- //", _relationships=" + _relationships +
- ", subMappingToscaTemplate=" + (subMappingToscaTemplate==null?"":subMappingToscaTemplate.toLimitedString()) +
- //", subMappingToscaTemplate2=" +( subMappingToscaTemplate2 ==null?"":subMappingToscaTemplate2.toLimitedString()) +
- ", metadata=" + metadata +
- '}';
+ return getName();
}
+
}
/*python
diff --git a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/SubstitutionMappings.java b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/SubstitutionMappings.java
index f02ec2a..153bd89 100644
--- a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/SubstitutionMappings.java
+++ b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/SubstitutionMappings.java
@@ -286,18 +286,19 @@ public class SubstitutionMappings {
@Override
public String toString() {
return "SubstitutionMappings{" +
- "subMappingDef=" + subMappingDef +
- ", nodetemplates=" + nodetemplates +
- ", inputs=" + inputs +
- ", outputs=" + outputs +
- ", groups=" + groups +
- ", subMappedNodeTemplate=" + subMappedNodeTemplate +
- ", customDefs=" + customDefs +
- ", _capabilities=" + _capabilities +
- ", _requirements=" + _requirements +
+// "subMappingDef=" + subMappingDef +
+// ", nodetemplates=" + nodetemplates +
+// ", inputs=" + inputs +
+// ", outputs=" + outputs +
+// ", groups=" + groups +
+ ", subMappedNodeTemplate=" + (subMappedNodeTemplate==null?"":subMappedNodeTemplate.getName()) +
+// ", customDefs=" + customDefs +
+// ", _capabilities=" + _capabilities +
+// ", _requirements=" + _requirements +
'}';
}
+ @Deprecated
public String toLimitedString() {
return "SubstitutionMappings{" +
"subMappingDef=" + subMappingDef +
@@ -305,7 +306,7 @@ public class SubstitutionMappings {
", inputs=" + inputs +
", outputs=" + outputs +
", groups=" + groups +
- ", subMappedNodeTemplate=" + subMappedNodeTemplate.getName() +
+ ", subMappedNodeTemplate=" + (subMappedNodeTemplate==null?"":subMappedNodeTemplate.getName()) +
", customDefs=" + customDefs +
", _capabilities=" + _capabilities +
", _requirements=" + _requirements +
diff --git a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/TopologyTemplate.java b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/TopologyTemplate.java
index 39536ca..4050643 100644
--- a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/TopologyTemplate.java
+++ b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/TopologyTemplate.java
@@ -84,7 +84,7 @@ public class TopologyTemplate {
ArrayList<Input> alInputs = new ArrayList<>();
for(String name: _tplInputs().keySet()) {
Object attrs = _tplInputs().get(name);
- Input input = new Input(name,(LinkedHashMap<String,Object>)attrs,customDefs);//ATT-CDT
+ Input input = new Input(name,(LinkedHashMap<String,Object>)attrs,customDefs);
if(parsedParams != null && parsedParams.get(name) != null) {
input.validate(parsedParams.get(name));
}
@@ -173,7 +173,7 @@ public class TopologyTemplate {
nodeTemplates,
inputs,
outputs,
- groups, //ATT addition
+ groups,
subMappedNodeTemplate,
customDefs);
}
@@ -232,7 +232,7 @@ public class TopologyTemplate {
DataEntity.validateDatatype("list", memberNames,null,null,null);
if(memberNames.size() < 1 ||
(new HashSet<String>(memberNames)).size() != memberNames.size()) {
- ExceptionCollector.appendException(String.format(
+ ExceptionCollector.appendWarning(String.format(
"InvalidGroupTargetException: Member nodes \"%s\" should be >= 1 and not repeated",
memberNames.toString()));
}
diff --git a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/parameters/Input.java b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/parameters/Input.java
index 2eb64e8..96958ce 100644
--- a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/parameters/Input.java
+++ b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/parameters/Input.java
@@ -1,6 +1,7 @@
package org.openecomp.sdc.toscaparser.api.parameters;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.LinkedHashMap;
import org.openecomp.sdc.toscaparser.api.DataEntity;
@@ -18,19 +19,31 @@ public class Input {
private static final String REQUIRED = "required";
private static final String STATUS = "status";
private static final String ENTRY_SCHEMA = "entry_schema";
+
+ public static final String INTEGER = "integer";
+ public static final String STRING = "string";
+ public static final String BOOLEAN = "boolean";
+ public static final String FLOAT = "float";
+ public static final String LIST = "list";
+ public static final String MAP = "map";
+ public static final String JSON = "json";
private static String INPUTFIELD[] = {
TYPE, DESCRIPTION, DEFAULT, CONSTRAINTS, REQUIRED,STATUS, ENTRY_SCHEMA
};
+
+ private static String PRIMITIVE_TYPES[] = {
+ INTEGER, STRING, BOOLEAN, FLOAT, LIST, MAP, JSON
+ };
private String name;
private Schema schema;
- private LinkedHashMap<String,Object> customDefs;//ATT-CDT
+ private LinkedHashMap<String,Object> customDefs;
- public Input(String _name,LinkedHashMap<String,Object> _schemaDict,LinkedHashMap<String,Object> _customDefs) {//ATT-CDT
+ public Input(String _name,LinkedHashMap<String,Object> _schemaDict,LinkedHashMap<String,Object> _customDefs) {
name = _name;
schema = new Schema(_name,_schemaDict);
- customDefs = _customDefs;//ATT-CDT
+ customDefs = _customDefs;
}
public String getName() {
@@ -90,13 +103,13 @@ public class Input {
break;
}
}
- //ATT-CDT
+
if(!bFound) {
if(customDefs.get(inputType) != null) {
bFound = true;
}
}
- //ATT-CDT
+
if(!bFound) {
ExceptionCollector.appendException(String.format(
"ValueError: Invalid type \"%s\"",inputType));
@@ -111,14 +124,20 @@ public class Input {
else if(EntityType.TOSCA_DEF.get(EntityType.DATATYPE_NETWORK_PREFIX + getType()) != null) {
datatype = EntityType.TOSCA_DEF.get(EntityType.DATATYPE_NETWORK_PREFIX + getType());
}
- //ATT-CDT
+
+ String type = getType();
+ // if it's one of the basic types DON'T look in customDefs
+ if(Arrays.asList(PRIMITIVE_TYPES).contains(type)) {
+ DataEntity.validateDatatype(getType(), value, null, (LinkedHashMap<String,Object>)datatype, null);
+ return;
+ }
else if(customDefs.get(getType()) != null) {
datatype = customDefs.get(getType());
- DataEntity.validateDatatype(getType(),value,(LinkedHashMap<String,Object>)datatype,customDefs,null);
+ DataEntity.validateDatatype(getType(), value, (LinkedHashMap<String,Object>)datatype, customDefs, null);
return;
}
- //ATT-CDT
- DataEntity.validateDatatype(getType(),value,null,(LinkedHashMap<String,Object>)datatype,null);
+
+ DataEntity.validateDatatype(getType(), value, null, (LinkedHashMap<String,Object>)datatype, null);
}
}
diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/CsarToscaTester.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/CsarToscaTester.java
index 068ef24..b07de08 100644
--- a/sdc-distribution-ci/src/main/java/org/openecomp/test/CsarToscaTester.java
+++ b/sdc-distribution-ci/src/main/java/org/openecomp/test/CsarToscaTester.java
@@ -27,7 +27,8 @@ public class CsarToscaTester {
Date now = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("d-MM-y-HH_mm_ss");
String time = dateFormat.format(now);
- File dir = new File(args[1].toString() + "/csar-reports-" + time);
+ String csarsDir = args[1].toString() + "/csar-reports-" + time;
+ File dir = new File(csarsDir);
dir.mkdir();
@@ -35,7 +36,10 @@ public class CsarToscaTester {
if (file.isFile()) {
System.out.println("File " + file.getAbsolutePath());
ExceptionCollector.clear();
-
+ String name = file.getName();
+ String currentCsarDir = csarsDir+"/"+name+"-"+time;
+ dir = new File(currentCsarDir);
+ dir.mkdir();
ISdcCsarHelper csarHelper = factory.getSdcCsarHelper(file.getAbsolutePath());
List<NodeTemplate> vflist = csarHelper.getServiceVfList();
List<Input> inputs = csarHelper.getServiceInputs();
@@ -44,18 +48,19 @@ public class CsarToscaTester {
List<String> warningsReport = ExceptionCollector.getWarningsReport();
//System.out.println("WARNINGS during CSAR parsing are: " + (warningsReport != null ? warningsReport.toString() : "none"));
+
if (!exceptionReport.isEmpty()) {
try {
- fw = new FileWriter(new File(dir + "/" + exceptionReport.size() / 2 + "-critical-" + file.getName() + ".txt"));
+ fw = new FileWriter(new File(currentCsarDir + "/" + exceptionReport.size() / 2 + "-critical-" + name +"-"+time + ".txt"));
for (String exception : exceptionReport) {
fw.write(exception);
fw.write("\r\n");
}
fw.close();
- fw = new FileWriter(new File(dir + "/" + warningsReport.size() / 2 + "-warning-" + file.getName() + ".txt"));
+ fw = new FileWriter(new File(currentCsarDir + "/" + warningsReport.size() / 2 + "-warning-" + name +"-"+time + ".txt"));
for (String warning : warningsReport) {
fw.write(warning);
fw.write("\r\n");
@@ -63,6 +68,14 @@ public class CsarToscaTester {
fw.close();
+ //TODO
+ fw = new FileWriter(new File(currentCsarDir + "/" + exceptionReport.size() / 2 + "-critical-" + name +"-"+time + ".txt"));
+ for (String critical : exceptionReport) {
+ fw.write(critical);
+ fw.write("\r\n");
+ }
+ fw.close();
+
} catch (IOException ex) {
ex.printStackTrace();
}
diff --git a/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
index b9ce069..df1d470 100644
--- a/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
+++ b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
@@ -68,10 +68,8 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
log.error("getNodeTemplatePropertyLeafValue - leafValuePath is null or empty");
return null;
}
- log.debug("getNodeTemplatePropertyLeafValue - nodeTemplate is : {}, leafValuePath is {} ", nodeTemplate, leafValuePath);
String[] split = getSplittedPath(leafValuePath);
LinkedHashMap<String, Property> properties = nodeTemplate.getProperties();
- log.debug("getNodeTemplatePropertyLeafValue - properties of nodeTemplate are : {}", properties);
Object property = processProperties(split, properties);
return property == null ? null : String.valueOf(property);
}
@@ -86,10 +84,8 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
log.error("getNodeTemplatePropertyAsObject - leafValuePath is null or empty");
return null;
}
- log.debug("getNodeTemplatePropertyAsObject - nodeTemplate is : {}, leafValuePath is {} ", nodeTemplate, leafValuePath);
String[] split = getSplittedPath(leafValuePath);
LinkedHashMap<String, Property> properties = nodeTemplate.getProperties();
- log.debug("getNodeTemplatePropertyAsObject - properties of nodeTemplate are : {}", properties);
return processProperties(split, properties);
}
@@ -134,7 +130,6 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
//Sunny flow - covered with UT
public List<NodeTemplate> getServiceVlList() {
List<NodeTemplate> serviceVlList = getNodeTemplateBySdcType(toscaTemplate.getTopologyTemplate(), Types.TYPE_VL);
- log.debug("getServiceVlList - the VL list is {}", serviceVlList);
return serviceVlList;
}
@@ -142,7 +137,6 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
//Sunny flow - covered with UT
public List<NodeTemplate> getServiceVfList() {
List<NodeTemplate> serviceVfList = getNodeTemplateBySdcType(toscaTemplate.getTopologyTemplate(), Types.TYPE_VF);
- log.debug("getServiceVfList - the VF list is {}", serviceVfList);
return serviceVfList;
}
@@ -158,7 +152,6 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
return null;
}
String metadataPropertyValue = metadata.getValue(metadataPropertyName);
- log.debug("getMetadataPropertyValue - metadata is {} metadataPropertyName is {} the value is : {}", metadata, metadataPropertyName, metadataPropertyValue);
return metadataPropertyValue;
}
@@ -179,7 +172,6 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
}
}
- log.debug("getServiceNodeTemplatesByType - For Node Type : {} - NodeTemplate list value is: {}", nodeType, res);
return res;
}
@@ -193,7 +185,6 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
List<NodeTemplate> serviceVfList = getServiceVfList();
NodeTemplate vfInstance = getNodeTemplateByCustomizationUuid(serviceVfList, vfCustomizationId);
- log.debug("getVfcListByVf - serviceVfList value: {}, vfInstance value: {}", serviceVfList, vfInstance);
return getNodeTemplateBySdcType(vfInstance, Types.TYPE_VFC);
}
@@ -201,9 +192,7 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
//Sunny flow - covered with UT
public List<Group> getVfModulesByVf(String vfCustomizationUuid) {
List<NodeTemplate> serviceVfList = getServiceVfList();
- log.debug("getVfModulesByVf - VF list is {}", serviceVfList);
NodeTemplate nodeTemplateByCustomizationUuid = getNodeTemplateByCustomizationUuid(serviceVfList, vfCustomizationUuid);
- log.debug("getVfModulesByVf - getNodeTemplateByCustomizationUuid is {}, customizationUuid {}", nodeTemplateByCustomizationUuid, vfCustomizationUuid);
if (nodeTemplateByCustomizationUuid != null) {
/*SubstitutionMappings substitutionMappings = nodeTemplateByCustomizationUuid.getSubstitutionMappings();
if (substitutionMappings != null){
@@ -223,7 +212,6 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
.stream()
.filter(x -> "org.openecomp.groups.VfModule".equals(x.getTypeDefinition().getType()) && x.getName().startsWith(normaliseComponentInstanceName))
.collect(Collectors.toList());
- log.debug("getVfModulesByVf - VfModules are {}", collect);
return collect;
}
}
@@ -245,11 +233,9 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
}
List<Input> inputs = toscaTemplate.getInputs();
- log.debug("getServiceInputLeafValue - the leafValuePath is {} , the inputs are {}", inputLeafValuePath, inputs);
if (inputs != null) {
Optional<Input> findFirst = inputs.stream().filter(x -> x.getName().equals(split[0])).findFirst();
if (findFirst.isPresent()) {
- log.debug("getServiceInputLeafValue - find first item is {}", findFirst.get());
Input input = findFirst.get();
Object current = input.getDefault();
Object property = iterateProcessPath(2, current, split);
@@ -274,11 +260,9 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
}
List<Input> inputs = toscaTemplate.getInputs();
- log.debug("getServiceInputLeafValueOfDefaultAsObject - the leafValuePath is {} , the inputs are {}", inputLeafValuePath, inputs);
if (inputs != null) {
Optional<Input> findFirst = inputs.stream().filter(x -> x.getName().equals(split[0])).findFirst();
if (findFirst.isPresent()) {
- log.debug("getServiceInputLeafValueOfDefaultAsObject - find first item is {}", findFirst.get());
Input input = findFirst.get();
Object current = input.getDefault();
return iterateProcessPath(2, current, split);
@@ -308,7 +292,6 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
}
}
if (current != null) {
- log.debug("iterateProcessPath - the input default leaf value is {}", String.valueOf(current));
return current;
}
log.error("iterateProcessPath - Path not Found");
@@ -328,14 +311,12 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
log.debug("getServiceSubstitutionMappingsTypeName - No Substitution Mappings defined");
return null;
}
- log.debug("getServiceSubstitutionMappingsTypeName - SubstitutionMappings value: {}", substitutionMappings);
NodeType nodeType = substitutionMappings.getNodeDefinition();
if (nodeType == null) {
log.debug("getServiceSubstitutionMappingsTypeName - No Substitution Mappings node defined");
return null;
}
- log.debug("getServiceSubstitutionMappingsTypeName - nodeType value: {}", nodeType);
return nodeType.getType();
}
@@ -403,7 +384,6 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
return cpList;
}
NodeTemplate vfInstance = getNodeTemplateByCustomizationUuid(serviceVfList, vfCustomizationId);
- log.debug("getCpListByVf vf list is {}", vfInstance);
if (vfInstance == null) {
log.debug("getCpListByVf vf list is null");
return cpList;
@@ -436,12 +416,9 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
.stream()
.filter(x -> (x.getMetadata() != null && serviceLevelVfModule.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID).equals(x.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)))).findFirst();
if (findFirst.isPresent()) {
- log.debug("getMembersOfVfModule - Found VF level group with vfModuleModelInvariantUUID {}", serviceLevelVfModule.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID));
List<String> members = findFirst.get().getMembers();
- log.debug("getMembersOfVfModule - members section is {}", members);
if (members != null) {
List<NodeTemplate> collect = substitutionMappings.getNodeTemplates().stream().filter(x -> members.contains(x.getName())).collect(Collectors.toList());
- log.debug("getMembersOfVfModule - Node templates are {}", collect);
return collect;
}
}
@@ -498,7 +475,6 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
if (nodeTemplates.isEmpty()) {
log.debug("getAllottedResources - allotted resources not exist");
} else {
- log.debug("getAllottedResources - the allotted resources list is {}", nodeTemplates);
}
return nodeTemplates;
@@ -512,7 +488,6 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
log.error("getTypeOfNodeTemplate nodeTemplate is null");
return null;
}
- log.debug("getTypeOfNodeTemplate node template type is {}", nodeTemplate.getTypeDefinition().getType());
return nodeTemplate.getTypeDefinition().getType();
}
@@ -583,16 +558,13 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
//Assumed to be unique property for the list
private NodeTemplate getNodeTemplateByCustomizationUuid(List<NodeTemplate> nodeTemplates, String customizationId) {
- log.debug("getNodeTemplateByCustomizationUuid - nodeTemplates {}, customizationId {}", nodeTemplates, customizationId);
Optional<NodeTemplate> findFirst = nodeTemplates.stream().filter(x -> (x.getMetaData() != null && customizationId.equals(x.getMetaData().getValue(PROPERTY_NAME_CUSTOMIZATIONUUID)))).findFirst();
return findFirst.isPresent() ? findFirst.get() : null;
}
private Object processProperties(String[] split, LinkedHashMap<String, Property> properties) {
- log.debug("processProperties - the leafValuePath is {} , the properties are {}", Arrays.toString(split), properties.toString());
Optional<Entry<String, Property>> findFirst = properties.entrySet().stream().filter(x -> x.getKey().equals(split[0])).findFirst();
if (findFirst.isPresent()) {
- log.debug("processProperties - find first item is {}", findFirst.get());
Property property = findFirst.get().getValue();
Object current = property.getValue();
return iterateProcessPath(1, current, split);