From f567dd66c9517acda42559e2c471d40e3401531e Mon Sep 17 00:00:00 2001 From: shangxdy Date: Tue, 23 Aug 2016 10:36:25 +0800 Subject: Replace the policie types with parent type when judging policy node template in HotResource In class of HotResource, because the policy node template has not interface property, so it is excepted when get all operation from node, but the policy types are enumerated, they are can expressed with parent type. JIRA:PARSER-97 Change-Id: I6393dcaefc774af3aa627ffa287b75083a173f3f Signed-off-by: shangxdy --- .../translator/hot/syntax/hot_resource.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'tosca2heat') diff --git a/tosca2heat/heat-translator/translator/hot/syntax/hot_resource.py b/tosca2heat/heat-translator/translator/hot/syntax/hot_resource.py index 261d8ee..8994c63 100644 --- a/tosca2heat/heat-translator/translator/hot/syntax/hot_resource.py +++ b/tosca2heat/heat-translator/translator/hot/syntax/hot_resource.py @@ -357,9 +357,10 @@ class HotResource(object): node_type = node.type_definition if isinstance(node_type, str) or \ - node_type.type == "tosca.policies.Placement" or \ - node_type.type == "tosca.policies.Colocate" or \ - node_type.type == "tosca.policies.Antilocate": + node_type.is_derived_from("tosca.policies.Root"): + # node_type.type == "tosca.policies.Placement" or \ + # node_type.type == "tosca.policies.Placement.Colocate" or \ + # node_type.type == "tosca.policies.Placement.Antilocate": return operations while True: @@ -377,9 +378,10 @@ class HotResource(object): def _get_interface_operations_from_type(node_type, node, lifecycle_name): operations = {} if isinstance(node_type, str) or \ - node_type.type == "tosca.policies.Placement" or \ - node_type.type == "tosca.policies.Colocate" or \ - node_type.type == "tosca.policies.Antilocate": + node_type.is_derived_from("tosca.policies.Root"): + # node_type.type == "tosca.policies.Placement" or \ + # node_type.type == "tosca.policies.Placement.Colocate" or \ + # node_type.type == "tosca.policies.Placement.Antilocate": return operations if node_type.interfaces and lifecycle_name in node_type.interfaces: for name, elems in node_type.interfaces[lifecycle_name].items(): @@ -396,8 +398,8 @@ class HotResource(object): def get_base_type(node_type): if node_type.parent_type is not None: if node_type.parent_type.type.endswith('.Root') or \ - node_type.type == "tosca.policies.Colocate" or \ - node_type.type == "tosca.policies.Antilocate": + node_type.type == "tosca.policies.Placement.Colocate" or \ + node_type.type == "tosca.policies.Placement.Antilocate": return node_type else: return HotResource.get_base_type(node_type.parent_type) -- cgit 1.2.3-korg