compute: Cleanup server before image in AttachSCSIVolumeTestJSON

This change simply reorders the cleanup operations within the
test_attach_scsi_disk_with_config_drive test to ensure the server is
always removed prior to the image.

This is required as when both Glance and Nova use a shared RBD backend
Nova will clone an instance disk directly from the Glance RBD volume.
This results in any attempt to delete the Glance image to fail while the
server is still provisioned as it still references the Glance RBD volume.

Change-Id: Ibcb1d1e3d1bb087060bcd0569a70c9955cd1357f
Closes-Bug: #1905725
diff --git a/tempest/api/compute/admin/test_volume.py b/tempest/api/compute/admin/test_volume.py
index 487337e..24e8a62 100644
--- a/tempest/api/compute/admin/test_volume.py
+++ b/tempest/api/compute/admin/test_volume.py
@@ -61,7 +61,6 @@
         }
         create_dict.update(kwargs)
         new_image = self.image_client.create_image(**create_dict)
-        self.addCleanup(self.image_client.delete_image, new_image['id'])
         self.image_client.store_image_file(new_image['id'], image_file)
 
         return new_image['id']
@@ -86,6 +85,12 @@
         server = self.create_test_server(image_id=custom_img,
                                          config_drive=True,
                                          wait_until='ACTIVE')
+
+        # NOTE(lyarwood): Add image cleanup *after* creating the instance to
+        # ensure the instance is deleted first. This avoids failures when using
+        # the rbd backend is used for both Glance and Nova ephemeral storage.
+        self.addCleanup(self.image_client.delete_image, custom_img)
+
         volume = self.create_volume()
         attachment = self.attach_volume(server, volume)
         waiters.wait_for_volume_resource_status(