diff options
author | julien zhang <zhang.jun3g@zte.com.cn> | 2016-07-04 10:03:58 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@172.30.200.206> | 2016-07-04 10:03:58 +0000 |
commit | 5eb53e8aa498bf080ff52cbddf3070be83292c3c (patch) | |
tree | 2ce2f039e509a296874c536db3cc2c2169a8fabf /tosca2heat/tosca-parser/toscaparser/elements | |
parent | d3ec79a8d3146b88892cf6d7fdf843ccd7e3a0b0 (diff) | |
parent | 32a4ee56e1dfbe986aab75bc7924057790c189cf (diff) |
Merge "The artifacttype's parent_type definition is error"
Diffstat (limited to 'tosca2heat/tosca-parser/toscaparser/elements')
-rw-r--r-- | tosca2heat/tosca-parser/toscaparser/elements/artifacttype.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/tosca2heat/tosca-parser/toscaparser/elements/artifacttype.py b/tosca2heat/tosca-parser/toscaparser/elements/artifacttype.py index 3bfd7d0..887e99a 100644 --- a/tosca2heat/tosca-parser/toscaparser/elements/artifacttype.py +++ b/tosca2heat/tosca-parser/toscaparser/elements/artifacttype.py @@ -20,6 +20,7 @@ class ArtifactTypeDef(StatefulEntityType): super(ArtifactTypeDef, self).__init__(atype, self.ARTIFACT_PREFIX, custom_def) self.type = atype + self.custom_def = custom_def self.properties = None if self.PROPERTIES in self.defs: self.properties = self.defs[self.PROPERTIES] @@ -27,17 +28,24 @@ class ArtifactTypeDef(StatefulEntityType): def _get_parent_artifacts(self): artifacts = {} - parent_artif = self.parent_type + parent_artif = self.parent_type.type if self.parent_type else None if parent_artif: while parent_artif != 'tosca.artifacts.Root': + # only support normative artifact, shall be modified future artifacts[parent_artif] = self.TOSCA_DEF[parent_artif] parent_artif = artifacts[parent_artif]['derived_from'] return artifacts @property def parent_type(self): - '''Return an artifact this artifact is derived from.''' - return self.derived_from(self.defs) + '''Return a artifact entity from which this entity is derived.''' + if not hasattr(self, 'defs'): + return None + partifact_entity = self.derived_from(self.defs) + if partifact_entity: + return ArtifactTypeDef(partifact_entity, self.custom_def) + else: + return None def get_artifact(self, name): '''Return the definition of an artifact field by name.''' |