ariatosca-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tliron <...@git.apache.org>
Subject [GitHub] incubator-ariatosca pull request #143: ARIA-254 Create of multiple nodes per...
Date Tue, 06 Jun 2017 19:22:14 GMT
Github user tliron commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/143#discussion_r120455950
  
    --- Diff: aria/modeling/service_template.py ---
    @@ -613,6 +597,56 @@ def dump(self):
                 utils.dump_dict_values(self.capability_templates, 'Capability templates')
                 utils.dump_list_values(self.requirement_templates, 'Requirement templates')
     
    +    @property
    +    def next_index(self):
    +        """
    +        Next available node index.
    +
    +        :returns: node index
    +        :rtype: int
    +        """
    +
    +        max_index = 0
    +        if self.nodes:
    +            max_index = max(int(n.name.rsplit('_', 1)[-1]) for n in self.nodes)
    +        return max_index + 1
    +
    +    @property
    +    def next_name(self):
    +        """
    +        Next available node name.
    +
    +        :returns: node name
    +        :rtype: basestring
    +        """
    +
    +        return '{name}_{index}'.format(name=self.name, index=self.next_index)
    +
    +    @property
    +    def default_instances(self):
    +        # TODO: currently finds the first matching policy; but we should emit a validation
error
    +        # if more than one policy applies to the same node
    +        for policy_template in self.service_template.policy_templates.itervalues():
    +            if policy_template.type.role == 'scaling':
    +                if policy_template.is_for_node_template(self.name):
    +                    default_instances = policy_template.properties.get('default_instances')
    +                    if (default_instances is not None) \
    +                        and (default_instances.type_name == 'integer'):
    --- End diff --
    
    We cannot expect anybody be to using the ARIA profile as is -- all we are relying here
is that there is an attribute with that name. I am adding that extra validation of type to
make sure that we don't cause breakage by somebody messing with the parameters. Note that
we also do this validation in setting "default" attributes, like `tosca_name` and `tosca_id`.


---
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