Add self-registered computes functional for other templates

- Added self-registered computes mechanism to virtual-mcp11-k8s-calico
and virtual-mcp11-k8s-contrail templates to support models
like sl-k8s-calico and sl-k8s-contrail.

- Mechanism controlled by os_env.

Change-Id: Ibd474aa3af38d30ae1bd204dcb389177eb1a335b
diff --git a/tcp_tests/templates/shared-salt.yaml b/tcp_tests/templates/shared-salt.yaml
index 955972c..1cb8a8c 100644
--- a/tcp_tests/templates/shared-salt.yaml
+++ b/tcp_tests/templates/shared-salt.yaml
@@ -35,6 +35,9 @@
 {% set SALT_FORMULAS_REFS = os_env('SALT_FORMULAS_REFS', '') %}
 {% set SALT_FORMULAS_REPO = os_env('SALT_FORMULAS_REPO', 'https://gerrit.mcp.mirantis.net/salt-formulas') %}
 
+# Needed for using different models in different templates
+{% set CLUSTER_NAME = os_env('DOMAIN_NAME', LAB_CONFIG_NAME) %}
+
 
 {%- macro MACRO_INSTALL_SALT_MASTER() %}
 {######################################}
@@ -144,7 +147,7 @@
     # Disable checkouting the model from remote repository
     cat << 'EOF' >> /srv/salt/reclass/nodes/_generated/{{ HOSTNAME_CFG01 }}.yml
     classes:
-    - cluster.{{ LAB_CONFIG_NAME }}.infra.config
+    - cluster.{{ CLUSTER_NAME }}.infra.config
     parameters:
       _param:
         linux_system_codename: xenial
@@ -677,7 +680,7 @@
     exec > >(tee -i /tmp/cloud-init-bootstrap.log) 2>&1
     export network01_prefix={{ IPV4_NET_ADMIN_PREFIX }}
     export network02_prefix={{ IPV4_NET_CONTROL_PREFIX }}
-    export cluster_name={{ LAB_CONFIG_NAME }}
+    export cluster_name={{ CLUSTER_NAME }}
     export config_host={{ config.salt.salt_master_host }}
     export node_domain={{ DOMAIN_NAME }}
     export nodes_os="xenial"
diff --git a/tcp_tests/templates/virtual-mcp11-k8s-calico/salt.yaml b/tcp_tests/templates/virtual-mcp11-k8s-calico/salt.yaml
index 45ffc37..43e609f 100644
--- a/tcp_tests/templates/virtual-mcp11-k8s-calico/salt.yaml
+++ b/tcp_tests/templates/virtual-mcp11-k8s-calico/salt.yaml
@@ -5,6 +5,9 @@
 {% set SALT_MODELS_REPOSITORY = os_env('SALT_MODELS_REPOSITORY','https://gerrit.mcp.mirantis.net/salt-models/mcp-virtual-lab') %}
 # Other salt model repository parameters see in shared-salt.yaml
 
+{% set ENABLE_COMPUTES_SELF_REGISTER = os_env('ENABLE_COMPUTES_SELF_REGISTER', '') %}
+# Different templates using this mechanism.
+
 {% import 'shared-salt.yaml' as SHARED with context %}
 
 {{ SHARED.MACRO_INSTALL_SALT_MASTER() }}
@@ -19,6 +22,10 @@
 
 {{ SHARED.ADJUST_K8S_OPTS() }}
 
+{%- if ENABLE_COMPUTES_SELF_REGISTER != '' %}
+{{ SHARED.REGISTER_COMPUTE_NODES() }}
+{%- endif %}
+
 {{ SHARED.MACRO_GENERATE_INVENTORY() }}
 
 {{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }}
diff --git a/tcp_tests/templates/virtual-mcp11-k8s-contrail/salt.yaml b/tcp_tests/templates/virtual-mcp11-k8s-contrail/salt.yaml
index c6e1486..0062db5 100644
--- a/tcp_tests/templates/virtual-mcp11-k8s-contrail/salt.yaml
+++ b/tcp_tests/templates/virtual-mcp11-k8s-contrail/salt.yaml
@@ -5,6 +5,10 @@
 {% set SALT_MODELS_REPOSITORY = os_env('SALT_MODELS_REPOSITORY','https://gerrit.mcp.mirantis.net/salt-models/mcp-virtual-lab') %}
 # Other salt model repository parameters see in shared-salt.yaml
 
+
+{% set ENABLE_COMPUTES_SELF_REGISTER = os_env('ENABLE_COMPUTES_SELF_REGISTER', '') %}
+# Different templates using this mechanism.
+
 {% import 'shared-salt.yaml' as SHARED with context %}
 
 {{ SHARED.MACRO_INSTALL_SALT_MASTER() }}
@@ -19,6 +23,10 @@
 
 {{ SHARED.ADJUST_K8S_OPTS() }}
 
+{%- if ENABLE_COMPUTES_SELF_REGISTER != '' %}
+{{ SHARED.REGISTER_COMPUTE_NODES() }}
+{%- endif %}
+
 {{ SHARED.MACRO_GENERATE_INVENTORY() }}
 
 {{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }}