Split MACRO_GENERATE_COOKIECUTTER_MODELS on two macros

Create two separated macros to more flexible usage:
1. MACRO_GENERATE_COOKIECUTTER_MODEL
2. MACRO_GENERATE_AND_ENABLE_ENVIRONMENT_MODEL

Change-Id: I95573ac6637a3f96bbd1a8b7da63ff145afb4b81
diff --git a/tcp_tests/templates/shared-salt.yaml b/tcp_tests/templates/shared-salt.yaml
index 78ecf85..9fcbb83 100644
--- a/tcp_tests/templates/shared-salt.yaml
+++ b/tcp_tests/templates/shared-salt.yaml
@@ -165,29 +165,8 @@
 {%- endmacro %}
 
 
-{%- macro MACRO_GENERATE_COOKIECUTTER_MODELS(IS_CONTRAIL_LAB=false) %}
-{############################################################}
-- description: "[EXPERIMENTAL] Upload 'environment' to {{ HOSTNAME_CFG01 }}"
-  upload:
-    local_path: {{ config.salt_deploy.environment_template_dir }}
-    remote_path: /tmp/environment/
-  node_name: {{ HOSTNAME_CFG01 }}
-  skip_fail: false
-
-- description: "[EXPERIMENTAL] Upload cookiecutter-templates context to {{ HOSTNAME_CFG01 }}"
-  upload:
-    local_path:  {{ config.salt_deploy.templates_dir }}{{ LAB_CONFIG_NAME }}/
-    local_filename: salt-context-cicd_oss.yaml
-    remote_path: /tmp/environment/
-  node_name: {{ HOSTNAME_CFG01 }}
-
-- description: "[EXPERIMENTAL] Upload environment inventory to {{ HOSTNAME_CFG01 }}"
-  upload:
-    local_path:  {{ config.salt_deploy.templates_dir }}{{ LAB_CONFIG_NAME }}/
-    local_filename: salt-context-environment.yaml
-    remote_path: /tmp/environment/
-  node_name: {{ HOSTNAME_CFG01 }}
-
+{%- macro MACRO_GENERATE_COOKIECUTTER_MODEL(IS_CONTRAIL_LAB=false) %}
+{###################################################################}
 - description: Create cluster model from cookiecutter templates
   cmd: |
     set -e;
@@ -238,54 +217,12 @@
     classes:
     - system.openssh.server.team.all
     - cluster.{{ LAB_CONFIG_NAME }}.infra.config
-    - environment.{{ ENVIRONMENT_MODEL_INVENTORY_NAME }}.reclass_datasource_local
-    - environment.{{ ENVIRONMENT_MODEL_INVENTORY_NAME }}
     EOF
 
   node_name: {{ HOSTNAME_CFG01 }}
   retry: {count: 1, delay: 1}
   skip_fail: false
 
-- description: "[EXPERIMENTAL] Remove linux.network.interface object from the cluster/system models and use fixed 'environment' model instead"
-  cmd: |
-    set -e;
-    apt-get -y install python-virtualenv python-pip build-essential python-dev libssl-dev;
-    pip install git+https://github.com/dis-xcom/reclass-tools;
-    reclass-tools del-key parameters.linux.network.interface /srv/salt/reclass/classes/cluster/;
-    reclass-tools del-key parameters.linux.network.interface /srv/salt/reclass/classes/system/;
-    reclass-tools del-key parameters.linux.network.interface /usr/share/salt-formulas/reclass/;
-
-    #if ! reclass-tools get-key 'classes' /srv/salt/reclass/nodes/{{ HOSTNAME_CFG01 }}.yml | grep -q "environment.{{ ENVIRONMENT_MODEL_INVENTORY_NAME }}$"; then
-    #  reclass-tools add-key 'classes' 'environment.{{ ENVIRONMENT_MODEL_INVENTORY_NAME }}' /srv/salt/reclass/nodes/{{ HOSTNAME_CFG01 }}.yml --merge ;
-    #fi;
-
-  node_name: {{ HOSTNAME_CFG01 }}
-  retry: {count: 1, delay: 5}
-  skip_fail: false
-
-- description: "Workaround for PROD-14756: all roles must use service.keepalived.cluster.single with the default 'VIP' instance"
-  cmd: |
-    set -e;
-    find /srv/salt/reclass/classes/cluster/ -type f -exec sed -i 's/system.keepalived.*/service.keepalived.cluster.single/g' {} +
-    find /srv/salt/reclass/classes/system/ -type f -exec sed -i 's/system.keepalived.*/service.keepalived.cluster.single/g' {} +
-
-  node_name: {{ HOSTNAME_CFG01 }}
-  retry: {count: 1, delay: 5}
-  skip_fail: false
-
-- description: "[EXPERIMENTAL] Create environment model for virtual environment"
-  cmd: |
-    set -e;
-    ln -s '/tmp/environment/environment_template/{{ '{# interfaces #}' }}' '/tmp/environment/environment_template/{{ '{{ cookiecutter._env_name }}' }}/';
-    ln -s '/tmp/environment/environment_template/{{ '{# roles #}' }}' '/tmp/environment/environment_template/{{ '{{ cookiecutter._env_name }}' }}/';
-    reclass-tools render --template-dir /tmp/environment/environment_template/ \
-                         --output-dir /srv/salt/reclass/classes/environment/ \
-                         --context {{ ENVIRONMENT_CONTEXT_PATH }} \
-                         --env-name {{ ENVIRONMENT_MODEL_INVENTORY_NAME }}
-  node_name: {{ HOSTNAME_CFG01 }}
-  retry: {count: 1, delay: 5}
-  skip_fail: false
-
 - description: Modify generated model and reclass-system if necessary
   cmd: |
     set -e;
@@ -316,6 +253,72 @@
 {%- endmacro %}
 
 
+{%- macro MACRO_GENERATE_AND_ENABLE_ENVIRONMENT_MODEL() %}
+{########################################################}
+- description: "[EXPERIMENTAL] Upload 'environment' to {{ HOSTNAME_CFG01 }}"
+  upload:
+    local_path: {{ config.salt_deploy.environment_template_dir }}
+    remote_path: /tmp/environment/
+  node_name: {{ HOSTNAME_CFG01 }}
+  skip_fail: false
+
+- description: "[EXPERIMENTAL] Upload cookiecutter-templates context to {{ HOSTNAME_CFG01 }}"
+  upload:
+    local_path:  {{ config.salt_deploy.templates_dir }}{{ LAB_CONFIG_NAME }}/
+    local_filename: {{ CLUSTER_CONTEXT_NAME }}
+    remote_path: /tmp/environment/
+  node_name: {{ HOSTNAME_CFG01 }}
+
+- description: "[EXPERIMENTAL] Upload environment inventory to {{ HOSTNAME_CFG01 }}"
+  upload:
+    local_path:  {{ config.salt_deploy.templates_dir }}{{ LAB_CONFIG_NAME }}/
+    local_filename: {{ ENVIRONMENT_CONTEXT_NAME }}
+    remote_path: /tmp/environment/
+  node_name: {{ HOSTNAME_CFG01 }}
+
+- description: "[EXPERIMENTAL] Remove linux.network.interface object from the cluster/system models and use fixed 'environment' model instead"
+  cmd: |
+    set -e;
+    apt-get -y install python-virtualenv python-pip build-essential python-dev libssl-dev;
+    pip install git+https://github.com/dis-xcom/reclass-tools;
+    reclass-tools del-key parameters.linux.network.interface /srv/salt/reclass/classes/cluster/;
+    reclass-tools del-key parameters.linux.network.interface /srv/salt/reclass/classes/system/;
+    reclass-tools del-key parameters.linux.network.interface /usr/share/salt-formulas/reclass/;
+
+    if ! reclass-tools get-key 'classes' /srv/salt/reclass/nodes/{{ HOSTNAME_CFG01 }}.yml | grep -q "environment.{{ ENVIRONMENT_MODEL_INVENTORY_NAME }}$"; then
+      reclass-tools add-key 'classes' 'environment.{{ ENVIRONMENT_MODEL_INVENTORY_NAME }}.reclass_datasource_local' /srv/salt/reclass/nodes/_generated/{{ HOSTNAME_CFG01 }}.yml --merge ;
+      reclass-tools add-key 'classes' 'environment.{{ ENVIRONMENT_MODEL_INVENTORY_NAME }}' /srv/salt/reclass/nodes/_generated/{{ HOSTNAME_CFG01 }}.yml --merge ;
+    fi;
+
+  node_name: {{ HOSTNAME_CFG01 }}
+  retry: {count: 1, delay: 5}
+  skip_fail: false
+
+- description: "Workaround for PROD-14756: all roles must use service.keepalived.cluster.single with the default 'VIP' instance"
+  cmd: |
+    set -e;
+    find /srv/salt/reclass/classes/cluster/ -type f -exec sed -i 's/system.keepalived.*/service.keepalived.cluster.single/g' {} +
+    find /srv/salt/reclass/classes/system/ -type f -exec sed -i 's/system.keepalived.*/service.keepalived.cluster.single/g' {} +
+
+  node_name: {{ HOSTNAME_CFG01 }}
+  retry: {count: 1, delay: 5}
+  skip_fail: false
+
+- description: "[EXPERIMENTAL] Create environment model for virtual environment"
+  cmd: |
+    set -e;
+    ln -s '/tmp/environment/environment_template/{{ '{# interfaces #}' }}' '/tmp/environment/environment_template/{{ '{{ cookiecutter._env_name }}' }}/';
+    ln -s '/tmp/environment/environment_template/{{ '{# roles #}' }}' '/tmp/environment/environment_template/{{ '{{ cookiecutter._env_name }}' }}/';
+    reclass-tools render --template-dir /tmp/environment/environment_template/ \
+                         --output-dir /srv/salt/reclass/classes/environment/ \
+                         --context {{ ENVIRONMENT_CONTEXT_PATH }} \
+                         --env-name {{ ENVIRONMENT_MODEL_INVENTORY_NAME }}
+  node_name: {{ HOSTNAME_CFG01 }}
+  retry: {count: 1, delay: 5}
+  skip_fail: false
+{%- endmacro %}
+
+
 {%- macro MACRO_CONFIGURE_RECLASS(FORMULA_SERVICES='') %}
 {#######################################################}
 - description: Configure reclass