ariatosca-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ran-z <...@git.apache.org>
Subject [GitHub] incubator-ariatosca pull request #191: ARIA-321 Provide Clearwater IMS examp...
Date Sun, 03 Sep 2017 13:00:12 GMT
Github user ran-z commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/191#discussion_r136716094
  
    --- 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):
    +        satisfied = True
    +        for node in self.nodes.itervalues():
    +            if not node.satisfy_requirements():
    +                satisfied = False
    +        return satisfied
    +
    +    def validate_capabilities(self):
    +        satisfied = True
    +        for node in self.nodes.itervalues():
    +            if not node.validate_capabilities():
    +                satisfied = False
    +        return satisfied
    +
    +    def find_hosts(self):
    +        for node in self.nodes.itervalues():
    +            node.find_host()
    +
    +    def configure_operations(self):
    +        for node in self.nodes.itervalues():
    +            node.configure_operations()
    +        for group in self.groups.itervalues():
    +            group.configure_operations()
    +        for operation in self.workflows.itervalues():
    +            operation.configure()
    +
    +    def is_node_a_target(self, target_node):
    +        for node in self.nodes.itervalues():
    +            if self._is_node_a_target(node, target_node):
    +                return True
    +        return False
    +
    +    def _is_node_a_target(self, source_node, target_node):
    --- End diff --
    
    Pretty confused by this.
    1) Who's using this?
    2) Why not check the node's `incoming_relationships`?
    3) Why is the private helper function recursive? The main public function already goes
over all nodes and checks each one for a source node.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message