Merge "Add tempest role if barbican integration enabled"
diff --git a/_modules/runtest/tempest_sections/base_section.py b/_modules/runtest/tempest_sections/base_section.py
index 867386f..5e2ea3a 100644
--- a/_modules/runtest/tempest_sections/base_section.py
+++ b/_modules/runtest/tempest_sections/base_section.py
@@ -47,22 +47,22 @@
     def authenticated_openstack_module_call(self, target, module, *args, **kwargs):
         """Calls specified openstack module from admin keystone user.
         """
-        auth_profile = {}
-        ks = conditions.BaseRule(field='keystone.server.enabled', op='eq', val=True)
-        auth_profile['connection_password'] = self.get_item_when_condition_match(
-            'keystone.server.admin_password', ks)
-        auth_profile['connection_user'] = self.get_item_when_condition_match(
-            'keystone.server.admin_name', ks)
-        auth_profile['connection_tenant'] = self.get_item_when_condition_match(
-            'keystone.server.admin_tenant', ks)
-        auth_profile['connection_region_name'] = self.get_item_when_condition_match(
-            'keystone.server.region', ks)
-        address = self.get_item_when_condition_match(
-            'keystone.server.bind.public_address', ks)
-        port = self.get_item_when_condition_match('keystone.server.bind.public_port', ks)
-        auth_profile['connection_auth_url'] = "http://{}:{}/v2.0".format(address, port)
+        if 'profile' not in kwargs:
+            auth_profile = {}
+            ks = conditions.BaseRule(field='keystone.server.enabled', op='eq', val=True)
+            auth_profile['connection_password'] = self.get_item_when_condition_match(
+                'keystone.server.admin_password', ks)
+            auth_profile['connection_user'] = self.get_item_when_condition_match(
+                'keystone.server.admin_name', ks)
+            auth_profile['connection_tenant'] = self.get_item_when_condition_match(
+                'keystone.server.admin_tenant', ks)
+            auth_profile['connection_region_name'] = self.get_item_when_condition_match(
+                'keystone.server.region', ks)
+            address = self.get_item_when_condition_match(
+                'keystone.server.bind.public_address', ks)
+            port = self.get_item_when_condition_match('keystone.server.bind.public_port', ks)
+            auth_profile['connection_auth_url'] = "http://{}:{}/v2.0".format(address, port)
+            kwargs.update(auth_profile)
 
-        kwargs.update(auth_profile)
-
-        return self.salt_client.cmd(target, 'neutronng.list_networks', timeout=5,
+        return self.salt_client.cmd(target, module, timeout=5,
                                     gather_job_timeout=15, arg=args, kwarg=kwargs)
diff --git a/_modules/runtest/tempest_sections/compute.py b/_modules/runtest/tempest_sections/compute.py
index 4d9ee33..7ae933e 100644
--- a/_modules/runtest/tempest_sections/compute.py
+++ b/_modules/runtest/tempest_sections/compute.py
@@ -1,6 +1,8 @@
 
 import base_section
 
+from runtest import conditions
+
 class Compute(base_section.BaseSection):
 
     name = "compute"
@@ -47,7 +49,19 @@
 
     @property
     def flavor_ref(self):
-        pass
+        c = conditions.BaseRule(field='keystone.client.enabled', op='eq',
+                                val=True)
+        nodes = self.get_nodes_where_condition_match(c)
+        flavor_name = self.runtest_opts.get('convert_to_uuid', {}).get('flavor_name')
+        if not flavor_name:
+            return
+
+        keystone_profile_admin = self.runtest_opts.get('keystone_profile_admin', {})
+        res = self.authenticated_openstack_module_call(
+            nodes[0], 'novang.flavor_list', profile=keystone_profile_admin)[nodes[0]]
+
+        if flavor_name in res:
+            return res[flavor_name]['id']
 
     @property
     def flavor_ref_alt(self):
@@ -59,7 +73,22 @@
 
     @property
     def image_ref(self):
-        pass
+        c = conditions.BaseRule(field='keystone.client.enabled', op='eq',
+                                val=True)
+        nodes = self.get_nodes_where_condition_match(c)
+        image_name = self.runtest_opts.get('convert_to_uuid', {}).get('image_name')
+        if not image_name:
+            return
+
+        keystone_profile_admin = self.runtest_opts.get('keystone_profile_admin', {})
+        res = self.authenticated_openstack_module_call(
+             nodes[0], 'glanceng.image_list', profile=keystone_profile_admin)[nodes[0]]
+        images = [n['id'] for n in res if n['name'] == image_name]
+
+        if len(images) != 1:
+            raise Exception("Error getting images: {}".format(images))
+
+        return images[0]
 
     @property
     def image_ref_alt(self):
diff --git a/_modules/runtest/tempest_sections/network.py b/_modules/runtest/tempest_sections/network.py
index 68d4fea..9b4aea0 100644
--- a/_modules/runtest/tempest_sections/network.py
+++ b/_modules/runtest/tempest_sections/network.py
@@ -84,14 +84,17 @@
         c = conditions.BaseRule(field='keystone.client.enabled', op='eq',
                                 val=True)
         nodes = self.get_nodes_where_condition_match(c)
-        network_name = self.runtest_opts.get(
-            'convert_to_uuid', {}).get('public_network_id')
+        runtest_enable = conditions.BaseRule('runtest.enabled', 'eq', True)
+        network_name = self.get_item_when_condition_match(
+            'runtest.tempest.convert_to_uuid.network.public_network_id',
+            runtest_enable)
 
         if not network_name:
           return
 
+        keystone_profile_admin = self.runtest_opts.get('keystone_profile_admin', {})
         res = self.authenticated_openstack_module_call(
-            nodes[0], 'neutronng.list_networks')[nodes[0]]['networks']
+            nodes[0], 'neutronng.list_networks', profile=keystone_profile_admin)[nodes[0]]['networks']
         networks = [n['id'] for n in res if n['name'] == network_name]
 
         if len(networks) != 1:
diff --git a/metadata/service/tempest/init.yml b/metadata/service/tempest/init.yml
index 7a23466..780c61f 100644
--- a/metadata/service/tempest/init.yml
+++ b/metadata/service/tempest/init.yml
@@ -19,11 +19,15 @@
     tempest:
       enabled: true
       test_target: ${_param:tempest_test_target}
+      keystone_profile_admin: admin_identity
+      convert_to_uuid:
+        image_name: ${glance:client:identity:admin_identity:image:cirros:name}
+        flavor_name: 'm1.extra_tiny_test'
       heat_plugin:
         skip_scenario_test_list: ${_param:runtest_heat_plugin_skip_scenario_test_list}
         skip_functional_test_list: ${_param:runtest_heat_plugin_skip_functional_test_list}
-        instance_type: 'm1.heat_int'
-        minimal_instance_type: 'm1.heat_micro'
+        instance_type: 'm1.tiny_test'
+        minimal_instance_type: 'm1.extra_tiny_test'
         auth_version: 3
         project_domain_id: default
         user_domain_id: default
diff --git a/metadata/service/tempest/nova.yml b/metadata/service/tempest/nova.yml
index fa727e3..0dce923 100644
--- a/metadata/service/tempest/nova.yml
+++ b/metadata/service/tempest/nova.yml
@@ -5,11 +5,11 @@
       server:
         admin_identity:
           flavor:
-            m1.heat_int:
+            m1.tiny_test:
               ram: 512
               disk: 5
               vcpus: 1
-            m1.heat_micro:
+            m1.extra_tiny_test:
               ram: 256
               disk: 1
               vcpus: 1
\ No newline at end of file