Reconfigure updates.mirantis versioning setting

- Use stable updates repo for released jobs
- Add UPDATES_MIRANTIS_VERSION jenkins param
- Add ability to overwrite repo version in context (upgrade
  pre-deployment)
- Set repo version to 'staging' during MCP drivetrain upgrade

Change-Id: I99d70b6802a0215acf8533909f71b7d9f0784621
diff --git a/tcp_tests/templates/released-heat-cicd-pike-contrail41-sl/salt-context-cookiecutter-contrail.yaml b/tcp_tests/templates/released-heat-cicd-pike-contrail41-sl/salt-context-cookiecutter-contrail.yaml
index a8d05b3..207c298 100644
--- a/tcp_tests/templates/released-heat-cicd-pike-contrail41-sl/salt-context-cookiecutter-contrail.yaml
+++ b/tcp_tests/templates/released-heat-cicd-pike-contrail41-sl/salt-context-cookiecutter-contrail.yaml
@@ -319,4 +319,4 @@
   # Enable Mirantis repo with CVE fixes for xenial
   updates_mirantis_login: "%LOGIN%"
   updates_mirantis_password: "%PASS%"
-  updates_mirantis_version: "staging"
\ No newline at end of file
+  updates_mirantis_version: "stable"
\ No newline at end of file
diff --git a/tcp_tests/templates/released-heat-cicd-queens-dvr-sl/salt-context-cookiecutter.yaml b/tcp_tests/templates/released-heat-cicd-queens-dvr-sl/salt-context-cookiecutter.yaml
index 6e575b1..1b4ffe0 100644
--- a/tcp_tests/templates/released-heat-cicd-queens-dvr-sl/salt-context-cookiecutter.yaml
+++ b/tcp_tests/templates/released-heat-cicd-queens-dvr-sl/salt-context-cookiecutter.yaml
@@ -382,4 +382,4 @@
   # Enable Mirantis repo with CVE fixes for xenial
   updates_mirantis_login: "%LOGIN%"
   updates_mirantis_password: "%PASS%"
-  updates_mirantis_version: "staging"
\ No newline at end of file
+  updates_mirantis_version: "stable"
\ No newline at end of file
diff --git a/tcp_tests/templates/shared-salt.yaml b/tcp_tests/templates/shared-salt.yaml
index 200ae8d..354d59e 100644
--- a/tcp_tests/templates/shared-salt.yaml
+++ b/tcp_tests/templates/shared-salt.yaml
@@ -66,6 +66,8 @@
 # Needed for using different models in different templates
 {% set CLUSTER_NAME = os_env('CLUSTER_NAME', LAB_CONFIG_NAME) %}
 
+# Ubuntu-postEOL updates by cloudlinux
+{% set UPDATES_MIRANTIS_VERSION = os_env('UPDATES_MIRANTIS_VERSION', '') %}
 
 {%- macro MACRO_INSTALL_PACKAGES_ON_NODES(NODE_NAME) %}
 {#####################################################}
@@ -426,6 +428,10 @@
       {%- if JENKINS_PIPELINE_BRANCH != '' %}
         echo "JENKINS_PIPELINE_BRANCH={{ JENKINS_PIPELINE_BRANCH }}"
       {%- endif %}
+      {%- if UPDATES_MIRANTIS_VERSION != '' %}
+        echo "UPDATES_MIRANTIS_VERSION={{ UPDATES_MIRANTIS_VERSION }}"
+      {%- endif %}
+
       echo "======================================="
   node_name: {{ HOSTNAME_CFG01 }}
   retry: {count: 1, delay: 1}
@@ -517,6 +523,10 @@
     find ${REPLACE_DIRS} -type f -exec sed -i 's/==IPV4_NET_TENANT_PREFIX==/{{ IPV4_NET_TENANT_PREFIX }}/g' {} +
     find ${REPLACE_DIRS} -type f -exec sed -i 's/==IPV4_NET_EXTERNAL_PREFIX==/{{ IPV4_NET_EXTERNAL_PREFIX }}/g' {} +
 
+    {%- if UPDATES_MIRANTIS_VERSION != '' %}
+    sed -i "s/updates_mirantis_version:.*/updates_mirantis_version: '{{ UPDATES_MIRANTIS_VERSION }}'/g" {{ CLUSTER_CONTEXT_PATH }}
+    {%- endif %}
+
     {% set items = CLUSTER_PRODUCT_MODELS or '$(ls /root/cookiecutter-templates/cluster_product/)' %}
     mkdir -p /tmp/output /srv/salt/reclass/classes/cluster/{{ CLUSTER_NAME }}/
     # Allow to use encryption keys
diff --git a/tcp_tests/tests/system/test_mcp_update.py b/tcp_tests/tests/system/test_mcp_update.py
index c01c80f..5ec2627 100644
--- a/tcp_tests/tests/system/test_mcp_update.py
+++ b/tcp_tests/tests/system/test_mcp_update.py
@@ -226,11 +226,32 @@
     salt_actions.run_state("*", "saltutil.refresh_pillar")
 
 
+@pytest.fixture(scope='class')
+def switch_to_staging_updates_mirantis_repo(reclass_actions, salt_actions):
+    version_param = "parameters._param.updates_mirantis_version"
+    infra_yml = "cluster/*/infra/init.yml"
+
+    current_version = reclass_actions.get_key(version_param, infra_yml)
+    if current_version == 'staging':
+        LOG.info("updates.mirantis.com already set to 'staging', skipping")
+        return
+    if current_version is None:
+        LOG.info("updates.mirantis.com is not enabled, "
+                 "skipping /staging repo pillar")
+        return
+
+    LOG.info("Switch to updates.mirantis.com/staging repo")
+    reclass_actions.add_key(version_param, 'staging', infra_yml)
+
+    salt_actions.run_state("*", "saltutil.refresh_pillar")
+
+
 @pytest.mark.usefixtures("switch_to_proposed_pipelines",
                          "update_to_tag",
                          "wa_for_galera_clustercheck_password_prod35705",
                          "wa_for_alerta_password_prod35958",
-                         "wa_redis_server_version_3_prod36960")
+                         "wa_redis_server_version_3_prod36960",
+                         "switch_to_staging_updates_mirantis_repo")
 class TestUpdateMcpCluster(object):
     """
     Following the steps in