\Update runtestmanager

Change-Id: I85122734c0488f33e594724c88e01ba278f6989e
diff --git a/tcp_tests/fixtures/runtest_fixtures.py b/tcp_tests/fixtures/runtest_fixtures.py
index 3e1a45b..53342ae 100644
--- a/tcp_tests/fixtures/runtest_fixtures.py
+++ b/tcp_tests/fixtures/runtest_fixtures.py
@@ -26,13 +26,11 @@
     tempest_pattern = settings.TEMPEST_PATTERN
     cluster_name = settings.LAB_CONFIG_NAME
     domain_name = settings.DOMAIN_NAME
-    target = settings.TEMPEST_TARGET
     runtest = RuntestManager(
         config,
         underlay_actions, salt_actions,
         cluster_name=cluster_name,
         domain_name=domain_name,
         tempest_threads=tempest_threads,
-        tempest_pattern=tempest_pattern,
-        target=target)
+        tempest_pattern=tempest_pattern)
     return runtest
diff --git a/tcp_tests/managers/runtestmanager.py b/tcp_tests/managers/runtestmanager.py
index bc39643..a354d01 100644
--- a/tcp_tests/managers/runtestmanager.py
+++ b/tcp_tests/managers/runtestmanager.py
@@ -39,8 +39,7 @@
     def __init__(self, config, underlay, salt_api, cluster_name,
                  domain_name, tempest_threads,
                  tempest_pattern=settings.TEMPEST_PATTERN,
-                 run_cmd=None, target='gtw01*', control_host='ctl01*',
-                 compute_host='cmp001*'):
+                 run_cmd=None):
         self.__config = config
         self.underlay = underlay
         self.__salt_api = salt_api
@@ -49,98 +48,26 @@
         self.tempest_threads = tempest_threads
         self.tempest_pattern = tempest_pattern
         self.run_cmd = run_cmd or self.run_cmd
-        self.target_name = self.underlay.get_target_node_names(target)[0]
         self.master_name = self.underlay.get_target_node_names(
             self.master_host)[0]
-        self.control_name = control_host
-        self.compute_name = compute_host
-        self.barbican = False
+        self.__target_name = None
 
     @property
     def salt_api(self):
         return self.__salt_api
 
     @property
-    def runtest_pillar(self):
-        public_net = self.__config.underlay.dhcp_ranges[
-            settings.EXTERNAL_ADDRESS_POOL_NAME]
-        public_gateway = public_net["gateway"].encode("ascii")
-        public_cidr = public_net["cidr"].encode("ascii")
-        public_allocation_start = public_net["start"].encode("ascii")
-        public_allocation_end = public_net["end"].encode("ascii")
-        tempest_test_target = self.target_name.encode("ascii") + "*"
-
-        pillar = {
-            'classes': ['service.runtest.tempest',
-                        'service.runtest.tempest.public_net',
-                        'service.runtest.tempest.services.manila.glance'],
-            'parameters': {
-                '_param': {
-                    'runtest_tempest_cfg_dir': TEMPEST_CFG_DIR,
-                    'runtest_tempest_cfg_name': 'tempest.conf',
-                    'runtest_tempest_public_net': 'public',
-                    'openstack_public_neutron_subnet_gateway': public_gateway,
-                    'openstack_public_neutron_subnet_cidr': public_cidr,
-                    'openstack_public_neutron_subnet_allocation_start':
-                        public_allocation_start,
-                    'openstack_public_neutron_subnet_allocation_end':
-                        public_allocation_end,
-                    'tempest_test_target': tempest_test_target,
-                    'glance_image_cirros_location':
-                        'http://cz8133.bud.mirantis.net:8099'
-                        '/cirros-0.3.5-x86_64-disk.img',
-                    'glance_image_fedora_location':
-                        'http://cz8133.bud.mirantis.net:8099'
-                        '/Fedora-Cloud-Base-27-1.6.x86_64.qcow2',
-                    'glance_image_manila_location':
-                        'http://cz8133.bud.mirantis.net:8099'
-                        '/manila-service-image-master.qcow2',
-                },
-                'neutron': {
-                    'client': {
-                        'enabled': True
-                    }
-                },
-                'runtest': {
-                    'enabled': True,
-                    'keystonerc_node': 'ctl01*',
-                    'tempest': {
-                        'enabled': True,
-                        'cfg_dir': '${_param:runtest_tempest_cfg_dir}',
-                        'cfg_name': '${_param:runtest_tempest_cfg_name}',
-                        'put_keystone_rc_enabled': True,
-                        'put_local_image_file_enabled': False,
-                        'DEFAULT': {
-                            'log_file': 'tempest.log'
-                        },
-                        'compute': {
-                            'min_compute_nodes': 2,
-                        },
-                        'convert_to_uuid': {
-                            'network': {
-                                'public_network_id':
-                                '${_param:runtest_tempest_public_net}'
-                            }
-                        },
-                        'heat_plugin': {
-                            'build_timeout': '600'
-                        },
-                        'share': {
-                            'capability_snapshot_support': True,
-                            'run_driver_assisted_migration_tests': False,
-                            'run_manage_unmanage_snapshot_tests': False,
-                            'run_manage_unmanage_tests': False,
-                            'run_migration_with_preserve_snapshots_tests':
-                                False,
-                            'run_quota_tests': True,
-                            'run_replication_tests': False,
-                            'run_snapshot_tests': True,
-                        }}}}}
-
-        if self.barbican:
-            pillar['classes'].append('service.runtest.tempest.barbican')
-
-        return pillar
+    def target_name(self):
+        if not self.__target_name:
+            result = self.salt_api.get_pillar(
+                tgt=self.master_name,
+                pillar="runtest:tempest:test_target")
+            target_host = (result[0].get(self.master_name))
+            if target_host[-1] == "*":
+                target_host = target_host[:-1]
+            self.__target_name = self.underlay.get_target_node_names(
+                target_host)[0]
+        return self.__target_name
 
     def fetch_arficats(self, username=None, file_format='xml'):
         with self.underlay.remote(node_name=self.target_name,
@@ -156,25 +83,6 @@
                 destination=report,  # noqa
                 target=os.getcwd())
 
-    def store_runtest_model(self, runtest_pillar=None):
-        with self.underlay.yaml_editor(
-                file_path="/srv/salt/reclass/classes/cluster/"
-                          "{cluster_name}/infra/"
-                          "{class_name}.yml".format(
-                              cluster_name=self.cluster_name,
-                              class_name=self.class_name),
-                node_name=self.master_name) as editor:
-            editor.content = runtest_pillar or self.runtest_pillar
-        with self.underlay.yaml_editor(
-                file_path="/srv/salt/reclass/nodes/_generated/"
-                          "cfg01.{domain_name}.yml".format(
-                              domain_name=self.domain_name),
-                node_name=self.master_name) as editor:
-            editor.content['classes'].append(
-                'cluster.{cluster_name}.infra.{class_name}'.format(
-                    cluster_name=self.cluster_name,
-                    class_name=self.class_name))
-
     def save_runtime_logs(self, logs=None, inspect=None):
         if logs:
             with open("{path}/{target}_tempest_run.log".format(
@@ -194,35 +102,10 @@
                                                indent=4, sort_keys=True)
                 f.write(container_inspect)
 
-    def prepare(self, store_run_test_model):
-        barbican_pillar = "nova:controller:barbican:enabled"
-        result = self.__salt_api.get_pillar(tgt=self.control_name,
-                                            pillar=barbican_pillar)
-        self.barbican = result[0].get(self.control_name, False)
-        if store_run_test_model:
-            self.store_runtest_model()
-        cirros_pillar = ("salt-call --out=newline_values_only "
-                         "pillar.get "
-                         "glance:client:identity:"
-                         "admin_identity:image:cirros:location")
-        dpdk_pillar = "linux:network:dpdk:enabled"
-        salt_cmd = "salt -l info --hard-crash --state-output=mixed "
+    def prepare(self):
         salt_call_cmd = "salt-call -l info --hard-crash --state-output=mixed "
-
-        result = self.__salt_api.get_pillar(tgt=self.compute_name,
-                                            pillar=dpdk_pillar)
-
-        dpdk = result[0].get(self.compute_name, False)
-        LOG.info("DPDK enabled: {}".format(bool(dpdk)))
-
         commands = [
             {
-                'description': "Sync salt objects for runtest model",
-                'node_name': self.master_name,
-                'cmd': ("set -ex;" +
-                        salt_cmd + "'*' saltutil.refresh_pillar && " +
-                        salt_cmd + "'*' saltutil.sync_all")},
-            {
                 'description': ("Install docker-ce package and "
                                 "enable packets forwarding"),
                 'node_name': self.target_name,
@@ -236,71 +119,12 @@
                         salt_call_cmd + " pip.install setuptools && " +
                         salt_call_cmd + " pip.install docker")},
             {
-                'description': "Run salt.minion state for runtest formula",
-                'node_name': self.master_name,
-                'cmd': ("set -ex;" +
-                        salt_call_cmd + " state.sls salt.minion && "
-                        " sleep 20")},
-            {
-                'description': "Enforce keystone state for neutronv2",
-                'node_name': self.master_name,
-                'cmd': ("set -ex;" +
-                        salt_call_cmd + " state.sls keystone.client")},
-            {
-                'description': "Create networks for Tempest tests",
-                'node_name': self.master_name,
-                'cmd': ("set -ex;" +
-                        salt_call_cmd + " state.sls neutron.client")},
-            {
-                'description': "Create flavors for Tempest tests",
-                'node_name': self.master_name,
-                'cmd': ("set -ex;" +
-                        salt_call_cmd + " state.sls nova.client")},
-            {
-                'description': "Upload images for Tempest",
-                'node_name': self.master_name,
-                'cmd': ("set -ex;" +
-                        salt_call_cmd + " state.sls glance.client")},
-            {
                 'description': "Generate config for Tempest",
                 'node_name': self.master_name,
                 'cmd': ("set -ex;" +
-                        salt_call_cmd + " state.sls runtest")},
-            {
-                'description': "Upload cirros image",
-                'node_name': self.master_name,
-                'cmd': ("set -ex;"
-                        "cirros_url=$({}) && {} '{}' cmd.run "
-                        "\"wget $cirros_url -O /tmp/TestCirros-0.3.5.img\""
-                        .format(cirros_pillar, salt_cmd, self.target_name))},
+                        "salt-run state.orchestrate " +
+                        "runtest.orchestrate.tempest")},
         ]
-
-        if dpdk:
-            commands.append({
-                'description': "Configure flavor for DPDK",
-                'node_name': self.control_name,
-                'cmd': ("set -ex;" +
-                        salt_call_cmd + " cmd.run "
-                        " '. /root/keystonercv3;"
-                        "  openstack flavor set m1.extra_tiny_test"
-                        "  --property hw:mem_page_size=any;"
-                        "  openstack flavor set m1.tiny_test"
-                        "  --property hw:mem_page_size=any'")},
-            )
-
-        if self.barbican:
-            commands.append({
-                'description': "Configure barbican",
-                'node_name': self.master_name,
-                'cmd': ("set -ex;" +
-                        salt_call_cmd +
-                        " state.sls barbican.client && " +
-                        salt_call_cmd +
-                        " state.sls runtest.test_accounts && " +
-                        salt_call_cmd +
-                        " state.sls runtest.barbican_sign_image")},
-            )
-
         self.__salt_api.execute_commands(commands=commands,
                                          label="Prepare for Tempest")
 
@@ -380,13 +204,12 @@
         return {'inspect': inspect,
                 'logs': logs}
 
-    def prepare_and_run_tempest(self, username='root',
-                                store_run_test_model=True):
+    def prepare_and_run_tempest(self, username='root'):
         """
         Run tempest tests
         """
         tempest_timeout = settings.TEMPEST_TIMEOUT
-        self.prepare(store_run_test_model=store_run_test_model)
+        self.prepare()
         test_res = self.run_tempest(tempest_timeout)
         self.fetch_arficats(username=username)
         self.save_runtime_logs(**test_res)
diff --git a/tcp_tests/templates/cookied-cicd-ovs-maas/salt-context-cookiecutter-openstack_ovs.yaml b/tcp_tests/templates/cookied-cicd-ovs-maas/salt-context-cookiecutter-openstack_ovs.yaml
index 3355d16..335b2d0 100644
--- a/tcp_tests/templates/cookied-cicd-ovs-maas/salt-context-cookiecutter-openstack_ovs.yaml
+++ b/tcp_tests/templates/cookied-cicd-ovs-maas/salt-context-cookiecutter-openstack_ovs.yaml
@@ -518,7 +518,7 @@
   openstack_barbican_node02_hostname: kmn02
   openstack_barbican_node03_address: 10.167.11.47
   openstack_barbican_node03_hostname: kmn03
-  openstack_create_public_network: 'False'
+  openstack_create_public_network: 'True'
   openstack_public_neutron_subnet_gateway: 172.17.42.1
   openstack_public_neutron_subnet_cidr: 172.17.42.0/26
   openstack_public_neutron_subnet_allocation_start: 172.17.42.15
diff --git a/tcp_tests/templates/cookied-cicd-ovs-maas/salt-context-environment.yaml b/tcp_tests/templates/cookied-cicd-ovs-maas/salt-context-environment.yaml
index 768df20..c4fae7b 100644
--- a/tcp_tests/templates/cookied-cicd-ovs-maas/salt-context-environment.yaml
+++ b/tcp_tests/templates/cookied-cicd-ovs-maas/salt-context-environment.yaml
@@ -4,6 +4,7 @@
       roles:
       - infra_config
       - linux_system_codename_xenial
+      - features_runtest
       interfaces:
         ens3:
           role: single_static_mgm
diff --git a/tcp_tests/templates/cookied-cicd-pike-dvr-ceph/cookiecutter-context-dvr-ceph.yaml b/tcp_tests/templates/cookied-cicd-pike-dvr-ceph/cookiecutter-context-dvr-ceph.yaml
index dcf4654..d42f93f 100644
--- a/tcp_tests/templates/cookied-cicd-pike-dvr-ceph/cookiecutter-context-dvr-ceph.yaml
+++ b/tcp_tests/templates/cookied-cicd-pike-dvr-ceph/cookiecutter-context-dvr-ceph.yaml
@@ -159,7 +159,6 @@
   mcp_common_scripts_branch: 'proposed'
   mcp_version: proposed
   no_platform: 'False'
-  nova_vnc_tls_enabled: 'True'
   offline_deployment: 'False'
   opencontrail_enabled: 'False'
   openldap_domain: ${_param:cluster_name}.local
@@ -295,7 +294,7 @@
   rabbitmq_ssl_enabled: 'True'
   openstack_rabbitmq_x509_enabled: 'True'
   openstack_internal_protocol: 'https'
-  openstack_create_public_network: 'False'
+  openstack_create_public_network: 'True'
   openstack_public_neutron_subnet_gateway: 172.17.16.1
   openstack_public_neutron_subnet_cidr: 172.17.16.0/24
   openstack_public_neutron_subnet_allocation_start: 172.17.16.201
diff --git a/tcp_tests/templates/cookied-cicd-pike-dvr-ceph/environment_context.yaml b/tcp_tests/templates/cookied-cicd-pike-dvr-ceph/environment_context.yaml
index 339956e..f396f3e 100644
--- a/tcp_tests/templates/cookied-cicd-pike-dvr-ceph/environment_context.yaml
+++ b/tcp_tests/templates/cookied-cicd-pike-dvr-ceph/environment_context.yaml
@@ -4,6 +4,7 @@
       roles:
       - infra_config
       - linux_system_codename_xenial
+      - features_runtest
       classes:
       - environment.cookied-cicd-pike-dvr-ceph.override_ntp_virtual
       interfaces:
diff --git a/tcp_tests/templates/cookied-cicd-queens-dvr-sl/cookiecutter-context-queens-dvr-sl.yaml b/tcp_tests/templates/cookied-cicd-queens-dvr-sl/cookiecutter-context-queens-dvr-sl.yaml
index 343a4e6..56f3646 100644
--- a/tcp_tests/templates/cookied-cicd-queens-dvr-sl/cookiecutter-context-queens-dvr-sl.yaml
+++ b/tcp_tests/templates/cookied-cicd-queens-dvr-sl/cookiecutter-context-queens-dvr-sl.yaml
@@ -266,7 +266,7 @@
   octavia_lb_mgmt_cidr: 192.168.1.0/24
   octavia_lb_mgmt_allocation_pool_start: 192.168.1.2
   octavia_lb_mgmt_allocation_pool_end: 192.168.1.200
-  openstack_create_public_network: 'False'
+  openstack_create_public_network: 'True'
   openstack_public_neutron_subnet_gateway: 172.17.16.1
   openstack_public_neutron_subnet_cidr: 172.17.16.0/24
   openstack_public_neutron_subnet_allocation_start: 172.17.16.201
diff --git a/tcp_tests/templates/cookied-cicd-queens-dvr-sl/environment_context.yaml b/tcp_tests/templates/cookied-cicd-queens-dvr-sl/environment_context.yaml
index 9b325ae..97e8520 100644
--- a/tcp_tests/templates/cookied-cicd-queens-dvr-sl/environment_context.yaml
+++ b/tcp_tests/templates/cookied-cicd-queens-dvr-sl/environment_context.yaml
@@ -4,6 +4,7 @@
       roles:
       - infra_config
       - linux_system_codename_xenial
+      - features_runtest
       classes:
       - environment.cookied-cicd-queens-dvr-sl.override_ntp_virtual
       interfaces: