Github user AviaE commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/189#discussion_r132123290
  
    --- Diff: aria/modeling/service_template.py ---
    @@ -530,6 +530,43 @@ def _next_name(self):
     
             return '{name}_{index}'.format(name=self.name, 
index=self._next_index)
     
    +    @property
    +    def scaling(self):
    +        scaling = {}
    +
    +        def extract_property(properties, name):
    +            if name in scaling:
    +                return
    +            prop = properties.get(name)
    +            if (prop is not None) and (prop.type_name == 'integer') and 
(prop.value is not None):
    +                scaling[name] = prop.value
    +
    +        def extract_properties(properties):
    +            extract_property(properties, 'min_instances')
    +            extract_property(properties, 'max_instances')
    +            extract_property(properties, 'default_instances')
    +
    +        def default_property(name, value):
    +            if name not in scaling:
    +                scaling[name] = value
    +
    +        # From our scaling capabilities
    +        for capability_template in self.capability_templates.itervalues():
    +            if capability_template.type.role == 'scaling':
    +                extract_properties(capability_template.properties)
    +
    +        # From service scaling policies
    +        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):
    +                    extract_properties(policy_template.properties)
    +
    +        # Defaults
    +        default_property('min_instances', 0)
    --- End diff --
    
    should be `setdefault`


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to