Cleanup images properly

Images weren't deleted properly due to bad request sent to
glance API. Also ImageService ignored 'next' parameter returned from
glance API when listing images which is required when more images
are present.

The fix lists all images properly. If 'next' parameter is present
in the glance API response then the API is asked to send next part
of image list.

Closes-Bug: 1866988
Change-Id: I9ebeccb545576e43ef0fc96c29169ae16f261f34
diff --git a/tempest/cmd/cleanup_service.py b/tempest/cmd/cleanup_service.py
index 2b35ebf..a1e02e7 100644
--- a/tempest/cmd/cleanup_service.py
+++ b/tempest/cmd/cleanup_service.py
@@ -13,6 +13,7 @@
 #    under the License.
 
 from oslo_log import log as logging
+from six.moves.urllib import parse as urllib
 
 from tempest import clients
 from tempest.common import credentials_factory as credentials
@@ -814,7 +815,15 @@
 
     def list(self):
         client = self.client
-        images = client.list_images(params={"all_tenants": True})['images']
+        response = client.list_images()
+        images = []
+        images.extend(response['images'])
+        while 'next' in response:
+            parsed = urllib.urlparse(response['next'])
+            marker = urllib.parse_qs(parsed.query)['marker'][0]
+            response = client.list_images(params={"marker": marker})
+            images.extend(response['images'])
+
         if not self.is_save_state:
             images = [image for image in images if image['id']
                       not in self.saved_state_json['images'].keys()]