Merge "Enable H302 check (tempest/services/volume)"
diff --git a/tempest/services/volume/json/admin/volume_hosts_client.py b/tempest/services/volume/json/admin/volume_hosts_client.py
index 6efb258..84e4705 100644
--- a/tempest/services/volume/json/admin/volume_hosts_client.py
+++ b/tempest/services/volume/json/admin/volume_hosts_client.py
@@ -16,13 +16,13 @@
 import json
 import urllib
 
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
 from tempest import config
 
 CONF = config.CONF
 
 
-class VolumeHostsClientJSON(RestClient):
+class VolumeHostsClientJSON(rest_client.RestClient):
     """
     Client class to send CRUD Volume Hosts API requests to a Cinder endpoint
     """
diff --git a/tempest/services/volume/json/admin/volume_types_client.py b/tempest/services/volume/json/admin/volume_types_client.py
index 0d50524..5554362 100644
--- a/tempest/services/volume/json/admin/volume_types_client.py
+++ b/tempest/services/volume/json/admin/volume_types_client.py
@@ -16,13 +16,13 @@
 import json
 import urllib
 
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
 from tempest import config
 
 CONF = config.CONF
 
 
-class VolumeTypesClientJSON(RestClient):
+class VolumeTypesClientJSON(rest_client.RestClient):
     """
     Client class to send CRUD Volume Types API requests to a Cinder endpoint
     """
diff --git a/tempest/services/volume/json/extensions_client.py b/tempest/services/volume/json/extensions_client.py
index 257b7c8..9e182ea 100644
--- a/tempest/services/volume/json/extensions_client.py
+++ b/tempest/services/volume/json/extensions_client.py
@@ -15,13 +15,13 @@
 
 import json
 
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
 from tempest import config
 
 CONF = config.CONF
 
 
-class ExtensionsClientJSON(RestClient):
+class ExtensionsClientJSON(rest_client.RestClient):
 
     def __init__(self, auth_provider):
         super(ExtensionsClientJSON, self).__init__(auth_provider)
diff --git a/tempest/services/volume/json/snapshots_client.py b/tempest/services/volume/json/snapshots_client.py
index ba33c49..2dff63d 100644
--- a/tempest/services/volume/json/snapshots_client.py
+++ b/tempest/services/volume/json/snapshots_client.py
@@ -14,7 +14,7 @@
 import time
 import urllib
 
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
 from tempest import config
 from tempest import exceptions
 from tempest.openstack.common import log as logging
@@ -24,7 +24,7 @@
 LOG = logging.getLogger(__name__)
 
 
-class SnapshotsClientJSON(RestClient):
+class SnapshotsClientJSON(rest_client.RestClient):
     """Client class to send CRUD Volume API requests."""
 
     def __init__(self, auth_provider):
diff --git a/tempest/services/volume/json/volumes_client.py b/tempest/services/volume/json/volumes_client.py
index 2183c56..e4d2e8d 100644
--- a/tempest/services/volume/json/volumes_client.py
+++ b/tempest/services/volume/json/volumes_client.py
@@ -17,14 +17,14 @@
 import time
 import urllib
 
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
 from tempest import config
 from tempest import exceptions
 
 CONF = config.CONF
 
 
-class VolumesClientJSON(RestClient):
+class VolumesClientJSON(rest_client.RestClient):
     """
     Client class to send CRUD Volume API requests to a Cinder endpoint
     """
diff --git a/tempest/services/volume/v2/json/volumes_client.py b/tempest/services/volume/v2/json/volumes_client.py
index bd98402..5bfa75f 100644
--- a/tempest/services/volume/v2/json/volumes_client.py
+++ b/tempest/services/volume/v2/json/volumes_client.py
@@ -17,14 +17,14 @@
 import time
 import urllib
 
-from tempest.common.rest_client import RestClient
+from tempest.common import rest_client
 from tempest import config
 from tempest import exceptions
 
 CONF = config.CONF
 
 
-class VolumesV2ClientJSON(RestClient):
+class VolumesV2ClientJSON(rest_client.RestClient):
     """
     Client class to send CRUD Volume V2 API requests to a Cinder endpoint
     """
diff --git a/tempest/services/volume/v2/xml/volumes_client.py b/tempest/services/volume/v2/xml/volumes_client.py
index bc57842..0b8f47c 100644
--- a/tempest/services/volume/v2/xml/volumes_client.py
+++ b/tempest/services/volume/v2/xml/volumes_client.py
@@ -21,11 +21,7 @@
 from tempest.common import rest_client
 from tempest import config
 from tempest import exceptions
-from tempest.services.compute.xml.common import Document
-from tempest.services.compute.xml.common import Element
-from tempest.services.compute.xml.common import Text
-from tempest.services.compute.xml.common import xml_to_json
-from tempest.services.compute.xml.common import XMLNS_11
+from tempest.services.compute.xml import common
 
 CONF = config.CONF
 
@@ -56,7 +52,7 @@
                                        meta.text) for meta in
                                        child.getchildren())
             else:
-                vol[tag] = xml_to_json(child)
+                vol[tag] = common.xml_to_json(child)
         return vol
 
     def get_attachment_from_volume(self, volume):
@@ -134,15 +130,15 @@
                          image
         """
         # NOTE(afazekas): it should use a volume namespace
-        volume = Element("volume", xmlns=XMLNS_11, size=size)
+        volume = common.Element("volume", xmlns=common.XMLNS_11, size=size)
 
         if 'metadata' in kwargs:
-            _metadata = Element('metadata')
+            _metadata = common.Element('metadata')
             volume.append(_metadata)
             for key, value in kwargs['metadata'].items():
-                meta = Element('meta')
+                meta = common.Element('meta')
                 meta.add_attr('key', key)
-                meta.append(Text(value))
+                meta.append(common.Text(value))
                 _metadata.append(meta)
             attr_to_add = kwargs.copy()
             del attr_to_add['metadata']
@@ -152,17 +148,17 @@
         for key, value in attr_to_add.items():
             volume.add_attr(key, value)
 
-        resp, body = self.post('volumes', str(Document(volume)))
-        body = xml_to_json(etree.fromstring(body))
+        resp, body = self.post('volumes', str(common.Document(volume)))
+        body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def update_volume(self, volume_id, **kwargs):
         """Updates the Specified Volume."""
-        put_body = Element("volume", xmlns=XMLNS_11, **kwargs)
+        put_body = common.Element("volume", xmlns=common.XMLNS_11, **kwargs)
 
         resp, body = self.put('volumes/%s' % volume_id,
-                              str(Document(put_body)))
-        body = xml_to_json(etree.fromstring(body))
+                              str(common.Document(put_body)))
+        body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def delete_volume(self, volume_id):
@@ -198,108 +194,107 @@
 
     def attach_volume(self, volume_id, instance_uuid, mountpoint):
         """Attaches a volume to a given instance on a given mountpoint."""
-        post_body = Element("os-attach",
-                            instance_uuid=instance_uuid,
-                            mountpoint=mountpoint
-                            )
+        post_body = common.Element("os-attach",
+                                   instance_uuid=instance_uuid,
+                                   mountpoint=mountpoint
+                                   )
         url = 'volumes/%s/action' % str(volume_id)
-        resp, body = self.post(url, str(Document(post_body)))
+        resp, body = self.post(url, str(common.Document(post_body)))
         if body:
-            body = xml_to_json(etree.fromstring(body))
+            body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def detach_volume(self, volume_id):
         """Detaches a volume from an instance."""
-        post_body = Element("os-detach")
+        post_body = common.Element("os-detach")
         url = 'volumes/%s/action' % str(volume_id)
-        resp, body = self.post(url, str(Document(post_body)))
+        resp, body = self.post(url, str(common.Document(post_body)))
         if body:
-            body = xml_to_json(etree.fromstring(body))
+            body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def upload_volume(self, volume_id, image_name, disk_format):
         """Uploads a volume in Glance."""
-        post_body = Element("os-volume_upload_image",
-                            image_name=image_name,
-                            disk_format=disk_format)
+        post_body = common.Element("os-volume_upload_image",
+                                   image_name=image_name,
+                                   disk_format=disk_format)
         url = 'volumes/%s/action' % str(volume_id)
-        resp, body = self.post(url, str(Document(post_body)))
-        volume = xml_to_json(etree.fromstring(body))
+        resp, body = self.post(url, str(common.Document(post_body)))
+        volume = common.xml_to_json(etree.fromstring(body))
         return resp, volume
 
     def extend_volume(self, volume_id, extend_size):
         """Extend a volume."""
-        post_body = Element("os-extend",
-                            new_size=extend_size)
+        post_body = common.Element("os-extend",
+                                   new_size=extend_size)
         url = 'volumes/%s/action' % str(volume_id)
-        resp, body = self.post(url, str(Document(post_body)))
+        resp, body = self.post(url, str(common.Document(post_body)))
         if body:
-            body = xml_to_json(etree.fromstring(body))
+            body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def reset_volume_status(self, volume_id, status):
         """Reset the Specified Volume's Status."""
-        post_body = Element("os-reset_status",
-                            status=status
-                            )
+        post_body = common.Element("os-reset_status",
+                                   status=status
+                                   )
         url = 'volumes/%s/action' % str(volume_id)
-        resp, body = self.post(url, str(Document(post_body)))
+        resp, body = self.post(url, str(common.Document(post_body)))
         if body:
-            body = xml_to_json(etree.fromstring(body))
+            body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def volume_begin_detaching(self, volume_id):
         """Volume Begin Detaching."""
-        post_body = Element("os-begin_detaching")
+        post_body = common.Element("os-begin_detaching")
         url = 'volumes/%s/action' % str(volume_id)
-        resp, body = self.post(url, str(Document(post_body)))
+        resp, body = self.post(url, str(common.Document(post_body)))
         if body:
-            body = xml_to_json(etree.fromstring(body))
+            body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def volume_roll_detaching(self, volume_id):
         """Volume Roll Detaching."""
-        post_body = Element("os-roll_detaching")
+        post_body = common.Element("os-roll_detaching")
         url = 'volumes/%s/action' % str(volume_id)
-        resp, body = self.post(url, str(Document(post_body)))
+        resp, body = self.post(url, str(common.Document(post_body)))
         if body:
-            body = xml_to_json(etree.fromstring(body))
+            body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def reserve_volume(self, volume_id):
         """Reserves a volume."""
-        post_body = Element("os-reserve")
+        post_body = common.Element("os-reserve")
         url = 'volumes/%s/action' % str(volume_id)
-        resp, body = self.post(url, str(Document(post_body)))
+        resp, body = self.post(url, str(common.Document(post_body)))
         if body:
-            body = xml_to_json(etree.fromstring(body))
+            body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def unreserve_volume(self, volume_id):
         """Restore a reserved volume ."""
-        post_body = Element("os-unreserve")
+        post_body = common.Element("os-unreserve")
         url = 'volumes/%s/action' % str(volume_id)
-        resp, body = self.post(url, str(Document(post_body)))
+        resp, body = self.post(url, str(common.Document(post_body)))
         if body:
-            body = xml_to_json(etree.fromstring(body))
+            body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def create_volume_transfer(self, vol_id, name=None):
         """Create a volume transfer."""
-        post_body = Element("transfer",
-                            volume_id=vol_id)
+        post_body = common.Element("transfer", volume_id=vol_id)
         if name:
             post_body.add_attr('name', name)
         resp, body = self.post('os-volume-transfer',
-                               str(Document(post_body)))
-        volume = xml_to_json(etree.fromstring(body))
+                               str(common.Document(post_body)))
+        volume = common.xml_to_json(etree.fromstring(body))
         return resp, volume
 
     def get_volume_transfer(self, transfer_id):
         """Returns the details of a volume transfer."""
         url = "os-volume-transfer/%s" % str(transfer_id)
         resp, body = self.get(url)
-        volume = xml_to_json(etree.fromstring(body))
+        volume = common.xml_to_json(etree.fromstring(body))
         return resp, volume
 
     def list_volume_transfers(self, params=None):
@@ -321,7 +316,7 @@
             tag = child.tag
             if tag.startswith("{"):
                 tag = tag.split("}", 1)
-            vol[tag] = xml_to_json(child)
+            vol[tag] = common.xml_to_json(child)
         return vol
 
     def delete_volume_transfer(self, transfer_id):
@@ -330,36 +325,36 @@
 
     def accept_volume_transfer(self, transfer_id, transfer_auth_key):
         """Accept a volume transfer."""
-        post_body = Element("accept", auth_key=transfer_auth_key)
+        post_body = common.Element("accept", auth_key=transfer_auth_key)
         url = 'os-volume-transfer/%s/accept' % transfer_id
-        resp, body = self.post(url, str(Document(post_body)))
-        volume = xml_to_json(etree.fromstring(body))
+        resp, body = self.post(url, str(common.Document(post_body)))
+        volume = common.xml_to_json(etree.fromstring(body))
         return resp, volume
 
     def update_volume_readonly(self, volume_id, readonly):
         """Update the Specified Volume readonly."""
-        post_body = Element("os-update_readonly_flag",
-                            readonly=readonly)
+        post_body = common.Element("os-update_readonly_flag",
+                                   readonly=readonly)
         url = 'volumes/%s/action' % str(volume_id)
-        resp, body = self.post(url, str(Document(post_body)))
+        resp, body = self.post(url, str(common.Document(post_body)))
         if body:
-            body = xml_to_json(etree.fromstring(body))
+            body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def force_delete_volume(self, volume_id):
         """Force Delete Volume."""
-        post_body = Element("os-force_delete")
+        post_body = common.Element("os-force_delete")
         url = 'volumes/%s/action' % str(volume_id)
-        resp, body = self.post(url, str(Document(post_body)))
+        resp, body = self.post(url, str(common.Document(post_body)))
         if body:
-            body = xml_to_json(etree.fromstring(body))
+            body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def _metadata_body(self, meta):
-        post_body = Element('metadata')
+        post_body = common.Element('metadata')
         for k, v in meta.items():
-            data = Element('meta', key=k)
-            data.append(Text(v))
+            data = common.Element('meta', key=k)
+            data.append(common.Text(v))
             post_body.append(data)
         return post_body
 
@@ -374,7 +369,7 @@
         """Create metadata for the volume."""
         post_body = self._metadata_body(metadata)
         resp, body = self.post('volumes/%s/metadata' % volume_id,
-                               str(Document(post_body)))
+                               str(common.Document(post_body)))
         body = self._parse_key_value(etree.fromstring(body))
         return resp, body
 
@@ -389,18 +384,18 @@
         """Update metadata for the volume."""
         put_body = self._metadata_body(metadata)
         url = "volumes/%s/metadata" % str(volume_id)
-        resp, body = self.put(url, str(Document(put_body)))
+        resp, body = self.put(url, str(common.Document(put_body)))
         body = self._parse_key_value(etree.fromstring(body))
         return resp, body
 
     def update_volume_metadata_item(self, volume_id, id, meta_item):
         """Update metadata item for the volume."""
         for k, v in meta_item.items():
-            put_body = Element('meta', key=k)
-            put_body.append(Text(v))
+            put_body = common.Element('meta', key=k)
+            put_body.append(common.Text(v))
         url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
-        resp, body = self.put(url, str(Document(put_body)))
-        body = xml_to_json(etree.fromstring(body))
+        resp, body = self.put(url, str(common.Document(put_body)))
+        body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def delete_volume_metadata_item(self, volume_id, id):
diff --git a/tempest/services/volume/xml/admin/volume_hosts_client.py b/tempest/services/volume/xml/admin/volume_hosts_client.py
index fb84c83..e34b9f0 100644
--- a/tempest/services/volume/xml/admin/volume_hosts_client.py
+++ b/tempest/services/volume/xml/admin/volume_hosts_client.py
@@ -19,7 +19,7 @@
 
 from tempest.common import rest_client
 from tempest import config
-from tempest.services.compute.xml.common import xml_to_json
+from tempest.services.compute.xml import common
 
 CONF = config.CONF
 
@@ -58,7 +58,7 @@
         for child in node.getchildren():
             tag_list = child.tag.split('}', 1)
             if tag_list[0] == "host":
-                array.append(xml_to_json(child))
+                array.append(common.xml_to_json(child))
         return array
 
     def list_hosts(self, params=None):
diff --git a/tempest/services/volume/xml/admin/volume_types_client.py b/tempest/services/volume/xml/admin/volume_types_client.py
index 77bafec..1fa3e73 100644
--- a/tempest/services/volume/xml/admin/volume_types_client.py
+++ b/tempest/services/volume/xml/admin/volume_types_client.py
@@ -20,11 +20,7 @@
 from tempest.common import rest_client
 from tempest import config
 from tempest import exceptions
-from tempest.services.compute.xml.common import Document
-from tempest.services.compute.xml.common import Element
-from tempest.services.compute.xml.common import Text
-from tempest.services.compute.xml.common import xml_to_json
-from tempest.services.compute.xml.common import XMLNS_11
+from tempest.services.compute.xml import common
 
 CONF = config.CONF
 
@@ -53,7 +49,7 @@
                                                 meta.text)
                                                for meta in list(child))
             else:
-                vol_type[tag] = xml_to_json(child)
+                vol_type[tag] = common.xml_to_json(child)
             return vol_type
 
     def _parse_volume_type_extra_specs(self, body):
@@ -64,7 +60,7 @@
             if tag.startswith("{"):
                 ns, tag = tag.split("}", 1)
             else:
-                extra_spec[tag] = xml_to_json(child)
+                extra_spec[tag] = common.xml_to_json(child)
             return extra_spec
 
     def list_volume_types(self, params=None):
@@ -95,22 +91,22 @@
         Following optional keyword arguments are accepted:
         extra_specs: A dictionary of values to be used as extra_specs.
         """
-        vol_type = Element("volume_type", xmlns=XMLNS_11)
+        vol_type = common.Element("volume_type", xmlns=common.XMLNS_11)
         if name:
             vol_type.add_attr('name', name)
 
         extra_specs = kwargs.get('extra_specs')
         if extra_specs:
-            _extra_specs = Element('extra_specs')
+            _extra_specs = common.Element('extra_specs')
             vol_type.append(_extra_specs)
             for key, value in extra_specs.items():
-                spec = Element('extra_spec')
+                spec = common.Element('extra_spec')
                 spec.add_attr('key', key)
-                spec.append(Text(value))
+                spec.append(common.Text(value))
                 _extra_specs.append(spec)
 
-        resp, body = self.post('types', str(Document(vol_type)))
-        body = xml_to_json(etree.fromstring(body))
+        resp, body = self.post('types', str(common.Document(vol_type)))
+        body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def delete_volume_type(self, type_id):
@@ -147,21 +143,21 @@
         extra_specs: A dictionary of values to be used as extra_specs.
         """
         url = "types/%s/extra_specs" % str(vol_type_id)
-        extra_specs = Element("extra_specs", xmlns=XMLNS_11)
+        extra_specs = common.Element("extra_specs", xmlns=common.XMLNS_11)
         if extra_spec:
             if isinstance(extra_spec, list):
                 extra_specs.append(extra_spec)
             else:
                 for key, value in extra_spec.items():
-                    spec = Element('extra_spec')
+                    spec = common.Element('extra_spec')
                     spec.add_attr('key', key)
-                    spec.append(Text(value))
+                    spec.append(common.Text(value))
                     extra_specs.append(spec)
         else:
             extra_specs = None
 
-        resp, body = self.post(url, str(Document(extra_specs)))
-        body = xml_to_json(etree.fromstring(body))
+        resp, body = self.post(url, str(common.Document(extra_specs)))
+        body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def delete_volume_type_extra_specs(self, vol_id, extra_spec_name):
@@ -180,17 +176,17 @@
         """
         url = "types/%s/extra_specs/%s" % (str(vol_type_id),
                                            str(extra_spec_name))
-        extra_specs = Element("extra_specs", xmlns=XMLNS_11)
+        extra_specs = common.Element("extra_specs", xmlns=common.XMLNS_11)
 
         if extra_spec is not None:
             for key, value in extra_spec.items():
-                spec = Element('extra_spec')
+                spec = common.Element('extra_spec')
                 spec.add_attr('key', key)
-                spec.append(Text(value))
+                spec.append(common.Text(value))
                 extra_specs.append(spec)
 
-        resp, body = self.put(url, str(Document(extra_specs)))
-        body = xml_to_json(etree.fromstring(body))
+        resp, body = self.put(url, str(common.Document(extra_specs)))
+        body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def is_resource_deleted(self, id):
diff --git a/tempest/services/volume/xml/extensions_client.py b/tempest/services/volume/xml/extensions_client.py
index 1ea974f..4861733 100644
--- a/tempest/services/volume/xml/extensions_client.py
+++ b/tempest/services/volume/xml/extensions_client.py
@@ -17,7 +17,7 @@
 
 from tempest.common import rest_client
 from tempest import config
-from tempest.services.compute.xml.common import xml_to_json
+from tempest.services.compute.xml import common
 
 CONF = config.CONF
 
@@ -32,7 +32,7 @@
     def _parse_array(self, node):
         array = []
         for child in node:
-            array.append(xml_to_json(child))
+            array.append(common.xml_to_json(child))
         return array
 
     def list_extensions(self):
diff --git a/tempest/services/volume/xml/snapshots_client.py b/tempest/services/volume/xml/snapshots_client.py
index 458001b..9ad86d2 100644
--- a/tempest/services/volume/xml/snapshots_client.py
+++ b/tempest/services/volume/xml/snapshots_client.py
@@ -19,11 +19,7 @@
 from tempest import config
 from tempest import exceptions
 from tempest.openstack.common import log as logging
-from tempest.services.compute.xml.common import Document
-from tempest.services.compute.xml.common import Element
-from tempest.services.compute.xml.common import Text
-from tempest.services.compute.xml.common import xml_to_json
-from tempest.services.compute.xml.common import XMLNS_11
+from tempest.services.compute.xml import common
 
 CONF = config.CONF
 
@@ -52,7 +48,7 @@
         body = etree.fromstring(body)
         snapshots = []
         for snap in body:
-            snapshots.append(xml_to_json(snap))
+            snapshots.append(common.xml_to_json(snap))
         return resp, snapshots
 
     def list_snapshots_with_detail(self, params=None):
@@ -66,7 +62,7 @@
         body = etree.fromstring(body)
         snapshots = []
         for snap in body:
-            snapshots.append(xml_to_json(snap))
+            snapshots.append(common.xml_to_json(snap))
         return resp, snapshots
 
     def get_snapshot(self, snapshot_id):
@@ -74,7 +70,7 @@
         url = "snapshots/%s" % str(snapshot_id)
         resp, body = self.get(url)
         body = etree.fromstring(body)
-        return resp, xml_to_json(body)
+        return resp, common.xml_to_json(body)
 
     def create_snapshot(self, volume_id, **kwargs):
         """Creates a new snapshot.
@@ -84,20 +80,22 @@
         display_description: User friendly snapshot description.
         """
         # NOTE(afazekas): it should use the volume namespace
-        snapshot = Element("snapshot", xmlns=XMLNS_11, volume_id=volume_id)
+        snapshot = common.Element("snapshot", xmlns=common.XMLNS_11,
+                                  volume_id=volume_id)
         for key, value in kwargs.items():
             snapshot.add_attr(key, value)
-        resp, body = self.post('snapshots', str(Document(snapshot)))
-        body = xml_to_json(etree.fromstring(body))
+        resp, body = self.post('snapshots',
+                               str(common.Document(snapshot)))
+        body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def update_snapshot(self, snapshot_id, **kwargs):
         """Updates a snapshot."""
-        put_body = Element("snapshot", xmlns=XMLNS_11, **kwargs)
+        put_body = common.Element("snapshot", xmlns=common.XMLNS_11, **kwargs)
 
         resp, body = self.put('snapshots/%s' % snapshot_id,
-                              str(Document(put_body)))
-        body = xml_to_json(etree.fromstring(body))
+                              str(common.Document(put_body)))
+        body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     # NOTE(afazekas): just for the wait function
@@ -150,32 +148,30 @@
 
     def reset_snapshot_status(self, snapshot_id, status):
         """Reset the specified snapshot's status."""
-        post_body = Element("os-reset_status",
-                            status=status
-                            )
+        post_body = common.Element("os-reset_status", status=status)
         url = 'snapshots/%s/action' % str(snapshot_id)
-        resp, body = self.post(url, str(Document(post_body)))
+        resp, body = self.post(url, str(common.Document(post_body)))
         if body:
-            body = xml_to_json(etree.fromstring(body))
+            body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def update_snapshot_status(self, snapshot_id, status, progress):
         """Update the specified snapshot's status."""
-        post_body = Element("os-update_snapshot_status",
-                            status=status,
-                            progress=progress
-                            )
+        post_body = common.Element("os-update_snapshot_status",
+                                   status=status,
+                                   progress=progress
+                                   )
         url = 'snapshots/%s/action' % str(snapshot_id)
-        resp, body = self.post(url, str(Document(post_body)))
+        resp, body = self.post(url, str(common.Document(post_body)))
         if body:
-            body = xml_to_json(etree.fromstring(body))
+            body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def _metadata_body(self, meta):
-        post_body = Element('metadata')
+        post_body = common.Element('metadata')
         for k, v in meta.items():
-            data = Element('meta', key=k)
-            data.append(Text(v))
+            data = common.Element('meta', key=k)
+            data.append(common.Text(v))
             post_body.append(data)
         return post_body
 
@@ -190,7 +186,7 @@
         """Create metadata for the snapshot."""
         post_body = self._metadata_body(metadata)
         resp, body = self.post('snapshots/%s/metadata' % snapshot_id,
-                               str(Document(post_body)))
+                               str(common.Document(post_body)))
         body = self._parse_key_value(etree.fromstring(body))
         return resp, body
 
@@ -205,18 +201,18 @@
         """Update metadata for the snapshot."""
         put_body = self._metadata_body(metadata)
         url = "snapshots/%s/metadata" % str(snapshot_id)
-        resp, body = self.put(url, str(Document(put_body)))
+        resp, body = self.put(url, str(common.Document(put_body)))
         body = self._parse_key_value(etree.fromstring(body))
         return resp, body
 
     def update_snapshot_metadata_item(self, snapshot_id, id, meta_item):
         """Update metadata item for the snapshot."""
         for k, v in meta_item.items():
-            put_body = Element('meta', key=k)
-            put_body.append(Text(v))
+            put_body = common.Element('meta', key=k)
+            put_body.append(common.Text(v))
         url = "snapshots/%s/metadata/%s" % (str(snapshot_id), str(id))
-        resp, body = self.put(url, str(Document(put_body)))
-        body = xml_to_json(etree.fromstring(body))
+        resp, body = self.put(url, str(common.Document(put_body)))
+        body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def delete_snapshot_metadata_item(self, snapshot_id, id):
@@ -226,9 +222,9 @@
 
     def force_delete_snapshot(self, snapshot_id):
         """Force Delete Snapshot."""
-        post_body = Element("os-force_delete")
+        post_body = common.Element("os-force_delete")
         url = 'snapshots/%s/action' % str(snapshot_id)
-        resp, body = self.post(url, str(Document(post_body)))
+        resp, body = self.post(url, str(common.Document(post_body)))
         if body:
-            body = xml_to_json(etree.fromstring(body))
+            body = common.xml_to_json(etree.fromstring(body))
         return resp, body
diff --git a/tempest/services/volume/xml/volumes_client.py b/tempest/services/volume/xml/volumes_client.py
index aef1e3c..8e886ce 100644
--- a/tempest/services/volume/xml/volumes_client.py
+++ b/tempest/services/volume/xml/volumes_client.py
@@ -17,16 +17,12 @@
 import urllib
 
 from lxml import etree
-from xml.sax.saxutils import escape
+from xml.sax import saxutils
 
 from tempest.common import rest_client
 from tempest import config
 from tempest import exceptions
-from tempest.services.compute.xml.common import Document
-from tempest.services.compute.xml.common import Element
-from tempest.services.compute.xml.common import Text
-from tempest.services.compute.xml.common import xml_to_json
-from tempest.services.compute.xml.common import XMLNS_11
+from tempest.services.compute.xml import common
 
 CONF = config.CONF
 
@@ -55,7 +51,7 @@
                                        meta.text) for meta in
                                        child.getchildren())
             else:
-                vol[tag] = xml_to_json(child)
+                vol[tag] = common.xml_to_json(child)
         return vol
 
     def get_attachment_from_volume(self, volume):
@@ -135,15 +131,15 @@
                          image
         """
         # NOTE(afazekas): it should use a volume namespace
-        volume = Element("volume", xmlns=XMLNS_11, size=size)
+        volume = common.Element("volume", xmlns=common.XMLNS_11, size=size)
 
         if 'metadata' in kwargs:
-            _metadata = Element('metadata')
+            _metadata = common.Element('metadata')
             volume.append(_metadata)
             for key, value in kwargs['metadata'].items():
-                meta = Element('meta')
+                meta = common.Element('meta')
                 meta.add_attr('key', key)
-                meta.append(Text(value))
+                meta.append(common.Text(value))
                 _metadata.append(meta)
             attr_to_add = kwargs.copy()
             del attr_to_add['metadata']
@@ -153,17 +149,17 @@
         for key, value in attr_to_add.items():
             volume.add_attr(key, value)
 
-        resp, body = self.post('volumes', str(Document(volume)))
-        body = xml_to_json(etree.fromstring(body))
+        resp, body = self.post('volumes', str(common.Document(volume)))
+        body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def update_volume(self, volume_id, **kwargs):
         """Updates the Specified Volume."""
-        put_body = Element("volume", xmlns=XMLNS_11, **kwargs)
+        put_body = common.Element("volume", xmlns=common.XMLNS_11, **kwargs)
 
         resp, body = self.put('volumes/%s' % volume_id,
-                              str(Document(put_body)))
-        body = xml_to_json(etree.fromstring(body))
+                              str(common.Document(put_body)))
+        body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def delete_volume(self, volume_id):
@@ -199,108 +195,108 @@
 
     def attach_volume(self, volume_id, instance_uuid, mountpoint):
         """Attaches a volume to a given instance on a given mountpoint."""
-        post_body = Element("os-attach",
-                            instance_uuid=instance_uuid,
-                            mountpoint=mountpoint
-                            )
+        post_body = common.Element("os-attach",
+                                   instance_uuid=instance_uuid,
+                                   mountpoint=mountpoint
+                                   )
         url = 'volumes/%s/action' % str(volume_id)
-        resp, body = self.post(url, str(Document(post_body)))
+        resp, body = self.post(url, str(common.Document(post_body)))
         if body:
-            body = xml_to_json(etree.fromstring(body))
+            body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def detach_volume(self, volume_id):
         """Detaches a volume from an instance."""
-        post_body = Element("os-detach")
+        post_body = common.Element("os-detach")
         url = 'volumes/%s/action' % str(volume_id)
-        resp, body = self.post(url, str(Document(post_body)))
+        resp, body = self.post(url, str(common.Document(post_body)))
         if body:
-            body = xml_to_json(etree.fromstring(body))
+            body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def upload_volume(self, volume_id, image_name, disk_format):
         """Uploads a volume in Glance."""
-        post_body = Element("os-volume_upload_image",
-                            image_name=image_name,
-                            disk_format=disk_format)
+        post_body = common.Element("os-volume_upload_image",
+                                   image_name=image_name,
+                                   disk_format=disk_format)
         url = 'volumes/%s/action' % str(volume_id)
-        resp, body = self.post(url, str(Document(post_body)))
-        volume = xml_to_json(etree.fromstring(body))
+        resp, body = self.post(url, str(common.Document(post_body)))
+        volume = common.xml_to_json(etree.fromstring(body))
         return resp, volume
 
     def extend_volume(self, volume_id, extend_size):
         """Extend a volume."""
-        post_body = Element("os-extend",
-                            new_size=extend_size)
+        post_body = common.Element("os-extend",
+                                   new_size=extend_size)
         url = 'volumes/%s/action' % str(volume_id)
-        resp, body = self.post(url, str(Document(post_body)))
+        resp, body = self.post(url, str(common.Document(post_body)))
         if body:
-            body = xml_to_json(etree.fromstring(body))
+            body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def reset_volume_status(self, volume_id, status):
         """Reset the Specified Volume's Status."""
-        post_body = Element("os-reset_status",
-                            status=status
-                            )
+        post_body = common.Element("os-reset_status",
+                                   status=status
+                                   )
         url = 'volumes/%s/action' % str(volume_id)
-        resp, body = self.post(url, str(Document(post_body)))
+        resp, body = self.post(url, str(common.Document(post_body)))
         if body:
-            body = xml_to_json(etree.fromstring(body))
+            body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def volume_begin_detaching(self, volume_id):
         """Volume Begin Detaching."""
-        post_body = Element("os-begin_detaching")
+        post_body = common.Element("os-begin_detaching")
         url = 'volumes/%s/action' % str(volume_id)
-        resp, body = self.post(url, str(Document(post_body)))
+        resp, body = self.post(url, str(common.Document(post_body)))
         if body:
-            body = xml_to_json(etree.fromstring(body))
+            body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def volume_roll_detaching(self, volume_id):
         """Volume Roll Detaching."""
-        post_body = Element("os-roll_detaching")
+        post_body = common.Element("os-roll_detaching")
         url = 'volumes/%s/action' % str(volume_id)
-        resp, body = self.post(url, str(Document(post_body)))
+        resp, body = self.post(url, str(common.Document(post_body)))
         if body:
-            body = xml_to_json(etree.fromstring(body))
+            body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def reserve_volume(self, volume_id):
         """Reserves a volume."""
-        post_body = Element("os-reserve")
+        post_body = common.Element("os-reserve")
         url = 'volumes/%s/action' % str(volume_id)
-        resp, body = self.post(url, str(Document(post_body)))
+        resp, body = self.post(url, str(common.Document(post_body)))
         if body:
-            body = xml_to_json(etree.fromstring(body))
+            body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def unreserve_volume(self, volume_id):
         """Restore a reserved volume ."""
-        post_body = Element("os-unreserve")
+        post_body = common.Element("os-unreserve")
         url = 'volumes/%s/action' % str(volume_id)
-        resp, body = self.post(url, str(Document(post_body)))
+        resp, body = self.post(url, str(common.Document(post_body)))
         if body:
-            body = xml_to_json(etree.fromstring(body))
+            body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def create_volume_transfer(self, vol_id, display_name=None):
         """Create a volume transfer."""
-        post_body = Element("transfer",
-                            volume_id=vol_id)
+        post_body = common.Element("transfer",
+                                   volume_id=vol_id)
         if display_name:
             post_body.add_attr('name', display_name)
         resp, body = self.post('os-volume-transfer',
-                               str(Document(post_body)))
-        volume = xml_to_json(etree.fromstring(body))
+                               str(common.Document(post_body)))
+        volume = common.xml_to_json(etree.fromstring(body))
         return resp, volume
 
     def get_volume_transfer(self, transfer_id):
         """Returns the details of a volume transfer."""
         url = "os-volume-transfer/%s" % str(transfer_id)
         resp, body = self.get(url)
-        volume = xml_to_json(etree.fromstring(body))
+        volume = common.xml_to_json(etree.fromstring(body))
         return resp, volume
 
     def list_volume_transfers(self, params=None):
@@ -322,7 +318,7 @@
             tag = child.tag
             if tag.startswith("{"):
                 tag = tag.split("}", 1)
-            vol[tag] = xml_to_json(child)
+            vol[tag] = common.xml_to_json(child)
         return vol
 
     def delete_volume_transfer(self, transfer_id):
@@ -331,37 +327,37 @@
 
     def accept_volume_transfer(self, transfer_id, transfer_auth_key):
         """Accept a volume transfer."""
-        post_body = Element("accept", auth_key=transfer_auth_key)
+        post_body = common.Element("accept", auth_key=transfer_auth_key)
         url = 'os-volume-transfer/%s/accept' % transfer_id
-        resp, body = self.post(url, str(Document(post_body)))
-        volume = xml_to_json(etree.fromstring(body))
+        resp, body = self.post(url, str(common.Document(post_body)))
+        volume = common.xml_to_json(etree.fromstring(body))
         return resp, volume
 
     def update_volume_readonly(self, volume_id, readonly):
         """Update the Specified Volume readonly."""
-        post_body = Element("os-update_readonly_flag",
-                            readonly=readonly)
+        post_body = common.Element("os-update_readonly_flag",
+                                   readonly=readonly)
         url = 'volumes/%s/action' % str(volume_id)
-        resp, body = self.post(url, str(Document(post_body)))
+        resp, body = self.post(url, str(common.Document(post_body)))
         if body:
-            body = xml_to_json(etree.fromstring(body))
+            body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def force_delete_volume(self, volume_id):
         """Force Delete Volume."""
-        post_body = Element("os-force_delete")
+        post_body = common.Element("os-force_delete")
         url = 'volumes/%s/action' % str(volume_id)
-        resp, body = self.post(url, str(Document(post_body)))
+        resp, body = self.post(url, str(common.Document(post_body)))
         if body:
-            body = xml_to_json(etree.fromstring(body))
+            body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def _metadata_body(self, meta):
-        post_body = Element('metadata')
+        post_body = common.Element('metadata')
         for k, v in meta.items():
-            data = Element('meta', key=k)
+            data = common.Element('meta', key=k)
             # Escape value to allow for special XML chars
-            data.append(Text(escape(v)))
+            data.append(common.Text(saxutils.escape(v)))
             post_body.append(data)
         return post_body
 
@@ -376,7 +372,7 @@
         """Create metadata for the volume."""
         post_body = self._metadata_body(metadata)
         resp, body = self.post('volumes/%s/metadata' % volume_id,
-                               str(Document(post_body)))
+                               str(common.Document(post_body)))
         body = self._parse_key_value(etree.fromstring(body))
         return resp, body
 
@@ -391,18 +387,18 @@
         """Update metadata for the volume."""
         put_body = self._metadata_body(metadata)
         url = "volumes/%s/metadata" % str(volume_id)
-        resp, body = self.put(url, str(Document(put_body)))
+        resp, body = self.put(url, str(common.Document(put_body)))
         body = self._parse_key_value(etree.fromstring(body))
         return resp, body
 
     def update_volume_metadata_item(self, volume_id, id, meta_item):
         """Update metadata item for the volume."""
         for k, v in meta_item.items():
-            put_body = Element('meta', key=k)
-            put_body.append(Text(v))
+            put_body = common.Element('meta', key=k)
+            put_body.append(common.Text(v))
         url = "volumes/%s/metadata/%s" % (str(volume_id), str(id))
-        resp, body = self.put(url, str(Document(put_body)))
-        body = xml_to_json(etree.fromstring(body))
+        resp, body = self.put(url, str(common.Document(put_body)))
+        body = common.xml_to_json(etree.fromstring(body))
         return resp, body
 
     def delete_volume_metadata_item(self, volume_id, id):