Allow to use external nodegenerator

  * Switch to downstream reclass
  * Add reference replacement in generator:
   COLON_SYMBOL_FOR_FUTURE_REFERENCE => ':'

https://mirantis.jira.com/browse/PROD-30702

Change-Id: I342e2e3abc770f3a150668df06cc06fe0f3e2687
diff --git a/.kitchen.yml b/.kitchen.yml
index 1c7b65f..24be116 100644
--- a/.kitchen.yml
+++ b/.kitchen.yml
@@ -24,7 +24,8 @@
         "*":
           - reclass
   init_environment: |
-        sudo yum install -y python-netaddr || sudo apt-get install -y python-netaddr || true
+        sudo apt-get install -y python-netaddr python-pip || true
+        sudo pip install git+http://gerrit.mcp.mirantis.com/packaging/sources/reclass@mcp/xenial/extra
 
 verifier:
   name: inspec
diff --git a/README.rst b/README.rst
index c871b99..c7959f5 100644
--- a/README.rst
+++ b/README.rst
@@ -204,7 +204,10 @@
 
 Multiple nodes definitions (using generator) with IP address comprehension.
 Ranges are named and formatting symbol of the same name is replaced by IP
-address from the corresponding range:
+address from the corresponding range.
+Some extra references supported, as:
+  COLON_SYMBOL_FOR_FUTURE_REFERENCE = ':'
+Which will be replaced during reclass process
 
 .. code-block:: yaml
 
@@ -236,6 +239,9 @@
                 tenant_address:
                   start: 101
                   value: 192.168.2.<<tenant_address>>
+                somevalue:
+                  start: 101
+                  value: 192.168.2.<<tenant_address>>COLON_SYMBOL_FOR_FUTURE_REFERENCEtestme
 
 Read more
 =========
diff --git a/reclass/files/node.yml b/reclass/files/node.yml
index f10630e..b2f0fba 100644
--- a/reclass/files/node.yml
+++ b/reclass/files/node.yml
@@ -6,22 +6,23 @@
   {%- if node.params is defined or extra_params|length > 0 %}
   _param:
     {%- for param_name, param_value in node.params.iteritems() %}
-    {%- if param_value is not string %}
-    {{ param_name }}: {{ param_value }}
-    {%- else %}
-    {{ param_name }}: {{ param_value|replace("u'", "'") }}
-    {%- endif %}
+      {%- if param_value is not string %}
+      {{ param_name }}: {{ param_value }}
+      {%- else %}
+      {{ param_name }}: {{ param_value|replace("u'", "'") }}
+      {%- endif %}
     {%- endfor %}
     {%- for param_name, param_value in extra_params.iteritems() %}
-    {%- if param_value.value is not string %}
-    {{ param_name }}: {{ param_value.value }}
-    {%- else %}
-    {%- if param_value.interpolate %}
-    {{ param_name }}: {% raw %}'${_param:{% endraw %}{{ param_value.value|replace("u'", "'")|replace("'", "") }}}'
-    {%- else %}
-    {{ param_name }}: {{ param_value.value|replace("u'", "'") }}
-    {%- endif %}
-    {%- endif %}
+      {%- if param_value.value is not string %}
+      {{ param_name }}: {{ param_value.value }}
+      {%- else %}
+        {%- if param_value.interpolate %}
+      {%- set param = param_value.value|replace("u'", "'")|replace("'", "")|replace('COLON_SYMBOL_FOR_FUTURE_REFERENCE', ':') %}
+      {{ param_name }}: {% raw %}'${_param:{% endraw %}{{ param }}}'
+        {%- else %}
+      {{ param_name }}: {{ param_value.value|replace("u'", "'") }}
+        {%- endif %}
+      {%- endif %}
     {%- endfor %}
   {%- endif %}
   {{ node.get('kernel', 'linux') }}:
diff --git a/reclass/files/reclass-config.yml b/reclass/files/reclass-config.yml
index c9a306c..7f72b08 100644
--- a/reclass/files/reclass-config.yml
+++ b/reclass/files/reclass-config.yml
@@ -19,7 +19,7 @@
 propagate_pillar_data_to_reclass: {{ storage.propagate_pillar_data_to_reclass }}
 {%- endif %}
 # Below option are not available in original reclass,
-# use fork with extensions from https://github.com/salt-formulas/reclass
+# use fork with extensions from https://gerrit.mcp.mirantis.com/salt-formulas/reclass
 {%- if storage.ignore_class_notfound == True %}
 ignore_class_notfound: {{ storage.ignore_class_notfound }}
 {%- endif %}
diff --git a/reclass/storage/node.sls b/reclass/storage/node.sls
index d34ff9c..307b64e 100644
--- a/reclass/storage/node.sls
+++ b/reclass/storage/node.sls
@@ -12,8 +12,22 @@
     - file_mode: 644
     - makedirs: True
     - clean: True
+    {%- if storage.get('use_standalone_nodegenerator', False) | to_bool %}
+    - require_in:
+      - call_nodegenerator
+    {%- endif %}
   {%- endif %}
 
+{%- if storage.get('use_standalone_nodegenerator', False) | to_bool %}
+  {%- if storage.get('node', {}) %}
+call_nodegenerator:
+  cmd.run:
+  - name: 'nodegenerator -b "{{ storage.base_dir }}/classes/" -o "{{ storage.base_dir }}/nodes/_generated/" {{ salt['pillar.get']('_param:cluster_name') }}'
+  {%- endif %}
+
+{%- else %}
+
+{# START: OLD generator section #}
   {%- set storage_by_name = {} %}
 
   {%- for node_name, node in storage.get('node', {}).iteritems() %}
@@ -89,5 +103,6 @@
     {%- endif %}
 
   {%- endfor %}
-
+{# END: OLD generator section #}
+{%- endif %}
 {%- endif %}
diff --git a/tests/pillar/storage_git.sls b/tests/pillar/storage_git.sls
index 7dd9aba..c8dd687 100644
--- a/tests/pillar/storage_git.sls
+++ b/tests/pillar/storage_git.sls
@@ -4,5 +4,5 @@
     base_dir: /srv/reclass
     source:
       engine: git
-      repo: git+https://github.com/salt-formulas/reclass
-      branch: master
+      repo: git+http://gerrit.mcp.mirantis.com/packaging/sources/reclass
+      branch: mcp/xenial/extra