PR fixes
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/c0537bf1 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/c0537bf1 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/c0537bf1 Branch: refs/heads/ARIA-254-multiple-nodes-per-template Commit: c0537bf13de0dff4a049c295d84af534f634beee Parents: 9d99fed Author: Tal Liron <[email protected]> Authored: Wed Jul 5 16:01:40 2017 -0500 Committer: Tal Liron <[email protected]> Committed: Wed Jul 5 16:01:47 2017 -0500 ---------------------------------------------------------------------- aria/modeling/service_template.py | 52 +++++++++++++++++----------------- 1 file changed, 26 insertions(+), 26 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/c0537bf1/aria/modeling/service_template.py ---------------------------------------------------------------------- diff --git a/aria/modeling/service_template.py b/aria/modeling/service_template.py index df2f1a0..4b60ba2 100644 --- a/aria/modeling/service_template.py +++ b/aria/modeling/service_template.py @@ -622,7 +622,7 @@ class NodeTemplateBase(TemplateModelMixin): def instantiate(self, container): from . import models - node = models.Node(name=self.next_name, + node = models.Node(name=self._next_name, type=self.type, description=deepcopy_with_locators(self.description), state=models.Node.INITIAL, @@ -674,31 +674,6 @@ class NodeTemplateBase(TemplateModelMixin): 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 scaling(self): scaling = {} @@ -764,6 +739,31 @@ class NodeTemplateBase(TemplateModelMixin): return False return True + @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) + class GroupTemplateBase(TemplateModelMixin): """
