aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Aharoni <pa0916@att.com>2017-03-29 18:56:08 +0300
committerPavel Aharoni <pa0916@att.com>2017-03-29 18:56:43 +0300
commit905dce200dd3cf37bfc3b444a0d70b57232a30dc (patch)
tree3e4aad46e17d6daec871568fea3459a45c0034ec
parent611df70a00b75c1107b858e6904dc402d3fdff17 (diff)
[SDC-7] jython tosca parser 0.4.0-SNAPSHOT
Change-Id: I838b10721cfdf5b714e14f56fdae4c3c6d51445b Signed-off-by: Pavel Aharoni <pa0916@att.com>
-rw-r--r--jython-tosca-parser/pom.xml2
-rw-r--r--jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/api/NodeTemplate.java17
-rw-r--r--jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/api/TopologyTemplate.java6
-rw-r--r--jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/jython/JyNodeTemplate.java3
-rw-r--r--jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/jython/JyTopologyTemplate.java2
-rw-r--r--jython-tosca-parser/src/main/resources/Lib/site-packages/tosca_parser-0.7.0-py2.7.egg/toscaparser/nodetemplate.py13
-rw-r--r--jython-tosca-parser/src/main/resources/Lib/site-packages/tosca_parser-0.7.0-py2.7.egg/toscaparser/prereq/csar.py7
-rw-r--r--jython-tosca-parser/src/main/resources/Lib/site-packages/tosca_parser-0.7.0-py2.7.egg/toscaparser/topology_template.py12
-rw-r--r--pom.xml1
-rw-r--r--sdc-tosca-parser/pom.xml2
10 files changed, 58 insertions, 7 deletions
diff --git a/jython-tosca-parser/pom.xml b/jython-tosca-parser/pom.xml
index 2b8f024..2058d3a 100644
--- a/jython-tosca-parser/pom.xml
+++ b/jython-tosca-parser/pom.xml
@@ -9,7 +9,7 @@
</parent>
<artifactId>jython-tosca-parser</artifactId>
- <version>0.3.1-SNAPSHOT</version>
+ <version>${jython.tosca.parser.version}</version>
<dependencies>
<dependency>
diff --git a/jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/api/NodeTemplate.java b/jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/api/NodeTemplate.java
index 047a421..d8cac9e 100644
--- a/jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/api/NodeTemplate.java
+++ b/jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/api/NodeTemplate.java
@@ -1,10 +1,27 @@
package org.openecomp.sdc.toscaparser.api;
+import java.util.Map;
+
import org.openecomp.sdc.toscaparser.jython.JyNodeTemplate;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
public class NodeTemplate extends EntityTemplate {
+ private final JyNodeTemplate jyNodeTemplate;
+
public NodeTemplate(JyNodeTemplate jyNodeTemplate) {
super(jyNodeTemplate);
+ this.jyNodeTemplate = jyNodeTemplate;
+ }
+
+ public Map<String, String> getMetadata() {
+ return jyNodeTemplate.getJyMetadata();
}
+
+ @Override
+ protected ToStringHelper toStringHelper() {
+ return super.toStringHelper()
+ .add("metadata", getMetadata());
+ }
}
diff --git a/jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/api/TopologyTemplate.java b/jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/api/TopologyTemplate.java
index 1769455..5c9db48 100644
--- a/jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/api/TopologyTemplate.java
+++ b/jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/api/TopologyTemplate.java
@@ -3,6 +3,7 @@ package org.openecomp.sdc.toscaparser.api;
import static com.google.common.collect.ImmutableList.toImmutableList;
import java.util.List;
+import java.util.Map;
import java.util.Objects;
import org.openecomp.sdc.toscaparser.api.parameters.Input;
@@ -48,6 +49,10 @@ public class TopologyTemplate {
JySubstitutionMappings jySubstitutionMappings = jyTopologyTemplate.getJySubstitutionMappings();
return jySubstitutionMappings != null ? new SubstitutionMappings(jySubstitutionMappings) : null;
}
+
+ public Map<String, String> getMetadata() {
+ return jyTopologyTemplate.getJyMetadata();
+ }
@Override
public String toString() {
@@ -57,6 +62,7 @@ public class TopologyTemplate {
.add("nodeTemplates", getNodeTemplates())
.add("groups", getGroups())
.add("substitutionMappings", getSubstitutionMappings())
+ .add("metadata", getMetadata())
.toString();
}
}
diff --git a/jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/jython/JyNodeTemplate.java b/jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/jython/JyNodeTemplate.java
index b04a337..a837137 100644
--- a/jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/jython/JyNodeTemplate.java
+++ b/jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/jython/JyNodeTemplate.java
@@ -1,5 +1,8 @@
package org.openecomp.sdc.toscaparser.jython;
+import java.util.Map;
+
public interface JyNodeTemplate extends JyEntityTemplate {
+ Map<String, String> getJyMetadata();
}
diff --git a/jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/jython/JyTopologyTemplate.java b/jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/jython/JyTopologyTemplate.java
index c6fe053..9cdc38b 100644
--- a/jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/jython/JyTopologyTemplate.java
+++ b/jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/jython/JyTopologyTemplate.java
@@ -1,6 +1,7 @@
package org.openecomp.sdc.toscaparser.jython;
import java.util.List;
+import java.util.Map;
import org.openecomp.sdc.toscaparser.jython.parameters.JyInput;
@@ -11,4 +12,5 @@ public interface JyTopologyTemplate {
List<JyInput> getJyInputs();
List<JyGroup> getJyGroups();
JySubstitutionMappings getJySubstitutionMappings();
+ Map<String, String> getJyMetadata();
}
diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/tosca_parser-0.7.0-py2.7.egg/toscaparser/nodetemplate.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/tosca_parser-0.7.0-py2.7.egg/toscaparser/nodetemplate.py
index 6f37dfb..ee7622c 100644
--- a/jython-tosca-parser/src/main/resources/Lib/site-packages/tosca_parser-0.7.0-py2.7.egg/toscaparser/nodetemplate.py
+++ b/jython-tosca-parser/src/main/resources/Lib/site-packages/tosca_parser-0.7.0-py2.7.egg/toscaparser/nodetemplate.py
@@ -30,6 +30,7 @@ from toscaparser.elements.relationshiptype import RelationshipType
from toscaparser.entity_template import EntityTemplate
from toscaparser.relationship_template import RelationshipTemplate
from toscaparser.utils.gettextutils import _
+from toscaparser.utils import validateutils
from org.openecomp.sdc.toscaparser.jython import JyNodeTemplate
log = logging.getLogger('tosca')
@@ -39,11 +40,12 @@ class NodeTemplate(EntityTemplate, JyNodeTemplate):
'''Node template from a Tosca profile.'''
def __init__(self, name, node_templates, custom_def=None,
available_rel_tpls=None, available_rel_types=None):
- super(NodeTemplate, self).__init__(name, node_templates[name],
+ nodeTemplate = node_templates[name]
+ super(NodeTemplate, self).__init__(name, nodeTemplate,
'node_type',
custom_def)
self.templates = node_templates
- self._validate_fields(node_templates[name])
+ self._validate_fields(nodeTemplate)
self.custom_def = custom_def
self.related = {}
self.relationship_tpl = []
@@ -51,6 +53,13 @@ class NodeTemplate(EntityTemplate, JyNodeTemplate):
self.available_rel_types = available_rel_types
self._relationships = {}
self.sub_mapping_tosca_template = None
+ self.meta_data = None
+ if self.METADATA in nodeTemplate:
+ self.meta_data = nodeTemplate.get(self.METADATA)
+ validateutils.validate_map(self.meta_data)
+
+ def getJyMetadata(self):
+ return self.meta_data
@property
def relationships(self):
diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/tosca_parser-0.7.0-py2.7.egg/toscaparser/prereq/csar.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/tosca_parser-0.7.0-py2.7.egg/toscaparser/prereq/csar.py
index 36f39cc..de98328 100644
--- a/jython-tosca-parser/src/main/resources/Lib/site-packages/tosca_parser-0.7.0-py2.7.egg/toscaparser/prereq/csar.py
+++ b/jython-tosca-parser/src/main/resources/Lib/site-packages/tosca_parser-0.7.0-py2.7.egg/toscaparser/prereq/csar.py
@@ -251,7 +251,12 @@ class CSAR(object):
operation['implementation'])
finally:
if self.temp_dir:
- shutil.rmtree(self.temp_dir)
+ shutil.rmtree(self.temp_dir, False, self._printPath)
+
+
+ def _printPath(self, func, path, exc_info):
+ print('Could not delete: ' + path)
+
def _validate_external_reference(self, tpl_file, resource_file,
raise_exc=True):
diff --git a/jython-tosca-parser/src/main/resources/Lib/site-packages/tosca_parser-0.7.0-py2.7.egg/toscaparser/topology_template.py b/jython-tosca-parser/src/main/resources/Lib/site-packages/tosca_parser-0.7.0-py2.7.egg/toscaparser/topology_template.py
index 23f544a..c56e7b9 100644
--- a/jython-tosca-parser/src/main/resources/Lib/site-packages/tosca_parser-0.7.0-py2.7.egg/toscaparser/topology_template.py
+++ b/jython-tosca-parser/src/main/resources/Lib/site-packages/tosca_parser-0.7.0-py2.7.egg/toscaparser/topology_template.py
@@ -25,16 +25,17 @@ from toscaparser.relationship_template import RelationshipTemplate
from toscaparser.substitution_mappings import SubstitutionMappings
from toscaparser.tpl_relationship_graph import ToscaGraph
from toscaparser.utils.gettextutils import _
+from toscaparser.utils import validateutils
from org.openecomp.sdc.toscaparser.jython import JyTopologyTemplate
# Topology template key names
SECTIONS = (DESCRIPTION, INPUTS, NODE_TEMPLATES,
RELATIONSHIP_TEMPLATES, OUTPUTS, GROUPS,
- SUBSTITUION_MAPPINGS, POLICIES) = \
+ SUBSTITUION_MAPPINGS, POLICIES, METADATA) = \
('description', 'inputs', 'node_templates',
'relationship_templates', 'outputs', 'groups',
- 'substitution_mappings', 'policies')
+ 'substitution_mappings', 'policies', 'metadata')
log = logging.getLogger("tosca.model")
@@ -48,6 +49,10 @@ class TopologyTemplate(JyTopologyTemplate):
self.tpl = template
self.sub_mapped_node_template = sub_mapped_node_template
if self.tpl:
+ self.meta_data = None
+ if METADATA in self.tpl:
+ self.meta_data = self.tpl.get(METADATA)
+ validateutils.validate_map(self.meta_data)
self.custom_defs = custom_defs
self.rel_types = rel_types
self.parsed_params = parsed_params
@@ -78,6 +83,9 @@ class TopologyTemplate(JyTopologyTemplate):
def getJySubstitutionMappings(self):
return self.substitution_mappings
+
+ def getJyMetadata(self):
+ return self.meta_data
def _inputs(self):
inputs = []
diff --git a/pom.xml b/pom.xml
index fe0f9e8..27ee15c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -35,6 +35,7 @@
<logback.version>1.1.2</logback.version>
<junit.version>4.12</junit.version>
<snakeyaml.version>1.14</snakeyaml.version>
+ <jython.tosca.parser.version>0.4.0-SNAPSHOT</jython.tosca.parser.version>
<!-- Repositories -->
<!-- <nexusServerName>mavencentral.it.att.com</nexusServerName> -->
diff --git a/sdc-tosca-parser/pom.xml b/sdc-tosca-parser/pom.xml
index 2c8eff0..59ae0e4 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>jython-tosca-parser</artifactId>
- <version>0.3.1-SNAPSHOT</version>
+ <version>${jython.tosca.parser.version}</version>
</dependency>