Add test to check boot server in UEFI type

Related-Prod: PRODX-28483
Change-Id: I4a37ac6dae4f16ddfc2dec350a98479c40c0143a
(cherry picked from commit 2abc2cc6caef153026a3371b96ad1c88f7350a2e)
diff --git a/tempest/api/compute/admin/test_create_server.py b/tempest/api/compute/admin/test_create_server.py
index 293e284..5bc9206 100644
--- a/tempest/api/compute/admin/test_create_server.py
+++ b/tempest/api/compute/admin/test_create_server.py
@@ -136,3 +136,36 @@
             servers_client=self.client)
         disks_num_eph = len(linux_client.get_disks().split('\n'))
         self.assertEqual(disks_num + 1, disks_num_eph)
+
+
+class ServersTestUEFI(base.BaseV2ComputeAdminTest):
+    """Test creating server with UEFI firmware type"""
+
+    @classmethod
+    def setup_credentials(cls):
+        cls.prepare_instance_network()
+        super(ServersTestUEFI, cls).setup_credentials()
+
+    @classmethod
+    def setup_clients(cls):
+        super(ServersTestUEFI, cls).setup_clients()
+        cls.client = cls.servers_client
+
+    @decorators.idempotent_id('94feb6c3-d07e-b3b9-def8-64fd082d9b21')
+    def test_created_server_uefi(self):
+        # create custom image with uefi type
+        custom_img = self.create_image_with_custom_property(
+            hw_machine_type='q35',
+            hw_firmware_type='uefi',
+            )
+        # create the server and wait for it to become ready
+        validation_resources = self.get_class_validation_resources(
+            self.os_primary)
+        server = self.create_test_server(
+            image_id=custom_img, validatable=True,
+            validation_resources=validation_resources, wait_until='SSHABLE')
+        # check UEFI boot loader in console log server
+        uefi_boot_loader = "UEFI Misc Device"
+        console_log = self.client.get_console_output(server['id'])['output']
+        self.assertTrue(console_log, "Console output was empty.")
+        self.assertIn(uefi_boot_loader, console_log)
diff --git a/tempest/api/compute/admin/test_volume.py b/tempest/api/compute/admin/test_volume.py
index 2813d7a..dc631e5 100644
--- a/tempest/api/compute/admin/test_volume.py
+++ b/tempest/api/compute/admin/test_volume.py
@@ -37,46 +37,6 @@
         cls.prepare_instance_network()
         super(BaseAttachSCSIVolumeTest, cls).setup_credentials()
 
-    def _create_image_with_custom_property(self, **kwargs):
-        """Wrapper utility that returns the custom image.
-
-        Creates a new image by downloading the default image's bits and
-        uploading them to a new image. Any kwargs are set as image properties
-        on the new image.
-
-        :param return image_id: The UUID of the newly created image.
-        """
-        image = self.admin_image_client.show_image(CONF.compute.image_ref)
-        # NOTE(danms): We need to stream this, so chunked=True means we get
-        # back a urllib3.HTTPResponse and have to carefully pass it to
-        # store_image_file() to upload it in pieces.
-        image_data_resp = self.admin_image_client.show_image_file(
-            CONF.compute.image_ref, chunked=True)
-        create_dict = {
-            'container_format': image['container_format'],
-            'disk_format': image['disk_format'],
-            'min_disk': image['min_disk'],
-            'min_ram': image['min_ram'],
-            'visibility': 'public',
-        }
-        if 'kernel_id' in image:
-            create_dict['kernel_id'] = image['kernel_id']
-        if 'ramdisk_id' in image:
-            create_dict['ramdisk_id'] = image['ramdisk_id']
-
-        create_dict.update(kwargs)
-        try:
-            new_image = self.admin_image_client.create_image(**create_dict)
-            self.addCleanup(self.admin_image_client.wait_for_resource_deletion,
-                            new_image['id'])
-            self.addCleanup(
-                self.admin_image_client.delete_image, new_image['id'])
-            self.admin_image_client.store_image_file(new_image['id'],
-                                                     image_data_resp)
-        finally:
-            image_data_resp.release_conn()
-        return new_image['id']
-
 
 class AttachSCSIVolumeTestJSON(BaseAttachSCSIVolumeTest):
     """Test attaching scsi volume to server"""
@@ -90,7 +50,7 @@
         virtio-scsi mode with further asserting list volume attachments
         in instance after attach and detach of the volume.
         """
-        custom_img = self._create_image_with_custom_property(
+        custom_img = self.create_image_with_custom_property(
             hw_scsi_model='virtio-scsi',
             hw_disk_bus='scsi',
             hw_cdrom_bus='scsi')
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index 2557e47..313f73d 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -701,3 +701,37 @@
         for target_host in hosts:
             if source_host != target_host:
                 return target_host
+
+    def create_image_with_custom_property(self, base_image=None, **kwargs):
+        """Wrapper utility that returns the custom image.
+
+        Creates a new image by downloading the base image bits and
+        uploading them to a new image. Any kwargs are set as image properties
+        on the new image.
+
+        :param return image_id: The UUID of the newly created image.
+        """
+        if base_image is None:
+            base_image = CONF.compute.image_ref
+        image = self.admin_image_client.show_image(base_image)
+        image_data_resp = self.admin_image_client.show_image_file(
+            CONF.compute.image_ref, chunked=True)
+        create_dict = {
+            'container_format': image['container_format'],
+            'disk_format': image['disk_format'],
+            'min_disk': image['min_disk'],
+            'min_ram': image['min_ram'],
+            'visibility': 'public',
+        }
+        create_dict.update(kwargs)
+        try:
+            new_image = self.admin_image_client.create_image(**create_dict)
+            self.addCleanup(self.admin_image_client.wait_for_resource_deletion,
+                            new_image['id'])
+            self.addCleanup(
+                self.admin_image_client.delete_image, new_image['id'])
+            self.admin_image_client.store_image_file(new_image['id'],
+                                                     image_data_resp)
+        finally:
+            image_data_resp.release_conn()
+        return new_image['id']