Merge "Add ability to generate required parameters for manila in tempest conf"
diff --git a/_modules/runtest/tempest_sections/share.py b/_modules/runtest/tempest_sections/share.py
index a7e8b96..339c599 100644
--- a/_modules/runtest/tempest_sections/share.py
+++ b/_modules/runtest/tempest_sections/share.py
@@ -226,6 +226,9 @@
         'run_quota_tests',
         'suppress_errors_in_cleanup',
         'share_creation_retry_number',
+        'client_vm_flavor_ref',
+        'image_with_share_tools',
+        'image_password',
     ]
 
     @property
@@ -442,3 +445,53 @@
     def suppress_errors_in_cleanup(self):
         if conditions.BaseRule('manila.api.enabled', 'eq', True):
             return False
+
+    # Defines client vm flavor reference.
+    @property
+    def client_vm_flavor_ref(self):
+        if conditions.BaseRule('manila.api.enabled', 'eq', True):
+            c = conditions.BaseRule('keystone.client.enabled', 'eq', True)
+            nodes = self.get_nodes_where_condition_match(c)
+            flavor_name = self.runtest_opts.get('convert_to_uuid', {}).get(
+                'compute', {}).get('flavor_ref_alt')
+            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']
+
+    # Defines name of image with share tools.
+    @property
+    def image_with_share_tools(self):
+        if conditions.BaseRule('manila.api.enabled', 'eq', True):
+            c = conditions.BaseRule('keystone.client.enabled', 'eq', True)
+            nodes = self.get_nodes_where_condition_match(c)
+            image_name = self.runtest_opts.get('convert_to_uuid', {}).get(
+                'compute', {}).get('image_ref_nfs')
+            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]]
+
+            for item in res:
+                if item['name'] == image_name:
+                    return item['name']
+
+    # Defines password for image with share tools.
+    @property
+    def image_password(self):
+        if conditions.BaseRule('manila.api.enabled', 'eq', True):
+            image_name = self.runtest_opts.get('convert_to_uuid', {}).get(
+                'compute', {}).get('image_ref_nfs')
+            if not image_name:
+                return
+
+            image_map = {'manila-service-image-master': 'manila'}
+
+            return image_map.get(image_name)
diff --git a/metadata/service/tempest/init.yml b/metadata/service/tempest/init.yml
index 7582e5b..5f38c3f 100644
--- a/metadata/service/tempest/init.yml
+++ b/metadata/service/tempest/init.yml
@@ -9,8 +9,10 @@
   _param:
     glance_image_cirros_name: 'TestCirros-0.3.5'
     glance_image_fedora_name: 'TestFedora-27-1.6'
+    glance_image_manila_name: 'manila-service-image-master'
     glance_image_cirros_location: 'http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img'
     glance_image_fedora_location: 'https://mirror.chpc.utah.edu/pub/fedora/linux/releases/27/CloudImages/x86_64/images/Fedora-Cloud-Base-27-1.6.x86_64.qcow2'
+    glance_image_manila_location: 'http://tarballs.openstack.org/manila-image-elements/images/manila-service-image-master.qcow2'
     runtest_heat_plugin_skip_scenario_test_list: 'SoftwareConfigIntegrationTest, VolumeBackupRestoreIntegrationTest, AodhAlarmTest'
     # VolumeBackupRestoreIntegrationTest : we don't use volume backup in our default configuration.
     # AodhAlarmTest : we don't have aodh endpoint because of have't telemetry on default configuration.
@@ -62,6 +64,7 @@
           flavor_ref: 'm1.extra_tiny_test'
           flavor_ref_alt: 'm1.tiny_test'
           image_ref_alt: ${_param:glance_image_cirros_name}
+          image_ref_nfs: ${_param:glance_image_manila_name}
         network:
           public_network_id: ${_param:runtest_tempest_public_net}
       cfg_dir: ${_param:runtest_tempest_cfg_dir}