Merge "Fix proxy node ip in calico test"
diff --git a/tcp_tests/managers/k8smanager.py b/tcp_tests/managers/k8smanager.py
index 7d9b142..d84fd73 100644
--- a/tcp_tests/managers/k8smanager.py
+++ b/tcp_tests/managers/k8smanager.py
@@ -21,7 +21,7 @@
 from tcp_tests import logger
 from tcp_tests.managers.execute_commands import ExecuteCommandsMixin
 from tcp_tests.managers.k8s import cluster
-
+from k8sclient.client.rest import ApiException
 
 LOG = logger.logger
 
@@ -275,12 +275,20 @@
         :param name: str
         :rtype: K8sNamespace object
         """
-        LOG.info("Creating Namespace in k8s cluster")
-        ns = self.api.namespaces.create(body={'metadata': {'name': name}})
-        LOG.info("Namespace '{0}' is created".format(ns.name))
-        # wait 10 seconds until a token for new service account is created
-        time.sleep(10)
-        return self.api.namespaces.get(name=ns.name)
+        try:
+            ns = self.api.namespaces.get(name=name)
+            LOG.info("Namespace '{0}' is already exists".format(ns.name))
+        except ApiException as e:
+          if hasattr(e,"status") and 404 == e.status:
+            LOG.info("Creating Namespace in k8s cluster")
+            ns = self.api.namespaces.create(body={'metadata': {'name': name}})
+            LOG.info("Namespace '{0}' is created".format(ns.name))
+            # wait 10 seconds until a token for new service account is created
+            time.sleep(10)
+            ns = self.api.namespaces.get(name=ns.name)
+          else:
+            raise
+        return ns
 
     def create_objects(self, path):
         if isinstance(path, str):
diff --git a/tcp_tests/requirements.txt b/tcp_tests/requirements.txt
index da56a73..26b84b9 100644
--- a/tcp_tests/requirements.txt
+++ b/tcp_tests/requirements.txt
@@ -1,5 +1,5 @@
 # git+git://github.com/openstack/fuel-devops.git@887368d#egg=project[postgre]   # Use this requirement for PostgreSQL
-git+git://github.com/openstack/fuel-devops.git@887368d   # Use this requirement for Sqlite3, or if requirements for PostgreSQL are already installed
+git+git://github.com/openstack/fuel-devops.git@e115ef4   # Use this requirement for Sqlite3, or if requirements for PostgreSQL are already installed
 git+git://github.com/dis-xcom/fuel-devops-driver-ironic
 paramiko
 six
diff --git a/tcp_tests/templates/cookied-mcp-ocata-dop-sl2/oss.yaml b/tcp_tests/templates/cookied-mcp-ocata-dop-sl2/oss.yaml
index ba09e45..5b9b09d 100644
--- a/tcp_tests/templates/cookied-mcp-ocata-dop-sl2/oss.yaml
+++ b/tcp_tests/templates/cookied-mcp-ocata-dop-sl2/oss.yaml
@@ -289,6 +289,13 @@
   retry: {count: 1, delay: 10}
   skip_fail: true
 
+- description: Run salt minion to create cert files for nginx
+  cmd: salt --hard-crash --state-output=mixed --state-verbose=False
+    -C 'I@nginx:server' state.sls salt.minion
+  node_name: {{ HOSTNAME_CFG01 }}
+  retry: {count: 1, delay: 10}
+  skip_fail: false
+
 - description: Install nginx
   cmd: salt --hard-crash --state-output=mixed --state-verbose=False -C 'I@nginx:server' state.sls nginx
   node_name: {{ HOSTNAME_CFG01 }}
diff --git a/tcp_tests/templates/cookied-mcp-ocata-dvr-vxlan/common-services.yaml b/tcp_tests/templates/cookied-mcp-ocata-dvr-vxlan/common-services.yaml
index 8607bec..1deca4b 100644
--- a/tcp_tests/templates/cookied-mcp-ocata-dvr-vxlan/common-services.yaml
+++ b/tcp_tests/templates/cookied-mcp-ocata-dvr-vxlan/common-services.yaml
@@ -103,6 +103,13 @@
   retry: {count: 1, delay: 5}
   skip_fail: false
 
+- description: Run salt minion to create cert files for nginx
+  cmd: salt --hard-crash --state-output=mixed --state-verbose=False
+    -C 'I@nginx:server' state.sls salt.minion
+  node_name: {{ HOSTNAME_CFG01 }}
+  retry: {count: 1, delay: 10}
+  skip_fail: false
+
 - description: Install nginx on prx nodes
   cmd: salt --hard-crash --state-output=mixed --state-verbose=False
     -C 'I@nginx:server' state.sls nginx
diff --git a/tcp_tests/templates/shared-salt.yaml b/tcp_tests/templates/shared-salt.yaml
index a529543..a954be7 100644
--- a/tcp_tests/templates/shared-salt.yaml
+++ b/tcp_tests/templates/shared-salt.yaml
@@ -112,6 +112,7 @@
     {%- endif %}
     popd;
     mkdir -p /srv/salt/reclass/classes/service;
+    rm -rf /srv/salt/reclass/nodes/  # For backward compatibility. New cfg node will be regenerated here
     mkdir -p /srv/salt/reclass/nodes/_generated/;
 
     # Replace firstly to an intermediate value to avoid intersection between
@@ -183,6 +184,7 @@
     mkdir -p /srv/salt/reclass/classes/cluster/
     mkdir -p /srv/salt/reclass/classes/system/
     mkdir -p /srv/salt/reclass/classes/service/
+    rm -rf /srv/salt/reclass/nodes/  # For backward compatibility. New cfg node will be regenerated here
     mkdir -p /srv/salt/reclass/nodes/_generated
 
     # Override some context parameters
diff --git a/tcp_tests/templates/virtual-mcp-ocata-dvr/openstack.yaml b/tcp_tests/templates/virtual-mcp-ocata-dvr/openstack.yaml
index 3e0a4d3..966b7c1 100644
--- a/tcp_tests/templates/virtual-mcp-ocata-dvr/openstack.yaml
+++ b/tcp_tests/templates/virtual-mcp-ocata-dvr/openstack.yaml
@@ -5,7 +5,6 @@
 {% from 'virtual-mcp-ocata-dvr/underlay.yaml' import HOSTNAME_GTW01 with context %}
 {% from 'shared-salt.yaml' import IPV4_NET_EXTERNAL_PREFIX with context %}
 {% from 'shared-salt.yaml' import IPV4_NET_TENANT_PREFIX with context %}
-{% set PATTERN = os_env('PATTERN', 'smoke') %}
 {% set LAB_CONFIG_NAME = os_env('LAB_CONFIG_NAME') %}
 
 # Install OpenStack control services
diff --git a/tcp_tests/templates/virtual-mcp-ocata-dvr/underlay.yaml b/tcp_tests/templates/virtual-mcp-ocata-dvr/underlay.yaml
index 361474e..5a661dc 100644
--- a/tcp_tests/templates/virtual-mcp-ocata-dvr/underlay.yaml
+++ b/tcp_tests/templates/virtual-mcp-ocata-dvr/underlay.yaml
@@ -317,8 +317,8 @@
                   format: raw
                   device: cdrom
                   bus: ide
-                  cloudinit_meta_data: !include underlay--meta-data.yaml
-                  cloudinit_user_data: !include underlay--user-data1604.yaml
+                  cloudinit_meta_data: *cloudinit_meta_data
+                  cloudinit_user_data: *cloudinit_user_data_1604
 
               interfaces: *interfaces
               network_config: *network_config
@@ -343,8 +343,8 @@
                   format: raw
                   device: cdrom
                   bus: ide
-                  cloudinit_meta_data: !include underlay--meta-data.yaml
-                  cloudinit_user_data: !include underlay--user-data1604.yaml
+                  cloudinit_meta_data: *cloudinit_meta_data
+                  cloudinit_user_data: *cloudinit_user_data_1604
 
               interfaces: *interfaces
               network_config: *network_config
@@ -369,8 +369,8 @@
                   format: raw
                   device: cdrom
                   bus: ide
-                  cloudinit_meta_data: !include underlay--meta-data.yaml
-                  cloudinit_user_data: !include underlay--user-data1604.yaml
+                  cloudinit_meta_data: *cloudinit_meta_data
+                  cloudinit_user_data: *cloudinit_user_data_1604
 
               interfaces: *interfaces
               network_config: *network_config
diff --git a/tcp_tests/templates/virtual-mcp-ocata-ovs/openstack.yaml b/tcp_tests/templates/virtual-mcp-ocata-ovs/openstack.yaml
index 0023f88..c78e1b7 100644
--- a/tcp_tests/templates/virtual-mcp-ocata-ovs/openstack.yaml
+++ b/tcp_tests/templates/virtual-mcp-ocata-ovs/openstack.yaml
@@ -5,7 +5,6 @@
 {% from 'virtual-mcp-ocata-ovs/underlay.yaml' import HOSTNAME_GTW01 with context %}
 {% from 'shared-salt.yaml' import IPV4_NET_EXTERNAL_PREFIX with context %}
 {% from 'shared-salt.yaml' import IPV4_NET_TENANT_PREFIX with context %}
-{% set PATTERN = os_env('PATTERN', 'smoke') %}
 
 # Install OpenStack control services
 
diff --git a/tcp_tests/templates/virtual-mcp-ocata-ovs/underlay.yaml b/tcp_tests/templates/virtual-mcp-ocata-ovs/underlay.yaml
index 91c7a8b..9c19371 100644
--- a/tcp_tests/templates/virtual-mcp-ocata-ovs/underlay.yaml
+++ b/tcp_tests/templates/virtual-mcp-ocata-ovs/underlay.yaml
@@ -317,8 +317,8 @@
                   format: raw
                   device: cdrom
                   bus: ide
-                  cloudinit_meta_data: !include underlay--meta-data.yaml
-                  cloudinit_user_data: !include underlay--user-data1604.yaml
+                  cloudinit_meta_data: *cloudinit_meta_data
+                  cloudinit_user_data: *cloudinit_user_data_1604
 
               interfaces: *interfaces
               network_config: *network_config
@@ -343,8 +343,8 @@
                   format: raw
                   device: cdrom
                   bus: ide
-                  cloudinit_meta_data: !include underlay--meta-data.yaml
-                  cloudinit_user_data: !include underlay--user-data1604.yaml
+                  cloudinit_meta_data: *cloudinit_meta_data
+                  cloudinit_user_data: *cloudinit_user_data_1604
 
               interfaces: *interfaces
               network_config: *network_config
@@ -369,8 +369,8 @@
                   format: raw
                   device: cdrom
                   bus: ide
-                  cloudinit_meta_data: !include underlay--meta-data.yaml
-                  cloudinit_user_data: !include underlay--user-data1604.yaml
+                  cloudinit_meta_data: *cloudinit_meta_data
+                  cloudinit_user_data: *cloudinit_user_data_1604
 
               interfaces: *interfaces
               network_config: *network_config