Make possible to override the docker images for SL

Use the macro in the salt.yaml:
{{ SHARED.ADJUST_SL_OPTS(OVERRIDES_FILENAME='path/to/stacklight/server.yml') }}
and the following environment variables for image paths:

DOCKER_IMAGE_ALERTMANAGER
DOCKER_IMAGE_PUSHGATEWAY
DOCKER_IMAGE_PROMETHEUS
DOCKER_IMAGE_REMOTE_AGENT
DOCKER_IMAGE_REMOTE_STORAGE_ADAPTER
DOCKER_IMAGE_PROMETHEUS_RELAY
DOCKER_IMAGE_GRAFANA

, or manage the tag of the images using the single
variable:

DOCKER_IMAGES_SL_TAG= # latest, 2017.12, ...

Change-Id: Icf5039d9346f631ffb4391588b5090396268bc53
diff --git a/tcp_tests/settings.py b/tcp_tests/settings.py
index a1b296a..f90000c 100644
--- a/tcp_tests/settings.py
+++ b/tcp_tests/settings.py
@@ -52,9 +52,10 @@
 SALT_PASSWORD = os.environ.get('SALT_PASSWORD', 'hovno12345!')
 
 DOCKER_REGISTRY = os.environ.get('DOCKER_REGISTRY',
-                                 'docker-prod-virtual.docker.mirantis.net')
+                                 'docker-prod-local.artifactory.mirantis.com')
 DOCKER_NAME = os.environ.get('DOCKER_NAME',
                              'mirantis/oscore/rally-tempest:latest')
+DOCKER_IMAGES_SL_TAG = os.environ.get('DOCKER_IMAGES_SL_TAG', 'latest')
 
 PATTERN = os.environ.get('PATTERN', None)
 RUN_TEMPEST = get_var_as_bool('RUN_TEMPEST', False)
diff --git a/tcp_tests/settings_oslo.py b/tcp_tests/settings_oslo.py
index dacdb22..9ff0e40 100644
--- a/tcp_tests/settings_oslo.py
+++ b/tcp_tests/settings_oslo.py
@@ -197,20 +197,26 @@
            help="Path to YAML with steps to deploy sl",
            default=_default_sl_prepare_tests_steps_path),
     ct.Cfg('docker_image_alertmanager', ct.String(),
-           default='{}/openstack-docker/alertmanager:latest'.format(
-               settings.DOCKER_REGISTRY)),
+           default='{0}/openstack-docker/alertmanager:{1}'.format(
+               settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
     ct.Cfg('docker_image_pushgateway', ct.String(),
-           default='{}/openstack-docker/pushgateway:latest'.format(
-               settings.DOCKER_REGISTRY)),
+           default='{0}/openstack-docker/pushgateway:{1}'.format(
+               settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
     ct.Cfg('docker_image_prometheus', ct.String(),
-           default='{}/openstack-docker/prometheus:latest'.format(
-               settings.DOCKER_REGISTRY)),
+           default='{0}/openstack-docker/prometheus:{1}'.format(
+               settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
     ct.Cfg('docker_image_remote_agent', ct.String(),
-           default='{}/openstack-docker/telegraf:latest'.format(
-               settings.DOCKER_REGISTRY)),
+           default='{0}/openstack-docker/telegraf:{1}'.format(
+               settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
     ct.Cfg('docker_image_remote_storage_adapter', ct.String(),
-           default='{}/openstack-docker/remote_storage_adapter:latest'.format(
-               settings.DOCKER_REGISTRY)),
+           default='{0}/openstack-docker/remote_storage_adapter:{1}'.format(
+               settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
+    ct.Cfg('docker_image_prometheus_relay', ct.String(),
+           default='{0}/openstack-docker/prometheus_relay:{1}'.format(
+               settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
+    ct.Cfg('docker_image_grafana', ct.String(),
+           default='{0}/mirantis/external/grafana:{1}'.format(
+               settings.DOCKER_REGISTRY, settings.DOCKER_IMAGES_SL_TAG)),
     # SalesForce connection options for pushkin
     ct.Cfg('sfdc_sandbox_enabled', ct.String(), default='False'),
     ct.Cfg('sfdc_auth_url', ct.String(), default=''),
diff --git a/tcp_tests/templates/cookied-bm-mcp-dvr-vxlan/salt.yaml b/tcp_tests/templates/cookied-bm-mcp-dvr-vxlan/salt.yaml
index 019b590..bcf5dbb 100644
--- a/tcp_tests/templates/cookied-bm-mcp-dvr-vxlan/salt.yaml
+++ b/tcp_tests/templates/cookied-bm-mcp-dvr-vxlan/salt.yaml
@@ -58,6 +58,8 @@
 
 {{ SHARED.MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() }}
 
+{{ SHARED.ADJUST_SL_OPTS(OVERRIDES_FILENAME='/srv/salt/reclass/classes/environment/' + ENVIRONMENT_MODEL_INVENTORY_NAME + '/overrides.yml') }}
+
 {{ SHARED.MACRO_GENERATE_INVENTORY() }}
 
 {{ SHARED.MACRO_NETWORKING_WORKAROUNDS() }}
diff --git a/tcp_tests/templates/cookied-bm-mcp-ocata-contrail/salt.yaml b/tcp_tests/templates/cookied-bm-mcp-ocata-contrail/salt.yaml
index f3e121d..dd847c4 100644
--- a/tcp_tests/templates/cookied-bm-mcp-ocata-contrail/salt.yaml
+++ b/tcp_tests/templates/cookied-bm-mcp-ocata-contrail/salt.yaml
@@ -76,6 +76,8 @@
 
 {{ SHARED.MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() }}
 
+{{ SHARED.ADJUST_SL_OPTS(OVERRIDES_FILENAME='/srv/salt/reclass/classes/environment/' + ENVIRONMENT_MODEL_INVENTORY_NAME + '/overrides.yml') }}
+
 - description: "Workaround for rack01 compute generator"
   cmd: |
     set -e;
diff --git a/tcp_tests/templates/cookied-mcp-ocata-dop-sl2/salt.yaml b/tcp_tests/templates/cookied-mcp-ocata-dop-sl2/salt.yaml
index bd34cc8..2a86269 100644
--- a/tcp_tests/templates/cookied-mcp-ocata-dop-sl2/salt.yaml
+++ b/tcp_tests/templates/cookied-mcp-ocata-dop-sl2/salt.yaml
@@ -25,6 +25,8 @@
 
 {{ SHARED.MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() }}
 
+{{ SHARED.ADJUST_SL_OPTS(OVERRIDES_FILENAME='/srv/salt/reclass/classes/environment/' + ENVIRONMENT_MODEL_INVENTORY_NAME + '/overrides.yml') }}
+
 - description: "Workaround for combined roles: remove unnecessary classes"
   cmd: |
     set -e;
diff --git a/tcp_tests/templates/cookied-mcp-ocata-dop-sl2/sl.yaml b/tcp_tests/templates/cookied-mcp-ocata-dop-sl2/sl.yaml
index dddb5fd..504b6c5 100644
--- a/tcp_tests/templates/cookied-mcp-ocata-dop-sl2/sl.yaml
+++ b/tcp_tests/templates/cookied-mcp-ocata-dop-sl2/sl.yaml
@@ -143,22 +143,6 @@
   retry: {count: 1, delay: 10}
   skip_fail: false
 
-# Change environment configuration before deploy
-- description: Set SL docker images deploy parameters
-  cmd: |
-  {#- For cookiecutter-generated model, use overrides.yml from environment model instead of cluster model #}
-  {%- set OVERRIDES_FILENAME='/srv/salt/reclass/classes/environment/' + ENVIRONMENT_MODEL_INVENTORY_NAME + '/overrides.yml' %}
-  {%- for sl_opt, value in config.sl_deploy.items() %}
-    {%- if value|string() %}
-    salt-call reclass.cluster_meta_set name={{ sl_opt }} value={{ value }} file_name={{ OVERRIDES_FILENAME }};
-    {%- endif %}
-  {%- endfor %}
-    salt '*' saltutil.refresh_pillar;
-    sleep 10
-  node_name: {{ HOSTNAME_CFG01 }}
-  retry: {count: 1, delay: 1}
-  skip_fail: false
-
 # Configure the services running in Docker Swarm
 - description: Install prometheus alertmanager
   cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' state.sls prometheus -b 1
diff --git a/tcp_tests/templates/cookied-mcp-ocata-dvr-vxlan/salt.yaml b/tcp_tests/templates/cookied-mcp-ocata-dvr-vxlan/salt.yaml
index 45514bb..0ad8e5e 100644
--- a/tcp_tests/templates/cookied-mcp-ocata-dvr-vxlan/salt.yaml
+++ b/tcp_tests/templates/cookied-mcp-ocata-dvr-vxlan/salt.yaml
@@ -25,6 +25,8 @@
 
 {{ SHARED.MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() }}
 
+{{ SHARED.ADJUST_SL_OPTS(OVERRIDES_FILENAME='/srv/salt/reclass/classes/environment/' + ENVIRONMENT_MODEL_INVENTORY_NAME + '/overrides.yml') }}
+
 {{ SHARED.MACRO_GENERATE_INVENTORY() }}
 
 {{ SHARED.MACRO_NETWORKING_WORKAROUNDS() }}
diff --git a/tcp_tests/templates/cookied-mcp-ocata-dvr-vxlan/sl.yaml b/tcp_tests/templates/cookied-mcp-ocata-dvr-vxlan/sl.yaml
index 4dccd73..dd64b90 100644
--- a/tcp_tests/templates/cookied-mcp-ocata-dvr-vxlan/sl.yaml
+++ b/tcp_tests/templates/cookied-mcp-ocata-dvr-vxlan/sl.yaml
@@ -142,18 +142,6 @@
   retry: {count: 1, delay: 10}
   skip_fail: false
 
-# Change environment configuration before deploy
-- description: Set SL docker images deploy parameters
-  cmd: |
-  {% for sl_opt, value in config.sl_deploy.items() %}
-    {% if value|string() %}
-    salt-call reclass.cluster_meta_set {{ sl_opt }} {{ value }};
-    {% endif %}
-  {% endfor %}
-  node_name: {{ HOSTNAME_CFG01 }}
-  retry: {count: 1, delay: 1}
-  skip_fail: false
-
 # Configure the services running in Docker Swarm
 - description: Install prometheus alertmanager
   cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' state.sls prometheus,heka.remote_collector -b 1
diff --git a/tcp_tests/templates/cookied-mcp-ocata-dvr-vxlan/underlay.yaml b/tcp_tests/templates/cookied-mcp-ocata-dvr-vxlan/underlay.yaml
index b63a123..ef002fe 100644
--- a/tcp_tests/templates/cookied-mcp-ocata-dvr-vxlan/underlay.yaml
+++ b/tcp_tests/templates/cookied-mcp-ocata-dvr-vxlan/underlay.yaml
@@ -344,7 +344,7 @@
           - name: {{ HOSTNAME_CFG01 }}
             role: salt_master
             params:
-              vcpu: !os_env SLAVE_NODE_CPU, 2
+              vcpu: !os_env SLAVE_NODE_CPU, 3
               memory: !os_env SLAVE_NODE_MEMORY, 4096
               boot:
                 - hd
diff --git a/tcp_tests/templates/shared-salt.yaml b/tcp_tests/templates/shared-salt.yaml
index ccefbe1..e34e519 100644
--- a/tcp_tests/templates/shared-salt.yaml
+++ b/tcp_tests/templates/shared-salt.yaml
@@ -764,8 +764,9 @@
 
 {%- endmacro %}
 
+
 {%- macro ADJUST_K8S_OPTS() %}
-{#########################################}
+{############################}
 
 - description: Set k8s deploy parameters
   cmd: |
@@ -780,8 +781,31 @@
 
 {%- endmacro %}
 
+
+{%- macro ADJUST_SL_OPTS(OVERRIDES_FILENAME='') %}
+{#############################################}
+- description: Set SL docker images deploy parameters
+  cmd: |
+  {#- For cookiecutter-generated model, use overrides.yml from environment model instead of cluster model #}
+  {%- for sl_opt, value in config.sl_deploy.items() %}
+    {%- if value|string() %}
+      {%- if OVERRIDES_FILENAME %}
+    salt-call reclass.cluster_meta_set name={{ sl_opt }} value={{ value }} file_name={{ OVERRIDES_FILENAME }};
+      {%- else %}
+    salt-call reclass.cluster_meta_set name={{ sl_opt }} value={{ value }};
+      {%- endif %}
+    {%- endif %}
+  {%- endfor %}
+    salt '*' saltutil.refresh_pillar;
+    sleep 10
+  node_name: {{ HOSTNAME_CFG01 }}
+  retry: {count: 1, delay: 1}
+  skip_fail: false
+{%- endmacro %}
+
+
 {%- macro REGISTER_COMPUTE_NODES() %}
-{#########################################}
+{###################################}
 
 {% for ssh in config.underlay.ssh %}
 {% if ssh["node_name"].startswith("cmp") %}
diff --git a/tcp_tests/templates/virtual-mcp-ocata-dvr/salt.yaml b/tcp_tests/templates/virtual-mcp-ocata-dvr/salt.yaml
index 689dcf4..c8204a8 100644
--- a/tcp_tests/templates/virtual-mcp-ocata-dvr/salt.yaml
+++ b/tcp_tests/templates/virtual-mcp-ocata-dvr/salt.yaml
@@ -17,6 +17,8 @@
 
 {{ SHARED.MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() }}
 
+{{ SHARED.ADJUST_SL_OPTS(OVERRIDES_FILENAME='/srv/salt/reclass/classes/cluster/' + SHARED.CLUSTER_NAME + '/stacklight/server.yml') }}
+
 - description: "Workaround for PROD-14831 , add 'dns' role to cmp01 and cmp02 nodes"
   cmd: |
     set -e;
diff --git a/tcp_tests/templates/virtual-mcp-ocata-ovs/salt.yaml b/tcp_tests/templates/virtual-mcp-ocata-ovs/salt.yaml
index 5f5064f..11fb74b 100644
--- a/tcp_tests/templates/virtual-mcp-ocata-ovs/salt.yaml
+++ b/tcp_tests/templates/virtual-mcp-ocata-ovs/salt.yaml
@@ -17,6 +17,8 @@
 
 {{ SHARED.MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() }}
 
+{{ SHARED.ADJUST_SL_OPTS(OVERRIDES_FILENAME='/srv/salt/reclass/classes/cluster/' + SHARED.CLUSTER_NAME + '/stacklight/server.yml') }}
+
 {{ SHARED.MACRO_GENERATE_INVENTORY() }}
 
 {{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }}
diff --git a/tcp_tests/templates/virtual-mcp-pike-dvr/salt.yaml b/tcp_tests/templates/virtual-mcp-pike-dvr/salt.yaml
index a7c06dd..51a2203 100644
--- a/tcp_tests/templates/virtual-mcp-pike-dvr/salt.yaml
+++ b/tcp_tests/templates/virtual-mcp-pike-dvr/salt.yaml
@@ -17,6 +17,8 @@
 
 {{ SHARED.MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() }}
 
+{{ SHARED.ADJUST_SL_OPTS(OVERRIDES_FILENAME='/srv/salt/reclass/classes/cluster/' + SHARED.CLUSTER_NAME + '/stacklight/server.yml') }}
+
 {{ SHARED.MACRO_GENERATE_INVENTORY() }}
 
 {{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }}
diff --git a/tcp_tests/templates/virtual-mcp-pike-ovs/salt.yaml b/tcp_tests/templates/virtual-mcp-pike-ovs/salt.yaml
index 3eb5082..88b25cd 100644
--- a/tcp_tests/templates/virtual-mcp-pike-ovs/salt.yaml
+++ b/tcp_tests/templates/virtual-mcp-pike-ovs/salt.yaml
@@ -17,6 +17,8 @@
 
 {{ SHARED.MACRO_RUN_SALT_MASTER_UNDERLAY_STATES() }}
 
+{{ SHARED.ADJUST_SL_OPTS(OVERRIDES_FILENAME='/srv/salt/reclass/classes/cluster/' + SHARED.CLUSTER_NAME + '/stacklight/server.yml') }}
+
 {{ SHARED.MACRO_GENERATE_INVENTORY() }}
 
 {{ SHARED.MACRO_BOOTSTRAP_ALL_MINIONS() }}
diff --git a/tcp_tests/templates/virtual-mcp11-k8s-calico/salt.yaml b/tcp_tests/templates/virtual-mcp11-k8s-calico/salt.yaml
index b98a23a..a650b87 100644
--- a/tcp_tests/templates/virtual-mcp11-k8s-calico/salt.yaml
+++ b/tcp_tests/templates/virtual-mcp11-k8s-calico/salt.yaml
@@ -22,6 +22,8 @@
 
 {{ SHARED.ADJUST_K8S_OPTS() }}
 
+{{ SHARED.ADJUST_SL_OPTS(OVERRIDES_FILENAME='/srv/salt/reclass/classes/cluster/' + SHARED.CLUSTER_NAME + '/stacklight/server.yml') }}
+
 {%- if ENABLE_COMPUTES_SELF_REGISTER != '' %}
 {{ SHARED.REGISTER_COMPUTE_NODES() }}
 {%- endif %}
diff --git a/tcp_tests/templates/virtual-mcp11-k8s-calico/sl.yaml b/tcp_tests/templates/virtual-mcp11-k8s-calico/sl.yaml
index 354a00e..53a6aef 100644
--- a/tcp_tests/templates/virtual-mcp11-k8s-calico/sl.yaml
+++ b/tcp_tests/templates/virtual-mcp11-k8s-calico/sl.yaml
@@ -127,18 +127,6 @@
   retry: {count: 1, delay: 10}
   skip_fail: false
 
-# Change environment configuration before deploy
-- description: Set SL docker images deploy parameters
-  cmd: |
-  {% for sl_opt, value in config.sl_deploy.items() %}
-    {% if value|string() %}
-    salt-call reclass.cluster_meta_set {{ sl_opt }} {{ value }};
-    {% endif %}
-  {% endfor %}
-  node_name: {{ HOSTNAME_CFG01 }}
-  retry: {count: 1, delay: 1}
-  skip_fail: false
-
 # Configure the services running in Docker Swarm
 - description: Install prometheus alertmanager
   cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@docker:swarm' state.sls prometheus -b 1
diff --git a/tcp_tests/templates/virtual-mcp11-k8s-contrail/salt.yaml b/tcp_tests/templates/virtual-mcp11-k8s-contrail/salt.yaml
index 0062db5..3c37187 100644
--- a/tcp_tests/templates/virtual-mcp11-k8s-contrail/salt.yaml
+++ b/tcp_tests/templates/virtual-mcp11-k8s-contrail/salt.yaml
@@ -23,6 +23,8 @@
 
 {{ SHARED.ADJUST_K8S_OPTS() }}
 
+{{ SHARED.ADJUST_SL_OPTS(OVERRIDES_FILENAME='/srv/salt/reclass/classes/cluster/' + SHARED.CLUSTER_NAME + '/stacklight/server.yml') }}
+
 {%- if ENABLE_COMPUTES_SELF_REGISTER != '' %}
 {{ SHARED.REGISTER_COMPUTE_NODES() }}
 {%- endif %}