Add IdentityV3Client for cleanup

In identity v3 clients, there is a lot of duplicated code for
setting CONF. This patch adds IdentityV3Client for removing them.

Change-Id: Ib09342d7d831e8ac496efa0d799cd17af3c4a95f
diff --git a/tempest/services/identity/v3/json/base.py b/tempest/services/identity/v3/json/base.py
new file mode 100644
index 0000000..3df0dab
--- /dev/null
+++ b/tempest/services/identity/v3/json/base.py
@@ -0,0 +1,30 @@
+# Copyright 2014 NEC Corporation.  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.
+
+from tempest.common import rest_client
+from tempest import config
+
+CONF = config.CONF
+
+
+class IdentityV3Client(rest_client.RestClient):
+    """
+    Base identity v3 client class
+    """
+
+    def __init__(self, auth_provider):
+        super(IdentityV3Client, self).__init__(auth_provider)
+        self.service = CONF.identity.catalog_type
+        self.endpoint_url = 'adminURL'
+        self.api_version = "v3"
diff --git a/tempest/services/identity/v3/json/credentials_client.py b/tempest/services/identity/v3/json/credentials_client.py
index d424f4c..42acd2a 100644
--- a/tempest/services/identity/v3/json/credentials_client.py
+++ b/tempest/services/identity/v3/json/credentials_client.py
@@ -15,19 +15,10 @@
 
 import json
 
-from tempest.common import rest_client
-from tempest import config
-
-CONF = config.CONF
+from tempest.services.identity.v3.json import base
 
 
-class CredentialsClientJSON(rest_client.RestClient):
-
-    def __init__(self, auth_provider):
-        super(CredentialsClientJSON, self).__init__(auth_provider)
-        self.service = CONF.identity.catalog_type
-        self.endpoint_url = 'adminURL'
-        self.api_version = "v3"
+class CredentialsClientJSON(base.IdentityV3Client):
 
     def create_credential(self, access_key, secret_key, user_id, project_id):
         """Creates a credential."""
diff --git a/tempest/services/identity/v3/json/endpoints_client.py b/tempest/services/identity/v3/json/endpoints_client.py
index c3fedb2..9316a4b 100644
--- a/tempest/services/identity/v3/json/endpoints_client.py
+++ b/tempest/services/identity/v3/json/endpoints_client.py
@@ -15,19 +15,10 @@
 
 import json
 
-from tempest.common import rest_client
-from tempest import config
-
-CONF = config.CONF
+from tempest.services.identity.v3.json import base
 
 
-class EndPointClientJSON(rest_client.RestClient):
-
-    def __init__(self, auth_provider):
-        super(EndPointClientJSON, self).__init__(auth_provider)
-        self.service = CONF.identity.catalog_type
-        self.endpoint_url = 'adminURL'
-        self.api_version = "v3"
+class EndPointClientJSON(base.IdentityV3Client):
 
     def list_endpoints(self):
         """GET endpoints."""
diff --git a/tempest/services/identity/v3/json/identity_client.py b/tempest/services/identity/v3/json/identity_client.py
index 6ac4901..4c8d8df 100644
--- a/tempest/services/identity/v3/json/identity_client.py
+++ b/tempest/services/identity/v3/json/identity_client.py
@@ -19,17 +19,12 @@
 from tempest.common import rest_client
 from tempest import config
 from tempest import exceptions
+from tempest.services.identity.v3.json import base
 
 CONF = config.CONF
 
 
-class IdentityV3ClientJSON(rest_client.RestClient):
-
-    def __init__(self, auth_provider):
-        super(IdentityV3ClientJSON, self).__init__(auth_provider)
-        self.service = CONF.identity.catalog_type
-        self.endpoint_url = 'adminURL'
-        self.api_version = "v3"
+class IdentityV3ClientJSON(base.IdentityV3Client):
 
     def create_user(self, user_name, password=None, project_id=None,
                     email=None, domain_id='default', **kwargs):
diff --git a/tempest/services/identity/v3/json/policy_client.py b/tempest/services/identity/v3/json/policy_client.py
index 579243c..04374a2 100644
--- a/tempest/services/identity/v3/json/policy_client.py
+++ b/tempest/services/identity/v3/json/policy_client.py
@@ -16,18 +16,10 @@
 import json
 
 from tempest.common import rest_client
-from tempest import config
-
-CONF = config.CONF
+from tempest.services.identity.v3.json import base
 
 
-class PolicyClientJSON(rest_client.RestClient):
-
-    def __init__(self, auth_provider):
-        super(PolicyClientJSON, self).__init__(auth_provider)
-        self.service = CONF.identity.catalog_type
-        self.endpoint_url = 'adminURL'
-        self.api_version = "v3"
+class PolicyClientJSON(base.IdentityV3Client):
 
     def create_policy(self, blob, type):
         """Creates a Policy."""
diff --git a/tempest/services/identity/v3/json/region_client.py b/tempest/services/identity/v3/json/region_client.py
index becea6b..8545778 100644
--- a/tempest/services/identity/v3/json/region_client.py
+++ b/tempest/services/identity/v3/json/region_client.py
@@ -16,19 +16,10 @@
 import json
 import urllib
 
-from tempest.common import rest_client
-from tempest import config
-
-CONF = config.CONF
+from tempest.services.identity.v3.json import base
 
 
-class RegionClientJSON(rest_client.RestClient):
-
-    def __init__(self, auth_provider):
-        super(RegionClientJSON, self).__init__(auth_provider)
-        self.service = CONF.identity.catalog_type
-        self.endpoint_url = 'adminURL'
-        self.api_version = "v3"
+class RegionClientJSON(base.IdentityV3Client):
 
     def create_region(self, description, **kwargs):
         """Create region."""
diff --git a/tempest/services/identity/v3/json/service_client.py b/tempest/services/identity/v3/json/service_client.py
index 8e89957..b8b2556 100644
--- a/tempest/services/identity/v3/json/service_client.py
+++ b/tempest/services/identity/v3/json/service_client.py
@@ -15,19 +15,10 @@
 
 import json
 
-from tempest.common import rest_client
-from tempest import config
-
-CONF = config.CONF
+from tempest.services.identity.v3.json import base
 
 
-class ServiceClientJSON(rest_client.RestClient):
-
-    def __init__(self, auth_provider):
-        super(ServiceClientJSON, self).__init__(auth_provider)
-        self.service = CONF.identity.catalog_type
-        self.endpoint_url = 'adminURL'
-        self.api_version = "v3"
+class ServiceClientJSON(base.IdentityV3Client):
 
     def update_service(self, service_id, **kwargs):
         """Updates a service."""