Github user tliron commented on a diff in the pull request:
https://github.com/apache/incubator-ariatosca/pull/191#discussion_r137062291
--- Diff: aria/modeling/service_instance.py ---
@@ -228,6 +228,80 @@ def service_template_fk(cls):
:type: :class:`~datetime.datetime`
""")
+ def get_node_by_type(self, type_name):
+ """
+ Finds the first node of a type (or descendent type).
+ """
+ service_template = self.service_template
+
+ if service_template is not None:
+ node_types = service_template.node_types
+ if node_types is not None:
+ for node in self.nodes.itervalues():
+ if node_types.is_descendant(type_name, node.type.name):
+ return node
+
+ return None
+
+ def get_policy_by_type(self, type_name):
+ """
+ Finds the first policy of a type (or descendent type).
+ """
+ service_template = self.service_template
+
+ if service_template is not None:
+ policy_types = service_template.policy_types
+ if policy_types is not None:
+ for policy in self.policies.itervalues():
+ if policy_types.is_descendant(type_name,
policy.type.name):
+ return policy
+
+ return None
+
+ def satisfy_requirements(self):
--- End diff --
The `get_node_by_type` and `get_policy_by_type` are utility functions for
use by the ctx proxy. You can see them being used in
`clearwater/scripts/hosts/configure.sh`. I see them as being very useful for
users.
---