Merge "Add VolumeClient for cleanup"
diff --git a/tempest/services/volume/json/admin/volume_hosts_client.py b/tempest/services/volume/json/admin/volume_hosts_client.py
index 10cb0be..e7add30 100644
--- a/tempest/services/volume/json/admin/volume_hosts_client.py
+++ b/tempest/services/volume/json/admin/volume_hosts_client.py
@@ -16,24 +16,14 @@
 import json
 import urllib
 
-from tempest.common import rest_client
-from tempest import config
-
-CONF = config.CONF
+from tempest.services.volume.json import base
 
 
-class BaseVolumeHostsClientJSON(rest_client.RestClient):
+class BaseVolumeHostsClientJSON(base.VolumeClient):
     """
     Client class to send CRUD Volume Hosts API requests to a Cinder endpoint
     """
 
-    def __init__(self, auth_provider):
-        super(BaseVolumeHostsClientJSON, self).__init__(auth_provider)
-
-        self.service = CONF.volume.catalog_type
-        self.build_interval = CONF.volume.build_interval
-        self.build_timeout = CONF.volume.build_timeout
-
     def list_hosts(self, params=None):
         """Lists all hosts."""
 
diff --git a/tempest/services/volume/json/admin/volume_quotas_client.py b/tempest/services/volume/json/admin/volume_quotas_client.py
index 5b49040..f08cb64 100644
--- a/tempest/services/volume/json/admin/volume_quotas_client.py
+++ b/tempest/services/volume/json/admin/volume_quotas_client.py
@@ -16,27 +16,17 @@
 
 import urllib
 
-from tempest.common import rest_client
-from tempest import config
 from tempest.openstack.common import jsonutils
-
-CONF = config.CONF
+from tempest.services.volume.json import base
 
 
-class BaseVolumeQuotasClientJSON(rest_client.RestClient):
+class BaseVolumeQuotasClientJSON(base.VolumeClient):
     """
     Client class to send CRUD Volume Quotas API requests to a Cinder endpoint
     """
 
     TYPE = "json"
 
-    def __init__(self, auth_provider):
-        super(BaseVolumeQuotasClientJSON, self).__init__(auth_provider)
-
-        self.service = CONF.volume.catalog_type
-        self.build_interval = CONF.volume.build_interval
-        self.build_timeout = CONF.volume.build_timeout
-
     def get_default_quota_set(self, tenant_id):
         """List the default volume quota set for a tenant."""
 
diff --git a/tempest/services/volume/json/admin/volume_services_client.py b/tempest/services/volume/json/admin/volume_services_client.py
index 88c6db0..5d4f9db 100644
--- a/tempest/services/volume/json/admin/volume_services_client.py
+++ b/tempest/services/volume/json/admin/volume_services_client.py
@@ -16,17 +16,10 @@
 import json
 import urllib
 
-from tempest.common import rest_client
-from tempest import config
-
-CONF = config.CONF
+from tempest.services.volume.json import base
 
 
-class BaseVolumesServicesClientJSON(rest_client.RestClient):
-
-    def __init__(self, auth_provider):
-        super(BaseVolumesServicesClientJSON, self).__init__(auth_provider)
-        self.service = CONF.volume.catalog_type
+class BaseVolumesServicesClientJSON(base.VolumeClient):
 
     def list_services(self, params=None):
         url = 'os-services'
diff --git a/tempest/services/volume/json/admin/volume_types_client.py b/tempest/services/volume/json/admin/volume_types_client.py
index eedf880..171ad35 100644
--- a/tempest/services/volume/json/admin/volume_types_client.py
+++ b/tempest/services/volume/json/admin/volume_types_client.py
@@ -16,25 +16,15 @@
 import json
 import urllib
 
-from tempest.common import rest_client
-from tempest import config
 from tempest import exceptions
-
-CONF = config.CONF
+from tempest.services.volume.json import base
 
 
-class BaseVolumeTypesClientJSON(rest_client.RestClient):
+class BaseVolumeTypesClientJSON(base.VolumeClient):
     """
     Client class to send CRUD Volume Types API requests to a Cinder endpoint
     """
 
-    def __init__(self, auth_provider):
-        super(BaseVolumeTypesClientJSON, self).__init__(auth_provider)
-
-        self.service = CONF.volume.catalog_type
-        self.build_interval = CONF.volume.build_interval
-        self.build_timeout = CONF.volume.build_timeout
-
     def is_resource_deleted(self, resource):
         # to use this method self.resource must be defined to respective value
         # Resource is a dictionary containing resource id and type
diff --git a/tempest/services/volume/json/availability_zone_client.py b/tempest/services/volume/json/availability_zone_client.py
index 5ad2287..9f2c570 100644
--- a/tempest/services/volume/json/availability_zone_client.py
+++ b/tempest/services/volume/json/availability_zone_client.py
@@ -15,18 +15,10 @@
 
 import json
 
-from tempest.common import rest_client
-from tempest import config
-
-CONF = config.CONF
+from tempest.services.volume.json import base
 
 
-class BaseVolumeAvailabilityZoneClientJSON(rest_client.RestClient):
-
-    def __init__(self, auth_provider):
-        super(BaseVolumeAvailabilityZoneClientJSON, self).__init__(
-            auth_provider)
-        self.service = CONF.volume.catalog_type
+class BaseVolumeAvailabilityZoneClientJSON(base.VolumeClient):
 
     def get_availability_zone_list(self):
         resp, body = self.get('os-availability-zone')
diff --git a/tempest/services/volume/json/backups_client.py b/tempest/services/volume/json/backups_client.py
index 51a017e..e2ba822 100644
--- a/tempest/services/volume/json/backups_client.py
+++ b/tempest/services/volume/json/backups_client.py
@@ -16,24 +16,15 @@
 import json
 import time
 
-from tempest.common import rest_client
-from tempest import config
 from tempest import exceptions
-
-CONF = config.CONF
+from tempest.services.volume.json import base
 
 
-class BaseBackupsClientJSON(rest_client.RestClient):
+class BaseBackupsClientJSON(base.VolumeClient):
     """
     Client class to send CRUD Volume backup API requests to a Cinder endpoint
     """
 
-    def __init__(self, auth_provider):
-        super(BaseBackupsClientJSON, self).__init__(auth_provider)
-        self.service = CONF.volume.catalog_type
-        self.build_interval = CONF.volume.build_interval
-        self.build_timeout = CONF.volume.build_timeout
-
     def create_backup(self, volume_id, container=None, name=None,
                       description=None):
         """Creates a backup of volume."""
diff --git a/tempest/services/volume/json/base.py b/tempest/services/volume/json/base.py
new file mode 100644
index 0000000..8bc2f93
--- /dev/null
+++ b/tempest/services/volume/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 VolumeClient(rest_client.RestClient):
+    """
+    Base volume client class
+    """
+
+    def __init__(self, auth_provider):
+        super(VolumeClient, self).__init__(auth_provider)
+        self.service = CONF.volume.catalog_type
+        self.build_interval = CONF.volume.build_interval
+        self.build_timeout = CONF.volume.build_timeout
diff --git a/tempest/services/volume/json/extensions_client.py b/tempest/services/volume/json/extensions_client.py
index c84b186..13b91c3 100644
--- a/tempest/services/volume/json/extensions_client.py
+++ b/tempest/services/volume/json/extensions_client.py
@@ -15,17 +15,10 @@
 
 import json
 
-from tempest.common import rest_client
-from tempest import config
-
-CONF = config.CONF
+from tempest.services.volume.json import base
 
 
-class BaseExtensionsClientJSON(rest_client.RestClient):
-
-    def __init__(self, auth_provider):
-        super(BaseExtensionsClientJSON, self).__init__(auth_provider)
-        self.service = CONF.volume.catalog_type
+class BaseExtensionsClientJSON(base.VolumeClient):
 
     def list_extensions(self):
         url = 'extensions'
diff --git a/tempest/services/volume/json/qos_client.py b/tempest/services/volume/json/qos_client.py
index b647bc7..9c13cac 100644
--- a/tempest/services/volume/json/qos_client.py
+++ b/tempest/services/volume/json/qos_client.py
@@ -15,22 +15,13 @@
 import json
 import time
 
-from tempest.common import rest_client
-from tempest import config
 from tempest import exceptions
-
-CONF = config.CONF
+from tempest.services.volume.json import base
 
 
-class BaseQosSpecsClientJSON(rest_client.RestClient):
+class BaseQosSpecsClientJSON(base.VolumeClient):
     """Client class to send CRUD QoS API requests"""
 
-    def __init__(self, auth_provider):
-        super(BaseQosSpecsClientJSON, self).__init__(auth_provider)
-        self.service = CONF.volume.catalog_type
-        self.build_interval = CONF.volume.build_interval
-        self.build_timeout = CONF.volume.build_timeout
-
     def is_resource_deleted(self, qos_id):
         try:
             self.get_qos(qos_id)
diff --git a/tempest/services/volume/json/snapshots_client.py b/tempest/services/volume/json/snapshots_client.py
index e9d5b83..349d1b0 100644
--- a/tempest/services/volume/json/snapshots_client.py
+++ b/tempest/services/volume/json/snapshots_client.py
@@ -14,26 +14,18 @@
 import time
 import urllib
 
-from tempest.common import rest_client
-from tempest import config
 from tempest import exceptions
 from tempest.openstack.common import log as logging
+from tempest.services.volume.json import base
 
-CONF = config.CONF
 
 LOG = logging.getLogger(__name__)
 
 
-class BaseSnapshotsClientJSON(rest_client.RestClient):
+class BaseSnapshotsClientJSON(base.VolumeClient):
     """Base Client class to send CRUD Volume API requests."""
 
-    def __init__(self, auth_provider):
-        super(BaseSnapshotsClientJSON, self).__init__(auth_provider)
-
-        self.service = CONF.volume.catalog_type
-        self.build_interval = CONF.volume.build_interval
-        self.build_timeout = CONF.volume.build_timeout
-        self.create_resp = 200
+    create_resp = 200
 
     def list_snapshots(self, params=None):
         """List all the snapshot."""
diff --git a/tempest/services/volume/json/volumes_client.py b/tempest/services/volume/json/volumes_client.py
index 1e49e5a..f19718e 100644
--- a/tempest/services/volume/json/volumes_client.py
+++ b/tempest/services/volume/json/volumes_client.py
@@ -17,25 +17,19 @@
 import time
 import urllib
 
-from tempest.common import rest_client
 from tempest import config
 from tempest import exceptions
+from tempest.services.volume.json import base
 
 CONF = config.CONF
 
 
-class BaseVolumesClientJSON(rest_client.RestClient):
+class BaseVolumesClientJSON(base.VolumeClient):
     """
     Base client class to send CRUD Volume API requests to a Cinder endpoint
     """
 
-    def __init__(self, auth_provider):
-        super(BaseVolumesClientJSON, self).__init__(auth_provider)
-
-        self.service = CONF.volume.catalog_type
-        self.build_interval = CONF.volume.build_interval
-        self.build_timeout = CONF.volume.build_timeout
-        self.create_resp = 200
+    create_resp = 200
 
     def get_attachment_from_volume(self, volume):
         """Return the element 'attachment' from input volumes."""