Add possibility to change k8s images.

* Added possibility to change k8s and netchecker images
from contrail+k8s template.
* Fixed getting node role in virtlet manager.

Change-Id: Ibf281632459136a9f62d1a7f198d27cc488ad67e
Reviewed-on: https://review.gerrithub.io/366394
Reviewed-by: <apanchenko@mirantis.com>
Reviewed-by: Victor Ryzhenkin <vryzhenkin@mirantis.com>
Reviewed-by: Dennis Dmitriev <dis.xcom@gmail.com>
Tested-by: Dennis Dmitriev <dis.xcom@gmail.com>
diff --git a/tcp_tests/templates/virtual-mcp11-k8s-calico/k8s.yaml b/tcp_tests/templates/virtual-mcp11-k8s-calico/k8s.yaml
index d63fba3..cd287e6 100644
--- a/tcp_tests/templates/virtual-mcp11-k8s-calico/k8s.yaml
+++ b/tcp_tests/templates/virtual-mcp11-k8s-calico/k8s.yaml
@@ -1,5 +1,18 @@
 {% from 'virtual-mcp11-k8s-calico/underlay.yaml' import HOSTNAME_CFG01 with context %}
 
+# Change environment configuration before deploy
+- description: Set k8s deploy parameters
+  cmd: |
+  {% for k8s_opt, value in config.k8s_deploy.items() %}
+    {% if value|string() %}
+    salt-call reclass.cluster_meta_set {{ k8s_opt }} {{ value }};
+    {% endif %}
+  {% endfor %}
+  node_name: {{ HOSTNAME_CFG01 }}
+  retry: {count: 1, delay: 1}
+  skip_fail: false
+
+# Kubernetes
 - description: Install etcd
   cmd: salt --hard-crash --state-output=mixed --state-verbose=False
     -C 'I@etcd:server' state.sls etcd.server.service
diff --git a/tcp_tests/templates/virtual-mcp11-k8s-calico/salt.yaml b/tcp_tests/templates/virtual-mcp11-k8s-calico/salt.yaml
index bd70138..4bacd55 100644
--- a/tcp_tests/templates/virtual-mcp11-k8s-calico/salt.yaml
+++ b/tcp_tests/templates/virtual-mcp11-k8s-calico/salt.yaml
@@ -17,10 +17,6 @@
 {% set IPV4_NET_ADMIN_PREFIX = '.'.join(IPV4_NET_ADMIN.split('.')[0:3]) %}
 {% set IPV4_NET_CONTROL_PREFIX = '.'.join(IPV4_NET_CONTROL.split('.')[0:3]) %}
 
-# Set docker engine version if one exported as environment variables
-{% set DOCKER_ENGINE = os_env('DOCKER_ENGINE', "") %}
-{% set LAB_CONFIG_NAME = os_env('LAB_CONFIG_NAME', "virtual-mcp11-k8s-calico") %}
-
 # Install salt to the config node
 - description: Installing salt master on cfg01
   cmd:  apt-get install -y reclass git; apt-get install -y salt-master
@@ -240,36 +236,6 @@
   retry: {count: 1, delay: 5}
   skip_fail: false
 
-# Change environment configuration before deploy
-
-{% for image_prefix in "CALICOCTL CALICO CALICO_CNI HYPERKUBE NETCHECKER_AGENT NETCHECKER_SERVER".split() %}
-- description: Change {{ image_prefix.lower() }} image to custom if necessary
-  cmd: |
-    image_link={{ os_env('CUSTOM_IMAGE_' + image_prefix, "") }}
-    if [ -n "${image_link}" ]; then
-        echo "{{ image_prefix.lower() }} image link changed to "${image_link}""
-        salt -C 'I@salt:master' reclass.cluster_meta_set kubernetes_{{ image_prefix.lower() }}_image ${image_link}
-    else
-        echo "Custom {{ image_prefix.lower() }} image link is not set, skipped."
-    fi
-  node_name: {{ HOSTNAME_CFG01 }}
-  retry: {count: 1, delay: 5}
-  skip_fail: false
-{% endfor %}
-
-- description: Change docker engine version to custom if necessary
-  cmd: |
-     FILE="/srv/salt/reclass/classes/cluster/{{ LAB_CONFIG_NAME }}/kubernetes/compute.yml"
-     if [ -n "{{ DOCKER_ENGINE }}" ]; then
-       echo "Change docker engine version to: {{ DOCKER_ENGINE }}"
-       sed "s#docker-engine=.*#docker-engine={{ DOCKER_ENGINE }}#" -i.bak ${FILE}
-     else
-       echo "Custom docker engine version is not set, skipped."
-     fi
-  node_name: {{ HOSTNAME_CFG01 }}
-  retry: {count: 1, delay: 5}
-  skip_fail: false
-
 # Bootstrap all nodes
 
 - description: Configure linux on other nodes
diff --git a/tcp_tests/templates/virtual-mcp11-k8s-contrail/k8s.yaml b/tcp_tests/templates/virtual-mcp11-k8s-contrail/k8s.yaml
index 0cdb087..9813f32 100644
--- a/tcp_tests/templates/virtual-mcp11-k8s-contrail/k8s.yaml
+++ b/tcp_tests/templates/virtual-mcp11-k8s-contrail/k8s.yaml
@@ -1,5 +1,18 @@
 {% from 'virtual-mcp11-k8s-contrail/underlay.yaml' import HOSTNAME_CFG01 with context %}
 
+# Change environment configuration before deploy
+
+- description: Set k8s deploy parameters
+  cmd: |
+  {% for k8s_opt, value in config.k8s_deploy.items() %}
+    {% if value|string() %}
+    salt-call reclass.cluster_meta_set {{ k8s_opt }} {{ value }};
+    {% endif %}
+  {% endfor %}
+  node_name: {{ HOSTNAME_CFG01 }}
+  retry: {count: 1, delay: 1}
+  skip_fail: false
+
 #Kubernetes
 - description: Install docker
   cmd: salt --hard-crash --state-output=mixed --state-verbose=False