ariatosca-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mxm...@apache.org
Subject incubator-ariatosca git commit: ARIA-165 Make node name suffix UUIDs become more readable
Date Tue, 09 May 2017 08:45:02 GMT
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/master b11fbc946 -> 1febf80de


ARIA-165 Make node name suffix UUIDs become more readable


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/1febf80d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/1febf80d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/1febf80d

Branch: refs/heads/master
Commit: 1febf80dee57b837d2ed937bcdaa080bdc3bd822
Parents: b11fbc9
Author: max-orlov <maxim@gigaspaces.com>
Authored: Mon May 8 15:25:37 2017 +0300
Committer: max-orlov <maxim@gigaspaces.com>
Committed: Tue May 9 11:24:07 2017 +0300

----------------------------------------------------------------------
 aria/modeling/service_template.py | 8 ++++++--
 aria/parser/modeling/context.py   | 5 -----
 2 files changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1febf80d/aria/modeling/service_template.py
----------------------------------------------------------------------
diff --git a/aria/modeling/service_template.py b/aria/modeling/service_template.py
index 7fab4fc..f721b64 100644
--- a/aria/modeling/service_template.py
+++ b/aria/modeling/service_template.py
@@ -549,9 +549,13 @@ class NodeTemplateBase(TemplateModelMixin):
             ('requirement_templates', formatting.as_raw_list(self.requirement_templates))))
 
     def instantiate(self, container):
-        context = ConsumptionContext.get_thread_local()
         from . import models
-        name = context.modeling.generate_node_id(self.name)
+        if self.nodes:
+            highest_name_suffix = max(int(n.name.rsplit('_', 1)[-1]) for n in self.nodes)
+            suffix = highest_name_suffix + 1
+        else:
+            suffix = 1
+        name = '{name}_{index}'.format(name=self.name, index=suffix)
         node = models.Node(name=name,
                            type=self.type,
                            description=deepcopy_with_locators(self.description),

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/1febf80d/aria/parser/modeling/context.py
----------------------------------------------------------------------
diff --git a/aria/parser/modeling/context.py b/aria/parser/modeling/context.py
index dff5991..4a53641 100644
--- a/aria/parser/modeling/context.py
+++ b/aria/parser/modeling/context.py
@@ -67,11 +67,6 @@ class ModelingContext(object):
         if self.instance is not None:
             model_storage.service.put(self.instance)
 
-    def generate_node_id(self, template_name):
-        return self.node_id_format.format(
-            template=template_name,
-            id=self.generate_id())
-
     def generate_id(self):
         if self.id_type == IdType.LOCAL_SERIAL:
             return self._serial_id_counter.next()


Mime
View raw message