Add XML support for test cases under identity admin.

So far test_service.py is not ready. Create_service, list_service and delete_service
in XML/admin_client.py are not working properly. It seems that Keystone does
not support XML for service API. A bug has been raised at
https://bugs.launchpad.net/keystone/+bug/1042144.
I have complied with the XML format as it described in
http://docs.rackspace.com/openstack-extensions/auth/OS-KSADM-admin-devguide/content/POST_addService_v2.0_OS-KSADM_services_Admin_API_Service_Developer_Operations-d1e1357.html

Change-Id: I60f72a0f99deff0bd8ee02bd2db5284d87481d5f
diff --git a/tempest/openstack.py b/tempest/openstack.py
index 89b7718..d9abb64 100644
--- a/tempest/openstack.py
+++ b/tempest/openstack.py
@@ -19,6 +19,10 @@
 
 from tempest import config
 from tempest import exceptions
+from tempest.services.identity.json.admin_client import AdminClientJSON
+from tempest.services.identity.json.admin_client import TokenClientJSON
+from tempest.services.identity.xml.admin_client import AdminClientXML
+from tempest.services.identity.xml.admin_client import TokenClientXML
 from tempest.services.image import service as image_service
 from tempest.services.network.json.network_client import NetworkClient
 from tempest.services.nova.json.extensions_client import ExtensionsClientJSON
@@ -48,6 +52,7 @@
 from tempest.services.volume.json.volumes_client import VolumesClientJSON
 from tempest.services.volume.xml.volumes_client import VolumesClientXML
 
+
 LOG = logging.getLogger(__name__)
 
 IMAGES_CLIENTS = {
@@ -96,6 +101,17 @@
 }
 
 
+ADMIN_CLIENT = {
+    "json": AdminClientJSON,
+    "xml": AdminClientXML,
+}
+
+TOKEN_CLIENT = {
+    "json": TokenClientJSON,
+    "xml": TokenClientXML,
+}
+
+
 class Manager(object):
 
     """
@@ -148,6 +164,8 @@
                     VOLUMES_EXTENSIONS_CLIENTS[interface](*client_args)
             self.floating_ips_client = FLOAT_CLIENTS[interface](*client_args)
             self.volumes_client = VOLUMES_CLIENTS[interface](*client_args)
+            self.admin_client = ADMIN_CLIENT[interface](*client_args)
+            self.token_client = TOKEN_CLIENT[interface](self.config)
         except KeyError:
             msg = "Unsupported interface type `%s'" % interface
             raise exceptions.InvalidConfiguration(msg)
@@ -196,3 +214,33 @@
         self.services = {}
         self.services['image'] = image_service.Service(self.config)
         self.images = self.services['image']
+
+
+class IdentityManager(Manager):
+
+    """
+    Manager object that uses the alt_XXX credentials for its
+    managed client objects
+    """
+
+    def __init__(self, interface='json'):
+        conf = config.TempestConfig()
+        super(IdentityManager, self).__init__(conf.identity_admin.username,
+                                         conf.identity_admin.password,
+                                         conf.identity_admin.tenant_name,
+                                         interface)
+
+
+class IdentityNaManager(Manager):
+
+    """
+    Manager object that uses the alt_XXX credentials for its
+    managed client objects
+    """
+
+    def __init__(self, interface='json'):
+        conf = config.TempestConfig()
+        super(IdentityNaManager, self).__init__(conf.compute.username,
+                                         conf.compute.password,
+                                         conf.compute.tenant_name,
+                                         interface)
diff --git a/tempest/services/identity/json/admin_client.py b/tempest/services/identity/json/admin_client.py
index cb9c10b..a42a690 100644
--- a/tempest/services/identity/json/admin_client.py
+++ b/tempest/services/identity/json/admin_client.py
@@ -4,10 +4,10 @@
 import json
 
 
-class AdminClient(RestClient):
+class AdminClientJSON(RestClient):
 
     def __init__(self, config, username, password, auth_url, tenant_name=None):
-        super(AdminClient, self).__init__(config, username, password,
+        super(AdminClientJSON, self).__init__(config, username, password,
                                                     auth_url, tenant_name)
         self.service = self.config.identity.catalog_type
         self.endpoint_url = 'adminURL'
@@ -204,7 +204,7 @@
         return self.delete(url)
 
 
-class TokenClient(RestClient):
+class TokenClientJSON(RestClient):
 
     def __init__(self, config):
         self.auth_url = config.identity.auth_url
diff --git a/tempest/services/identity/xml/__init__.py b/tempest/services/identity/xml/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tempest/services/identity/xml/__init__.py
diff --git a/tempest/services/identity/xml/admin_client.py b/tempest/services/identity/xml/admin_client.py
new file mode 100644
index 0000000..948c643
--- /dev/null
+++ b/tempest/services/identity/xml/admin_client.py
@@ -0,0 +1,267 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+#
+# Copyright 2012 IBM
+# All Rights Reserved.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+#    License for the specific language governing permissions and limitations
+#    under the License.
+
+import logging
+from lxml import etree
+from tempest.common.rest_client import RestClient
+from tempest.common.rest_client import RestClientXML
+from tempest.services.nova.xml.common import Document
+from tempest.services.nova.xml.common import Element
+from tempest.services.nova.xml.common import Text
+from tempest.services.nova.xml.common import xml_to_json
+from tempest import exceptions
+import httplib2
+import json
+
+XMLNS = "http://docs.openstack.org/identity/api/v2.0"
+
+
+class AdminClientXML(RestClientXML):
+
+    def __init__(self, config, username, password, auth_url, tenant_name=None):
+        super(AdminClientXML, self).__init__(config, username, password,
+                                                    auth_url, tenant_name)
+        self.service = self.config.identity.catalog_type
+        self.endpoint_url = 'adminURL'
+
+    def _parse_array(self, node):
+        array = []
+        for child in node.getchildren():
+            array.append(xml_to_json(child))
+        return array
+
+    def _parse_body(self, body):
+        json = xml_to_json(body)
+        return json
+
+    def has_admin_extensions(self):
+        """
+        Returns True if the KSADM Admin Extensions are supported
+        False otherwise
+        """
+        if hasattr(self, '_has_admin_extensions'):
+            return self._has_admin_extensions
+        resp, body = self.list_roles()
+        self._has_admin_extensions = ('status' in resp and resp.status != 503)
+        return self._has_admin_extensions
+
+    def create_role(self, name):
+        """Create a role"""
+        create_role = Element("role",
+                                xmlns=XMLNS,
+                                name=name)
+        resp, body = self.post('OS-KSADM/roles', str(Document(create_role)),
+                                      self.headers)
+        body = self._parse_body(etree.fromstring(body))
+        return resp, body
+
+    def create_tenant(self, name, **kwargs):
+        """
+        Create a tenant
+        name (required): New tenant name
+        description: Description of new tenant (default is none)
+        enabled <true|false>: Initial tenant status (default is true)
+        """
+        en = kwargs.get('enabled', 'true')
+        create_tenant = Element("tenant",
+                                xmlns=XMLNS,
+                                name=name,
+                                description=kwargs.get('description', ''),
+                                enabled=str(en).lower())
+        resp, body = self.post('tenants', str(Document(create_tenant)),
+                                      self.headers)
+        body = self._parse_body(etree.fromstring(body))
+        return resp, body
+
+    def delete_role(self, role_id):
+        """Delete a role"""
+        resp, body = self.delete('OS-KSADM/roles/%s' % str(role_id),
+                                 self.headers)
+        return resp, body
+
+    def list_user_roles(self, tenant_id, user_id):
+        """Returns a list of roles assigned to a user for a tenant"""
+        url = '/tenants/%s/users/%s/roles' % (tenant_id, user_id)
+        resp, body = self.get(url, self.headers)
+        body = self._parse_array(etree.fromstring(body))
+        return resp, body
+
+    def assign_user_role(self, tenant_id, user_id, role_id):
+        """Add roles to a user on a tenant"""
+        resp, body = self.put('/tenants/%s/users/%s/roles/OS-KSADM/%s'
+                                % (tenant_id, user_id, role_id),
+                                '', self.headers)
+        body = self._parse_body(etree.fromstring(body))
+        return resp, body
+
+    def remove_user_role(self, tenant_id, user_id, role_id):
+        """Removes a role assignment for a user on a tenant"""
+        return self.delete('/tenants/%s/users/%s/roles/OS-KSADM/%s'
+               % (tenant_id, user_id, role_id), self.headers)
+
+    def delete_tenant(self, tenant_id):
+        """Delete a tenant"""
+        resp, body = self.delete('tenants/%s' % str(tenant_id), self.headers)
+        return resp, body
+
+    def get_tenant(self, tenant_id):
+        """Get tenant details"""
+        resp, body = self.get('tenants/%s' % str(tenant_id), self.headers)
+        body = self._parse_body(etree.fromstring(body))
+        return resp, body
+
+    def list_roles(self):
+        """Returns roles"""
+        resp, body = self.get('OS-KSADM/roles', self.headers)
+        body = self._parse_array(etree.fromstring(body))
+        return resp, body
+
+    def list_tenants(self):
+        """Returns tenants"""
+        resp, body = self.get('tenants', self.headers)
+        body = self._parse_array(etree.fromstring(body))
+        return resp, body
+
+    def update_tenant(self, tenant_id, **kwargs):
+        """Updates a tenant"""
+        resp, body = self.get_tenant(tenant_id)
+        name = kwargs.get('name', body['name'])
+        desc = kwargs.get('description', body['description'])
+        en = kwargs.get('enabled', body['enabled'])
+        update_tenant = Element("tenant",
+                                xmlns=XMLNS,
+                                id=tenant_id,
+                                name=name,
+                                description=desc,
+                                enabled=str(en).lower())
+
+        resp, body = self.post('tenants/%s' % tenant_id,
+                               str(Document(update_tenant)),
+                               self.headers)
+        body = self._parse_body(etree.fromstring(body))
+        return resp, body
+
+    def create_user(self, name, password, tenant_id, email):
+        """Create a user"""
+        create_user = Element("user",
+                                xmlns=XMLNS,
+                                name=name,
+                                password=password,
+                                tenantId=tenant_id,
+                                email=email)
+        resp, body = self.post('users', str(Document(create_user)),
+                               self.headers)
+        body = self._parse_body(etree.fromstring(body))
+        return resp, body
+
+    def delete_user(self, user_id):
+        """Delete a user"""
+        resp, body = self.delete("users/%s" % user_id, self.headers)
+        return resp, body
+
+    def get_users(self):
+        """Get the list of users"""
+        resp, body = self.get("users", self.headers)
+        body = self._parse_array(etree.fromstring(body))
+        return resp, body
+
+    def enable_disable_user(self, user_id, enabled):
+        """Enables or disables a user"""
+        enable_user = Element("user",
+                                enabled=str(enabled).lower())
+        resp, body = self.put('users/%s/enabled' % user_id,
+                str(Document(enable_user)), self.headers)
+        body = self._parse_array(etree.fromstring(body))
+        return resp, body
+
+    def delete_token(self, token_id):
+        """Delete a token"""
+        resp, body = self.delete("tokens/%s" % token_id, self.headers)
+        return resp, body
+
+    def list_users_for_tenant(self, tenant_id):
+        """List users for a Tenant"""
+        resp, body = self.get('/tenants/%s/users' % tenant_id, self.headers)
+        body = self._parse_array(etree.fromstring(body))
+        return resp, body
+
+    def create_service(self, name, type, **kwargs):
+        """Create a service"""
+        OS_KSADM = "http://docs.openstack.org/identity/api/ext/OS-KSADM/v1.0"
+        create_service = Element("service",
+                                xmlns=OS_KSADM,
+                                name=name,
+                                type=type,
+                                description=kwargs.get('description'))
+        resp, body = self.post('OS-KSADM/services',
+                               str(Document(create_service)),
+                                    self.headers)
+        body = self._parse_body(etree.fromstring(body))
+        return resp, body
+
+    def get_service(self, service_id):
+        """Get Service"""
+        url = '/OS-KSADM/services/%s' % service_id
+        resp, body = self.get(url, self.headers)
+        body = self._parse_body(etree.fromstring(body))
+        return resp, body
+
+    def delete_service(self, service_id):
+        """Delete Service"""
+        url = '/OS-KSADM/services/%s' % service_id
+        return self.delete(url, self.headers)
+
+
+class TokenClientXML(RestClientXML):
+
+    def __init__(self, config):
+        self.auth_url = config.identity.auth_url
+
+    def auth(self, user, password, tenant):
+        passwordCreds = Element("passwordCredentials",
+                         username=user,
+                         password=password)
+        auth = Element("auth",
+                                tenantName=tenant)
+        auth.append(passwordCreds)
+        headers = {'Content-Type': 'application/xml'}
+        resp, body = self.post(self.auth_url, headers=headers,
+                               body=str(Document(auth)))
+        return resp, body
+
+    def request(self, method, url, headers=None, body=None):
+        """A simple HTTP request interface."""
+        self.http_obj = httplib2.Http()
+        if headers == None:
+            headers = {}
+
+        resp, resp_body = self.http_obj.request(url, method,
+                                                headers=headers, body=body)
+
+        if resp.status in (401, 403):
+            resp_body = json.loads(resp_body)
+            raise exceptions.Unauthorized(resp_body['error']['message'])
+
+        return resp, resp_body
+
+    def get_token(self, user, password, tenant):
+        resp, body = self.auth(user, password, tenant)
+        if resp['status'] != '202':
+            body = json.loads(body)
+            access = body['access']
+            token = access['token']
+            return token['id']
diff --git a/tempest/tests/compute/base.py b/tempest/tests/compute/base.py
index ee3bf9e..f36c8f2 100644
--- a/tempest/tests/compute/base.py
+++ b/tempest/tests/compute/base.py
@@ -26,7 +26,6 @@
 from tempest import openstack
 from tempest import exceptions
 from tempest.common.utils.data_utils import rand_name
-from tempest.services.identity.json.admin_client import AdminClient
 
 __all__ = ['BaseComputeTest', 'BaseComputeTestJSON', 'BaseComputeTestXML',
            'BaseComputeAdminTestJSON', 'BaseComputeAdminTestXML']
@@ -79,12 +78,8 @@
         """
         Returns an instance of the Identity Admin API client
         """
-        client_args = (cls.config,
-                       cls.config.identity_admin.username,
-                       cls.config.identity_admin.password,
-                       cls.config.identity.auth_url)
-        tenant_name = cls.config.identity_admin.tenant_name
-        admin_client = AdminClient(*client_args, tenant_name=tenant_name)
+        os = openstack.IdentityManager(interface=cls._interface)
+        admin_client = os.admin_client
         return admin_client
 
     @classmethod
diff --git a/tempest/tests/identity/admin/test_roles.py b/tempest/tests/identity/admin/test_roles.py
index 813f64a..e0b180b 100644
--- a/tempest/tests/identity/admin/test_roles.py
+++ b/tempest/tests/identity/admin/test_roles.py
@@ -19,14 +19,13 @@
 
 from tempest import exceptions
 from tempest.common.utils.data_utils import rand_name
-from tempest.tests.identity.base import BaseIdentityAdminTest
+from tempest.tests.identity import base
 
 
-class RolesTest(BaseIdentityAdminTest):
+class RolesTestBase(object):
 
-    @classmethod
+    @staticmethod
     def setUpClass(cls):
-        super(RolesTest, cls).setUpClass()
 
         for _ in xrange(5):
             resp, role = cls.client.create_role(rand_name('role-'))
@@ -101,11 +100,25 @@
         self.client.delete_role(role1_id)
 
 
-class UserRolesTest(RolesTest):
+class RolesTestJSON(base.BaseIdentityAdminTestJSON,
+                    RolesTestBase):
 
     @classmethod
     def setUpClass(cls):
-        super(UserRolesTest, cls).setUpClass()
+        super(RolesTestJSON, cls).setUpClass()
+        RolesTestBase.setUpClass(cls)
+
+
+class RolesTestXML(base.BaseIdentityAdminTestXML,
+                   RolesTestBase):
+
+    @classmethod
+    def setUpClass(cls):
+        super(RolesTestXML, cls).setUpClass()
+        RolesTestBase.setUpClass(cls)
+
+
+class UserRolesTestBase(RolesTestBase):
 
     def test_assign_user_role(self):
         """Assign a role to a user on a tenant"""
@@ -249,3 +262,19 @@
         (user, tenant, role) = self._get_role_params()
         self.assertRaises(exceptions.NotFound, self.client.list_user_roles,
         tenant['id'], 'junk-role-aabbcc11')
+
+
+class UserRolesTestJSON(RolesTestJSON,
+                        UserRolesTestBase):
+
+    @classmethod
+    def setUpClass(cls):
+        super(UserRolesTestJSON, cls).setUpClass()
+
+
+class UserRolesTestXML(RolesTestXML,
+                        UserRolesTestBase):
+
+    @classmethod
+    def setUpClass(cls):
+        super(UserRolesTestXML, cls).setUpClass()
diff --git a/tempest/tests/identity/admin/test_services.py b/tempest/tests/identity/admin/test_services.py
index d107a6e..fa4178a 100644
--- a/tempest/tests/identity/admin/test_services.py
+++ b/tempest/tests/identity/admin/test_services.py
@@ -20,10 +20,10 @@
 
 from tempest import exceptions
 from tempest.common.utils.data_utils import rand_name
-from tempest.tests.identity.base import BaseIdentityAdminTest
+from tempest.tests.identity import base
 
 
-class ServicesTest(BaseIdentityAdminTest):
+class ServicesTestBase(object):
 
     def test_create_get_delete_service(self):
         """GET Service"""
@@ -64,3 +64,17 @@
             #Checking whether service is deleted successfully
             self.assertRaises(exceptions.NotFound, self.client.get_service,
                               service_data['id'])
+
+
+class ServicesTestJSON(base.BaseIdentityAdminTestJSON,
+                      ServicesTestBase):
+    @classmethod
+    def setUpClass(cls):
+        super(ServicesTestJSON, cls).setUpClass()
+
+
+class ServicesTestXML(base.BaseIdentityAdminTestXML,
+                      ServicesTestBase):
+    @classmethod
+    def setUpClass(cls):
+        super(ServicesTestXML, cls).setUpClass()
diff --git a/tempest/tests/identity/admin/test_tenants.py b/tempest/tests/identity/admin/test_tenants.py
index 253e52e..d8b6c33 100644
--- a/tempest/tests/identity/admin/test_tenants.py
+++ b/tempest/tests/identity/admin/test_tenants.py
@@ -19,15 +19,13 @@
 
 from tempest import exceptions
 from tempest.common.utils.data_utils import rand_name
-from tempest.tests.identity.base import BaseIdentityAdminTest
+from tempest.tests.identity import base
 
 
-class TenantsTest(BaseIdentityAdminTest):
+class TenantsTestBase(object):
 
-    @classmethod
+    @staticmethod
     def setUpClass(cls):
-        super(TenantsTest, cls).setUpClass()
-
         for _ in xrange(5):
             resp, tenant = cls.client.create_tenant(rand_name('tenant-'))
             cls.data.tenants.append(tenant)
@@ -133,10 +131,12 @@
         st1 = resp['status']
         en1 = body['enabled']
         self.assertTrue(st1.startswith('2'))
-        self.assertFalse(en1, 'Enable should be False in response')
+        self.assertEqual('false', str(en1).lower(),
+                         'Enable should be False in response')
         resp, body = self.client.get_tenant(tenant_id)
         en2 = body['enabled']
-        self.assertFalse(en2, 'Enable should be False in lookup')
+        self.assertEqual('false', str(en2).lower(),
+                         'Enable should be False in lookup')
         self.client.delete_tenant(tenant_id)
 
     def test_tenant_create_duplicate(self):
@@ -246,7 +246,25 @@
         resp3_en = body['enabled']
 
         self.assertNotEqual(resp1_en, resp3_en)
-        self.assertEqual(t_en, resp1_en)
+        self.assertEqual('false', str(resp1_en).lower())
         self.assertEqual(resp2_en, resp3_en)
 
         self.client.delete_tenant(t_id)
+
+
+class TenantsTestJSON(base.BaseIdentityAdminTestJSON,
+                      TenantsTestBase):
+
+    @classmethod
+    def setUpClass(cls):
+        super(TenantsTestJSON, cls).setUpClass()
+        TenantsTestBase.setUpClass(cls)
+
+
+class TenantsTestXML(base.BaseIdentityAdminTestXML,
+                      TenantsTestBase):
+
+    @classmethod
+    def setUpClass(cls):
+        super(TenantsTestXML, cls).setUpClass()
+        TenantsTestBase.setUpClass(cls)
diff --git a/tempest/tests/identity/admin/test_users.py b/tempest/tests/identity/admin/test_users.py
index 1e1b752..07c032e 100644
--- a/tempest/tests/identity/admin/test_users.py
+++ b/tempest/tests/identity/admin/test_users.py
@@ -20,10 +20,10 @@
 
 from tempest import exceptions
 from tempest.common.utils.data_utils import rand_name
-from tempest.tests.identity.base import BaseIdentityAdminTest
+from tempest.tests.identity import base
 
 
-class UsersTest(BaseIdentityAdminTest):
+class UsersTestBase(object):
 
     alt_user = rand_name('test_user_')
     alt_password = rand_name('pass_')
@@ -331,3 +331,17 @@
         if len(fail) != 0:
             self.fail('Should raise Not Found when list users with invalid'
                           'tenant ids %s' % fail)
+
+
+class UsersTestJSON(base.BaseIdentityAdminTestJSON,
+                    UsersTestBase):
+    @classmethod
+    def setUpClass(cls):
+        super(UsersTestJSON, cls).setUpClass()
+
+
+class UsersTestXML(base.BaseIdentityAdminTestXML,
+                    UsersTestBase):
+    @classmethod
+    def setUpClass(cls):
+        super(UsersTestXML, cls).setUpClass()
diff --git a/tempest/tests/identity/base.py b/tempest/tests/identity/base.py
index 60037ca..f397a5b 100644
--- a/tempest/tests/identity/base.py
+++ b/tempest/tests/identity/base.py
@@ -18,50 +18,25 @@
 import nose
 import unittest2 as unittest
 
-import tempest.config
 from tempest.common.utils.data_utils import rand_name
-from tempest.services.identity.json.admin_client import AdminClient
-from tempest.services.identity.json.admin_client import TokenClient
+from tempest import openstack
 
 
-class BaseIdentityAdminTest(unittest.TestCase):
+class BaseIdAdminTest(unittest.TestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.config = tempest.config.TempestConfig()
-        cls.username = cls.config.identity_admin.username
-        cls.password = cls.config.identity_admin.password
-        cls.tenant_name = cls.config.identity_admin.tenant_name
-
-        if not (cls.username
-                and cls.password
-                and cls.tenant_name):
-            raise nose.SkipTest("Missing Admin credentials in configuration")
-
-        client_args = (cls.config,
-                       cls.username,
-                       cls.password,
-                       cls.config.identity.auth_url)
-        cls.client = AdminClient(*client_args, tenant_name=cls.tenant_name)
-        cls.token_client = TokenClient(cls.config)
+        os = openstack.IdentityManager(interface=cls._interface)
+        cls.client = os.admin_client
+        cls.token_client = os.token_client
 
         if not cls.client.has_admin_extensions():
             raise nose.SkipTest("Admin extensions disabled")
 
         cls.data = DataGenerator(cls.client)
 
-        # Create an admin client with regular Compute API credentials. This
-        # client is used in tests to validate Unauthorized is returned
-        # for non-admin users accessing Identity Admin API commands
-        cls.na_username = cls.config.compute.username
-        cls.na_password = cls.config.compute.password
-        cls.na_tenant_name = cls.config.compute.tenant_name
-        na_client_args = (cls.config,
-                       cls.na_username,
-                       cls.na_password,
-                       cls.config.identity.auth_url)
-        cls.non_admin_client = AdminClient(*na_client_args,
-                                           tenant_name=cls.na_tenant_name)
+        os = openstack.IdentityNaManager(interface=cls._interface)
+        cls.non_admin_client = os.admin_client
 
     @classmethod
     def tearDownClass(cls):
@@ -94,6 +69,22 @@
             return role[0]
 
 
+class BaseIdentityAdminTestJSON(BaseIdAdminTest):
+    @classmethod
+    def setUpClass(cls):
+        cls._interface = "json"
+        super(BaseIdentityAdminTestJSON, cls).setUpClass()
+
+BaseIdentityAdminTest = BaseIdentityAdminTestJSON
+
+
+class BaseIdentityAdminTestXML(BaseIdAdminTest):
+    @classmethod
+    def setUpClass(cls):
+        cls._interface = "xml"
+        super(BaseIdentityAdminTestXML, cls).setUpClass()
+
+
 class DataGenerator(object):
 
         def __init__(self, client):
diff --git a/tempest/tests/volume/base.py b/tempest/tests/volume/base.py
index 4862404..c150395 100644
--- a/tempest/tests/volume/base.py
+++ b/tempest/tests/volume/base.py
@@ -24,7 +24,6 @@
 from tempest import config
 from tempest import openstack
 from tempest.common.utils.data_utils import rand_name
-from tempest.services.identity.json.admin_client import AdminClient
 from tempest import exceptions
 
 LOG = logging.getLogger(__name__)
@@ -70,13 +69,8 @@
         """
         Returns an instance of the Identity Admin API client
         """
-        client_args = (cls.config,
-                       cls.config.identity_admin.username,
-                       cls.config.identity_admin.password,
-                       cls.config.identity.auth_url)
-        tenant_name = cls.config.identity_admin.tenant_name
-        admin_client = AdminClient(*client_args, tenant_name=tenant_name)
-        return admin_client
+        os = openstack.IdentityManager()
+        return os.admin_client
 
     @classmethod
     def _get_isolated_creds(cls):