Add image_ref

Co-Authored-By: Alina Nesterova <anesterova@mirantis.com>
Change-Id: Ibeb04f49a9efdf6f3091bf8ebba1b6a7317e59fb
diff --git a/_modules/runtest/tempest_sections/compute.py b/_modules/runtest/tempest_sections/compute.py
index 4d9ee33..9582559 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"
@@ -59,7 +61,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/metadata/service/tempest/init.yml b/metadata/service/tempest/init.yml
index 1291359..793557a 100644
--- a/metadata/service/tempest/init.yml
+++ b/metadata/service/tempest/init.yml
@@ -20,6 +20,8 @@
       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}
       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}