diff options
-rw-r--r-- | jtosca/pom.xml | 2 | ||||
-rw-r--r-- | jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/TopologyTemplate.java | 44 | ||||
-rw-r--r-- | jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/parameters/Input.java | 31 | ||||
-rw-r--r-- | sdc-tosca-parser/pom.xml | 2 | ||||
-rw-r--r-- | sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java | 11 | ||||
-rw-r--r-- | sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-with-allotted.csar | bin | 44991 -> 44976 bytes |
6 files changed, 43 insertions, 47 deletions
diff --git a/jtosca/pom.xml b/jtosca/pom.xml index 847579c..f74988b 100644 --- a/jtosca/pom.xml +++ b/jtosca/pom.xml @@ -9,7 +9,7 @@ </parent> <artifactId>jtosca</artifactId> - <version>0.1.1-SNAPSHOT</version> + <version>0.1.2-SNAPSHOT</version> <dependencies> 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 bf1851c..39536ca 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 @@ -5,11 +5,8 @@ import java.util.HashSet; import java.util.LinkedHashMap; import java.util.Map; -import org.openecomp.sdc.toscaparser.api.SubstitutionMappings; -import org.openecomp.sdc.toscaparser.api.ToscaGraph; import org.openecomp.sdc.toscaparser.api.common.ExceptionCollector; import org.openecomp.sdc.toscaparser.api.elements.InterfacesDef; -import org.openecomp.sdc.toscaparser.api.elements.Metadata; import org.openecomp.sdc.toscaparser.api.elements.NodeType; import org.openecomp.sdc.toscaparser.api.elements.RelationshipType; import org.openecomp.sdc.toscaparser.api.functions.Function; @@ -17,12 +14,9 @@ import org.openecomp.sdc.toscaparser.api.functions.GetAttribute; import org.openecomp.sdc.toscaparser.api.functions.GetInput; import org.openecomp.sdc.toscaparser.api.parameters.Input; import org.openecomp.sdc.toscaparser.api.parameters.Output; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class TopologyTemplate { - private static Logger log = LoggerFactory.getLogger(TopologyTemplate.class.getName()); private static final String DESCRIPTION = "description"; private static final String INPUTS = "inputs"; private static final String NODE_TEMPLATES = "node_templates"; @@ -39,7 +33,7 @@ public class TopologyTemplate { }; private LinkedHashMap<String,Object> tpl; - Metadata metaData; + LinkedHashMap<String,Object> metaData; private ArrayList<Input> inputs; private ArrayList<Output> outputs; private ArrayList<RelationshipTemplate> relationshipTemplates; @@ -86,10 +80,11 @@ public class TopologyTemplate { @SuppressWarnings("unchecked") private ArrayList<Input> _inputs() { + //DumpUtils.dumpYaml(customDefs,0); ArrayList<Input> alInputs = new ArrayList<>(); for(String name: _tplInputs().keySet()) { Object attrs = _tplInputs().get(name); - Input input = new Input(name,(LinkedHashMap<String,Object>)attrs); + Input input = new Input(name,(LinkedHashMap<String,Object>)attrs,customDefs);//ATT-CDT if(parsedParams != null && parsedParams.get(name) != null) { input.validate(parsedParams.get(name)); } @@ -101,7 +96,7 @@ public class TopologyTemplate { } if((parsedParams != null && parsedParams.get(input.getName()) == null || parsedParams == null) && input.isRequired() && input.getDefault() == null) { - log.error("Log warning: TopologyTemplate - _inputs - The required parameter {} is not provided", input.getName()); + System.out.format("Log warning: The required parameter \"%s\" is not provided\n",input.getName()); } alInputs.add(input); } @@ -109,12 +104,12 @@ public class TopologyTemplate { } - private Metadata _metaData() { + private LinkedHashMap<String,Object> _metaData() { if(tpl.get(METADATA) != null) { - return (Metadata)tpl.get(METADATA); + return (LinkedHashMap<String,Object>)tpl.get(METADATA); } else { - return new Metadata(new LinkedHashMap<>()); + return new LinkedHashMap<String,Object>(); } } @@ -178,7 +173,7 @@ public class TopologyTemplate { nodeTemplates, inputs, outputs, - groups, + groups, //ATT addition subMappedNodeTemplate, customDefs); } @@ -511,7 +506,7 @@ public class TopologyTemplate { return tpl; } - public Metadata getMetadata() { + public LinkedHashMap<String,Object> getMetadata() { return metaData; } @@ -546,27 +541,6 @@ public class TopologyTemplate { public LinkedHashMap<String,Object> getParsedParams() { return parsedParams; } - - @Override - public String toString() { - return "TopologyTemplate{" + - "tpl=" + tpl + - ", metaData=" + metaData + - ", inputs=" + inputs + - ", outputs=" + outputs + - ", relationshipTemplates=" + relationshipTemplates + - ", nodeTemplates=" + nodeTemplates + - ", customDefs=" + customDefs + - ", relTypes=" + relTypes + - ", subMappedNodeTemplate=" + subMappedNodeTemplate + - ", groups=" + groups + - ", policies=" + policies + - ", parsedParams=" + parsedParams + - ", description='" + description + '\'' + - ", graph=" + graph + - ", substitutionMappings=" + substitutionMappings + - '}'; - } } /*python 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 bda15dc..2eb64e8 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 @@ -25,11 +25,12 @@ public class Input { private String name; private Schema schema; + private LinkedHashMap<String,Object> customDefs;//ATT-CDT - - public Input(String _name,LinkedHashMap<String,Object> _schemaDict) { + public Input(String _name,LinkedHashMap<String,Object> _schemaDict,LinkedHashMap<String,Object> _customDefs) {//ATT-CDT name = _name; schema = new Schema(_name,_schemaDict); + customDefs = _customDefs;//ATT-CDT } public String getName() { @@ -89,6 +90,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)); @@ -97,14 +105,19 @@ public class Input { private void _validateValue(Object value) { Object datatype = null; - if (EntityType.TOSCA_DEF != null && EntityType.TOSCA_DEF.size() > 0) { - if(EntityType.TOSCA_DEF.get(getType()) != null) { - datatype = EntityType.TOSCA_DEF.get(getType()); - } - else if(EntityType.TOSCA_DEF.get(EntityType.DATATYPE_NETWORK_PREFIX + getType()) != null) { - datatype = EntityType.TOSCA_DEF.get(EntityType.DATATYPE_NETWORK_PREFIX + getType()); - } + if(EntityType.TOSCA_DEF.get(getType()) != null) { + datatype = EntityType.TOSCA_DEF.get(getType()); + } + else if(EntityType.TOSCA_DEF.get(EntityType.DATATYPE_NETWORK_PREFIX + getType()) != null) { + datatype = EntityType.TOSCA_DEF.get(EntityType.DATATYPE_NETWORK_PREFIX + getType()); + } + //ATT-CDT + else if(customDefs.get(getType()) != null) { + datatype = customDefs.get(getType()); + DataEntity.validateDatatype(getType(),value,(LinkedHashMap<String,Object>)datatype,customDefs,null); + return; } + //ATT-CDT DataEntity.validateDatatype(getType(),value,null,(LinkedHashMap<String,Object>)datatype,null); } } diff --git a/sdc-tosca-parser/pom.xml b/sdc-tosca-parser/pom.xml index f05622f..6b370ce 100644 --- a/sdc-tosca-parser/pom.xml +++ b/sdc-tosca-parser/pom.xml @@ -71,7 +71,7 @@ <dependency>
<groupId>org.openecomp.sdc.sdc-distribution-client</groupId>
<artifactId>jtosca</artifactId>
- <version>0.1.1-SNAPSHOT</version>
+ <version>0.1.2-SNAPSHOT</version>
</dependency>
diff --git a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java index 7c30616..8c748f6 100644 --- a/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java +++ b/sdc-tosca-parser/src/test/java/org/openecomp/sdc/impl/ToscaParserNodeTemplateTest.java @@ -45,10 +45,19 @@ public class ToscaParserNodeTemplateTest extends BasicTest { public void testNodeTemplateNestedProperty() throws SdcToscaParserException { List<NodeTemplate> serviceVlList = ToscaParserTestSuite.fdntCsarHelper.getServiceVlList(); NodeTemplate nodeTemplate = serviceVlList.get(0); - System.out.println("node template " + nodeTemplate.toString()); + //System.out.println("node template " + nodeTemplate.toString()); assertEquals("24", ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "network_assignments#ipv4_subnet_default_assignment#cidr_mask")); assertEquals("7a6520b-9982354-ee82992c-105720", ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "network_flows#vpn_binding")); } + + @Test + public void testNodeTemplateNestedPropertyFromInput() throws SdcToscaParserException { + List<NodeTemplate> serviceVfList = ToscaParserTestSuite.fdntCsarHelper.getServiceVfList(); + NodeTemplate nodeTemplate = serviceVfList.get(0); + //System.out.println("node template " + nodeTemplate.toString()); + assertEquals("true", ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming#ecomp_generated_naming")); + assertEquals("FDNT_instance_VF_2", ToscaParserTestSuite.fdntCsarHelper.getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming#naming_policy")); + } @Test public void testNodeTemplateNestedPropertyNotExists() throws SdcToscaParserException { diff --git a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-with-allotted.csar b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-with-allotted.csar Binary files differindex 41ee2c7..a343e84 100644 --- a/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-with-allotted.csar +++ b/sdc-tosca-parser/src/test/resources/csars/service-ServiceFdnt-with-allotted.csar |