Add tenant isolation for glance api tests

This commit adds isolated tenant support to the glance api tests. The
glance base test class is modified to call _get_isolated_creds() from
BaseTestCase if the isolated tenant config flag is set.

Change-Id: Ia22bd66006c010dcc4b57a6a6346b281086003d9
diff --git a/tempest/api/image/base.py b/tempest/api/image/base.py
index e27ec13..062d63e 100644
--- a/tempest/api/image/base.py
+++ b/tempest/api/image/base.py
@@ -28,11 +28,20 @@
 
     @classmethod
     def setUpClass(cls):
-        cls.os = clients.Manager()
+        cls.isolated_creds = []
         cls.created_images = []
+        cls._interface = 'json'
         if not cls.config.service_available.glance:
             skip_msg = ("%s skipped as glance is not available" % cls.__name__)
             raise cls.skipException(skip_msg)
+        if cls.config.compute.allow_tenant_isolation:
+            creds = cls._get_isolated_creds()
+            username, tenant_name, password = creds
+            cls.os = clients.Manager(username=username,
+                                     password=password,
+                                     tenant_name=tenant_name)
+        else:
+            cls.os = clients.Manager()
 
     @classmethod
     def tearDownClass(cls):
@@ -44,6 +53,7 @@
 
         for image_id in cls.created_images:
                 cls.client.wait_for_resource_deletion(image_id)
+        cls._clear_isolated_creds()
 
     @classmethod
     def create_image(cls, **kwargs):