workaround: Wait for instance.host=None when shelving

There is a race in Nova where an instance being shelved is set to the
SHELVED_OFFLOADED vm_state before the instance.host is cleared. It
appears to be non-trivial to fix given the comments in that code
explictly say the updates have the be in that order.

This works around the issue by waiting until the instance.host is None
before considering the shelve offload to be completed.

Related-Bug: #2045785

Change-Id: Ia45247a7aa14eb5f0038d4512a0b4ebe6af5a573
diff --git a/tempest/api/compute/admin/test_servers_on_multinodes.py b/tempest/api/compute/admin/test_servers_on_multinodes.py
index b5ee9b1..c5d5b19 100644
--- a/tempest/api/compute/admin/test_servers_on_multinodes.py
+++ b/tempest/api/compute/admin/test_servers_on_multinodes.py
@@ -150,6 +150,15 @@
         compute.shelve_server(self.servers_client, server['id'],
                               force_shelve_offload=True)
 
+        # Work around https://bugs.launchpad.net/nova/+bug/2045785
+        # This can be removed when ^ is fixed.
+        def _check_server_host_is_none():
+            server_details = self.os_admin.servers_client.show_server(
+                server['id'])
+            self.assertIsNone(server_details['server']['OS-EXT-SRV-ATTR:host'])
+
+        self.wait_for(_check_server_host_is_none)
+
         self.os_admin.servers_client.unshelve_server(
             server['id'],
             body={'unshelve': {'host': host}}