Merge "Prepare for enabling H302 rule(services/identity)"
diff --git a/tempest/services/identity/v3/json/credentials_client.py b/tempest/services/identity/v3/json/credentials_client.py
index 5d6632a..f795c7b 100644
--- a/tempest/services/identity/v3/json/credentials_client.py
+++ b/tempest/services/identity/v3/json/credentials_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 CredentialsClientJSON(RestClient):
+class CredentialsClientJSON(rest_client.RestClient):
 
     def __init__(self, auth_provider):
         super(CredentialsClientJSON, self).__init__(auth_provider)
diff --git a/tempest/services/identity/v3/json/endpoints_client.py b/tempest/services/identity/v3/json/endpoints_client.py
index 652c345..c3c1e15 100644
--- a/tempest/services/identity/v3/json/endpoints_client.py
+++ b/tempest/services/identity/v3/json/endpoints_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 EndPointClientJSON(RestClient):
+class EndPointClientJSON(rest_client.RestClient):
 
     def __init__(self, auth_provider):
         super(EndPointClientJSON, self).__init__(auth_provider)
diff --git a/tempest/services/identity/v3/json/identity_client.py b/tempest/services/identity/v3/json/identity_client.py
index b044e4d..65f3355 100644
--- a/tempest/services/identity/v3/json/identity_client.py
+++ b/tempest/services/identity/v3/json/identity_client.py
@@ -15,14 +15,14 @@
 
 import json
 
-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 IdentityV3ClientJSON(RestClient):
+class IdentityV3ClientJSON(rest_client.RestClient):
 
     def __init__(self, auth_provider):
         super(IdentityV3ClientJSON, self).__init__(auth_provider)
@@ -439,7 +439,7 @@
         return resp, body
 
 
-class V3TokenClientJSON(RestClient):
+class V3TokenClientJSON(rest_client.RestClient):
 
     def __init__(self):
         super(V3TokenClientJSON, self).__init__(None)
diff --git a/tempest/services/identity/v3/json/policy_client.py b/tempest/services/identity/v3/json/policy_client.py
index 5a3f891..3c90fa1 100644
--- a/tempest/services/identity/v3/json/policy_client.py
+++ b/tempest/services/identity/v3/json/policy_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 PolicyClientJSON(RestClient):
+class PolicyClientJSON(rest_client.RestClient):
 
     def __init__(self, auth_provider):
         super(PolicyClientJSON, self).__init__(auth_provider)
diff --git a/tempest/services/identity/v3/json/service_client.py b/tempest/services/identity/v3/json/service_client.py
index c1faebb..b66fb4a 100644
--- a/tempest/services/identity/v3/json/service_client.py
+++ b/tempest/services/identity/v3/json/service_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 ServiceClientJSON(RestClient):
+class ServiceClientJSON(rest_client.RestClient):
 
     def __init__(self, auth_provider):
         super(ServiceClientJSON, self).__init__(auth_provider)
diff --git a/tempest/services/identity/v3/xml/credentials_client.py b/tempest/services/identity/v3/xml/credentials_client.py
index 22ed44d..70f85a1 100644
--- a/tempest/services/identity/v3/xml/credentials_client.py
+++ b/tempest/services/identity/v3/xml/credentials_client.py
@@ -19,10 +19,7 @@
 
 from tempest.common import rest_client
 from tempest import config
-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 import common
 
 CONF = config.CONF
 
@@ -39,7 +36,7 @@
         self.api_version = "v3"
 
     def _parse_body(self, body):
-        data = xml_to_json(body)
+        data = common.xml_to_json(body)
         return data
 
     def _parse_creds(self, node):
@@ -47,7 +44,7 @@
         for child in node.getchildren():
             tag_list = child.tag.split('}', 1)
             if tag_list[1] == "credential":
-                array.append(xml_to_json(child))
+                array.append(common.xml_to_json(child))
         return array
 
     def create_credential(self, access_key, secret_key, user_id, project_id):
@@ -55,14 +52,14 @@
         cred_type = 'ec2'
         access = ""access": "%s"" % access_key
         secret = ""secret": "%s"" % secret_key
-        blob = Element('blob',
-                       xmlns=XMLNS)
-        blob.append(Text("{%s , %s}"
-                         % (access, secret)))
-        credential = Element('credential', project_id=project_id,
-                             type=cred_type, user_id=user_id)
+        blob = common.Element('blob',
+                              xmlns=XMLNS)
+        blob.append(common.Text("{%s , %s}"
+                                % (access, secret)))
+        credential = common.Element('credential', project_id=project_id,
+                                    type=cred_type, user_id=user_id)
         credential.append(blob)
-        resp, body = self.post('credentials', str(Document(credential)))
+        resp, body = self.post('credentials', str(common.Document(credential)))
         body = self._parse_body(etree.fromstring(body))
         body['blob'] = json.loads(body['blob'])
         return resp, body
@@ -77,15 +74,15 @@
         user_id = kwargs.get('user_id', body['user_id'])
         access = ""access": "%s"" % access_key
         secret = ""secret": "%s"" % secret_key
-        blob = Element('blob',
-                       xmlns=XMLNS)
-        blob.append(Text("{%s , %s}"
-                         % (access, secret)))
-        credential = Element('credential', project_id=project_id,
-                             type=cred_type, user_id=user_id)
+        blob = common.Element('blob',
+                              xmlns=XMLNS)
+        blob.append(common.Text("{%s , %s}"
+                                % (access, secret)))
+        credential = common.Element('credential', project_id=project_id,
+                                    type=cred_type, user_id=user_id)
         credential.append(blob)
         resp, body = self.patch('credentials/%s' % credential_id,
-                                str(Document(credential)))
+                                str(common.Document(credential)))
         body = self._parse_body(etree.fromstring(body))
         body['blob'] = json.loads(body['blob'])
         return resp, body
diff --git a/tempest/services/identity/v3/xml/endpoints_client.py b/tempest/services/identity/v3/xml/endpoints_client.py
index d79ea92..cc9aa65 100644
--- a/tempest/services/identity/v3/xml/endpoints_client.py
+++ b/tempest/services/identity/v3/xml/endpoints_client.py
@@ -18,9 +18,7 @@
 from tempest.common import http
 from tempest.common import rest_client
 from tempest import config
-from tempest.services.compute.xml.common import Document
-from tempest.services.compute.xml.common import Element
-from tempest.services.compute.xml.common import xml_to_json
+from tempest.services.compute.xml import common
 
 CONF = config.CONF
 
@@ -41,11 +39,11 @@
         for child in node.getchildren():
             tag_list = child.tag.split('}', 1)
             if tag_list[1] == "endpoint":
-                array.append(xml_to_json(child))
+                array.append(common.xml_to_json(child))
         return array
 
     def _parse_body(self, body):
-        json = xml_to_json(body)
+        json = common.xml_to_json(body)
         return json
 
     def request(self, method, url, headers=None, body=None, wait=None):
@@ -69,21 +67,22 @@
         enabled = kwargs.get('enabled', None)
         if enabled is not None:
             enabled = str(enabled).lower()
-        create_endpoint = Element("endpoint",
-                                  xmlns=XMLNS,
-                                  service_id=service_id,
-                                  interface=interface,
-                                  url=url, region=region,
-                                  enabled=enabled)
-        resp, body = self.post('endpoints', str(Document(create_endpoint)))
+        create_endpoint = common.Element("endpoint",
+                                         xmlns=XMLNS,
+                                         service_id=service_id,
+                                         interface=interface,
+                                         url=url, region=region,
+                                         enabled=enabled)
+        resp, body = self.post('endpoints',
+                               str(common.Document(create_endpoint)))
         body = self._parse_body(etree.fromstring(body))
         return resp, body
 
     def update_endpoint(self, endpoint_id, service_id=None, interface=None,
                         url=None, region=None, enabled=None):
         """Updates an endpoint with given parameters."""
-        doc = Document()
-        endpoint = Element("endpoint")
+        doc = common.Document()
+        endpoint = common.Element("endpoint")
         doc.append(endpoint)
 
         if service_id:
diff --git a/tempest/services/identity/v3/xml/identity_client.py b/tempest/services/identity/v3/xml/identity_client.py
index e8e70d8..6ff6d56 100644
--- a/tempest/services/identity/v3/xml/identity_client.py
+++ b/tempest/services/identity/v3/xml/identity_client.py
@@ -20,10 +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 import common
 
 CONF = config.CONF
 
@@ -44,7 +41,7 @@
         for child in node.getchildren():
             tag_list = child.tag.split('}', 1)
             if tag_list[1] == "project":
-                array.append(xml_to_json(child))
+                array.append(common.xml_to_json(child))
         return array
 
     def _parse_domains(self, node):
@@ -52,7 +49,7 @@
         for child in node.getchildren():
             tag_list = child.tag.split('}', 1)
             if tag_list[1] == "domain":
-                array.append(xml_to_json(child))
+                array.append(common.xml_to_json(child))
         return array
 
     def _parse_group_users(self, node):
@@ -60,7 +57,7 @@
         for child in node.getchildren():
             tag_list = child.tag.split('}', 1)
             if tag_list[1] == "user":
-                array.append(xml_to_json(child))
+                array.append(common.xml_to_json(child))
         return array
 
     def _parse_roles(self, node):
@@ -68,17 +65,17 @@
         for child in node.getchildren():
             tag_list = child.tag.split('}', 1)
             if tag_list[1] == "role":
-                array.append(xml_to_json(child))
+                array.append(common.xml_to_json(child))
         return array
 
     def _parse_array(self, node):
         array = []
         for child in node.getchildren():
-            array.append(xml_to_json(child))
+            array.append(common.xml_to_json(child))
         return array
 
     def _parse_body(self, body):
-        _json = xml_to_json(body)
+        _json = common.xml_to_json(body)
         return _json
 
     def create_user(self, user_name, **kwargs):
@@ -89,16 +86,16 @@
         project_id = kwargs.get('project_id', None)
         description = kwargs.get('description', None)
         domain_id = kwargs.get('domain_id', 'default')
-        post_body = Element("user",
-                            xmlns=XMLNS,
-                            name=user_name,
-                            password=password,
-                            description=description,
-                            email=email,
-                            enabled=str(en).lower(),
-                            project_id=project_id,
-                            domain_id=domain_id)
-        resp, body = self.post('users', str(Document(post_body)))
+        post_body = common.Element("user",
+                                   xmlns=XMLNS,
+                                   name=user_name,
+                                   password=password,
+                                   description=description,
+                                   email=email,
+                                   enabled=str(en).lower(),
+                                   project_id=project_id,
+                                   domain_id=domain_id)
+        resp, body = self.post('users', str(common.Document(post_body)))
         body = self._parse_body(etree.fromstring(body))
         return resp, body
 
@@ -110,16 +107,16 @@
         project_id = kwargs.get('project_id', body['project_id'])
         description = kwargs.get('description', body['description'])
         domain_id = kwargs.get('domain_id', body['domain_id'])
-        update_user = Element("user",
-                              xmlns=XMLNS,
-                              name=name,
-                              email=email,
-                              project_id=project_id,
-                              domain_id=domain_id,
-                              description=description,
-                              enabled=str(en).lower())
+        update_user = common.Element("user",
+                                     xmlns=XMLNS,
+                                     name=name,
+                                     email=email,
+                                     project_id=project_id,
+                                     domain_id=domain_id,
+                                     description=description,
+                                     enabled=str(en).lower())
         resp, body = self.patch('users/%s' % user_id,
-                                str(Document(update_user)))
+                                str(common.Document(update_user)))
         body = self._parse_body(etree.fromstring(body))
         return resp, body
 
@@ -151,14 +148,14 @@
         description = kwargs.get('description', None)
         en = kwargs.get('enabled', 'true')
         domain_id = kwargs.get('domain_id', 'default')
-        post_body = Element("project",
-                            xmlns=XMLNS,
-                            description=description,
-                            domain_id=domain_id,
-                            enabled=str(en).lower(),
-                            name=name)
+        post_body = common.Element("project",
+                                   xmlns=XMLNS,
+                                   description=description,
+                                   domain_id=domain_id,
+                                   enabled=str(en).lower(),
+                                   name=name)
         resp, body = self.post('projects',
-                               str(Document(post_body)))
+                               str(common.Document(post_body)))
         body = self._parse_body(etree.fromstring(body))
         return resp, body
 
@@ -175,14 +172,14 @@
         desc = kwargs.get('description', body['description'])
         en = kwargs.get('enabled', body['enabled'])
         domain_id = kwargs.get('domain_id', body['domain_id'])
-        post_body = Element("project",
-                            xmlns=XMLNS,
-                            name=name,
-                            description=desc,
-                            enabled=str(en).lower(),
-                            domain_id=domain_id)
+        post_body = common.Element("project",
+                                   xmlns=XMLNS,
+                                   name=name,
+                                   description=desc,
+                                   enabled=str(en).lower(),
+                                   domain_id=domain_id)
         resp, body = self.patch('projects/%s' % project_id,
-                                str(Document(post_body)))
+                                str(common.Document(post_body)))
         body = self._parse_body(etree.fromstring(body))
         return resp, body
 
@@ -199,10 +196,10 @@
 
     def create_role(self, name):
         """Create a Role."""
-        post_body = Element("role",
-                            xmlns=XMLNS,
-                            name=name)
-        resp, body = self.post('roles', str(Document(post_body)))
+        post_body = common.Element("role",
+                                   xmlns=XMLNS,
+                                   name=name)
+        resp, body = self.post('roles', str(common.Document(post_body)))
         body = self._parse_body(etree.fromstring(body))
         return resp, body
 
@@ -214,11 +211,11 @@
 
     def update_role(self, name, role_id):
         """Updates a Role."""
-        post_body = Element("role",
-                            xmlns=XMLNS,
-                            name=name)
+        post_body = common.Element("role",
+                                   xmlns=XMLNS,
+                                   name=name)
         resp, body = self.patch('roles/%s' % str(role_id),
-                                str(Document(post_body)))
+                                str(common.Document(post_body)))
         body = self._parse_body(etree.fromstring(body))
         return resp, body
 
@@ -237,12 +234,12 @@
         """Creates a domain."""
         description = kwargs.get('description', None)
         en = kwargs.get('enabled', True)
-        post_body = Element("domain",
-                            xmlns=XMLNS,
-                            name=name,
-                            description=description,
-                            enabled=str(en).lower())
-        resp, body = self.post('domains', str(Document(post_body)))
+        post_body = common.Element("domain",
+                                   xmlns=XMLNS,
+                                   name=name,
+                                   description=description,
+                                   enabled=str(en).lower())
+        resp, body = self.post('domains', str(common.Document(post_body)))
         body = self._parse_body(etree.fromstring(body))
         return resp, body
 
@@ -263,13 +260,13 @@
         description = kwargs.get('description', body['description'])
         en = kwargs.get('enabled', body['enabled'])
         name = kwargs.get('name', body['name'])
-        post_body = Element("domain",
-                            xmlns=XMLNS,
-                            name=name,
-                            description=description,
-                            enabled=str(en).lower())
+        post_body = common.Element("domain",
+                                   xmlns=XMLNS,
+                                   name=name,
+                                   description=description,
+                                   enabled=str(en).lower())
         resp, body = self.patch('domains/%s' % domain_id,
-                                str(Document(post_body)))
+                                str(common.Document(post_body)))
         body = self._parse_body(etree.fromstring(body))
         return resp, body
 
@@ -299,13 +296,13 @@
         description = kwargs.get('description', None)
         domain_id = kwargs.get('domain_id', 'default')
         project_id = kwargs.get('project_id', None)
-        post_body = Element("group",
-                            xmlns=XMLNS,
-                            name=name,
-                            description=description,
-                            domain_id=domain_id,
-                            project_id=project_id)
-        resp, body = self.post('groups', str(Document(post_body)))
+        post_body = common.Element("group",
+                                   xmlns=XMLNS,
+                                   name=name,
+                                   description=description,
+                                   domain_id=domain_id,
+                                   project_id=project_id)
+        resp, body = self.post('groups', str(common.Document(post_body)))
         body = self._parse_body(etree.fromstring(body))
         return resp, body
 
@@ -320,12 +317,12 @@
         resp, body = self.get_group(group_id)
         name = kwargs.get('name', body['name'])
         description = kwargs.get('description', body['description'])
-        post_body = Element("group",
-                            xmlns=XMLNS,
-                            name=name,
-                            description=description)
+        post_body = common.Element("group",
+                                   xmlns=XMLNS,
+                                   name=name,
+                                   description=description)
         resp, body = self.patch('groups/%s' % group_id,
-                                str(Document(post_body)))
+                                str(common.Document(post_body)))
         body = self._parse_body(etree.fromstring(body))
         return resp, body
 
@@ -456,35 +453,35 @@
         Validation is left to the server side.
         """
         if user_type == 'id':
-            _user = Element('user', id=user, password=password)
+            _user = common.Element('user', id=user, password=password)
         else:
-            _user = Element('user', name=user, password=password)
+            _user = common.Element('user', name=user, password=password)
         if domain is not None:
-            _domain = Element('domain', name=domain)
+            _domain = common.Element('domain', name=domain)
             _user.append(_domain)
 
-        password = Element('password')
+        password = common.Element('password')
         password.append(_user)
 
-        method = Element('method')
-        method.append(Text('password'))
-        methods = Element('methods')
+        method = common.Element('method')
+        method.append(common.Text('password'))
+        methods = common.Element('methods')
         methods.append(method)
-        identity = Element('identity')
+        identity = common.Element('identity')
         identity.append(methods)
         identity.append(password)
 
-        auth = Element('auth')
+        auth = common.Element('auth')
         auth.append(identity)
 
         if tenant is not None:
-            project = Element('project', name=tenant)
+            project = common.Element('project', name=tenant)
             project.append(_domain)
-            scope = Element('scope')
+            scope = common.Element('scope')
             scope.append(project)
             auth.append(scope)
 
-        resp, body = self.post(self.auth_url, body=str(Document(auth)))
+        resp, body = self.post(self.auth_url, body=str(common.Document(auth)))
         return resp, body
 
     def request(self, method, url, headers=None, body=None):
diff --git a/tempest/services/identity/v3/xml/policy_client.py b/tempest/services/identity/v3/xml/policy_client.py
index c12018a..bf4cce7 100644
--- a/tempest/services/identity/v3/xml/policy_client.py
+++ b/tempest/services/identity/v3/xml/policy_client.py
@@ -18,9 +18,7 @@
 from tempest.common import http
 from tempest.common import rest_client
 from tempest import config
-from tempest.services.compute.xml.common import Document
-from tempest.services.compute.xml.common import Element
-from tempest.services.compute.xml.common import xml_to_json
+from tempest.services.compute.xml import common
 
 CONF = config.CONF
 
@@ -41,11 +39,11 @@
         for child in node.getchildren():
             tag_list = child.tag.split('}', 1)
             if tag_list[1] == "policy":
-                array.append(xml_to_json(child))
+                array.append(common.xml_to_json(child))
         return array
 
     def _parse_body(self, body):
-        json = xml_to_json(body)
+        json = common.xml_to_json(body)
         return json
 
     def request(self, method, url, headers=None, body=None, wait=None):
@@ -59,8 +57,9 @@
 
     def create_policy(self, blob, type):
         """Creates a Policy."""
-        create_policy = Element("policy", xmlns=XMLNS, blob=blob, type=type)
-        resp, body = self.post('policies', str(Document(create_policy)))
+        create_policy = common.Element("policy", xmlns=XMLNS,
+                                       blob=blob, type=type)
+        resp, body = self.post('policies', str(common.Document(create_policy)))
         body = self._parse_body(etree.fromstring(body))
         return resp, body
 
@@ -81,9 +80,9 @@
         """Updates a policy."""
         resp, body = self.get_policy(policy_id)
         type = kwargs.get('type')
-        update_policy = Element("policy", xmlns=XMLNS, type=type)
+        update_policy = common.Element("policy", xmlns=XMLNS, type=type)
         url = 'policies/%s' % policy_id
-        resp, body = self.patch(url, str(Document(update_policy)))
+        resp, body = self.patch(url, str(common.Document(update_policy)))
         body = self._parse_body(etree.fromstring(body))
         return resp, body
 
diff --git a/tempest/services/identity/v3/xml/service_client.py b/tempest/services/identity/v3/xml/service_client.py
index d4a5877..966d7f7 100644
--- a/tempest/services/identity/v3/xml/service_client.py
+++ b/tempest/services/identity/v3/xml/service_client.py
@@ -17,9 +17,7 @@
 
 from tempest.common import rest_client
 from tempest import config
-from tempest.services.compute.xml.common import Document
-from tempest.services.compute.xml.common import Element
-from tempest.services.compute.xml.common import xml_to_json
+from tempest.services.compute.xml import common
 
 CONF = config.CONF
 
@@ -36,7 +34,7 @@
         self.api_version = "v3"
 
     def _parse_body(self, body):
-        data = xml_to_json(body)
+        data = common.xml_to_json(body)
         return data
 
     def update_service(self, service_id, **kwargs):
@@ -45,14 +43,14 @@
         name = kwargs.get('name', body['name'])
         description = kwargs.get('description', body['description'])
         type = kwargs.get('type', body['type'])
-        update_service = Element("service",
-                                 xmlns=XMLNS,
-                                 id=service_id,
-                                 name=name,
-                                 description=description,
-                                 type=type)
+        update_service = common.Element("service",
+                                        xmlns=XMLNS,
+                                        id=service_id,
+                                        name=name,
+                                        description=description,
+                                        type=type)
         resp, body = self.patch('services/%s' % service_id,
-                                str(Document(update_service)))
+                                str(common.Document(update_service)))
         body = self._parse_body(etree.fromstring(body))
         return resp, body
 
@@ -64,12 +62,12 @@
         return resp, body
 
     def create_service(self, serv_type, name=None, description=None):
-        post_body = Element("service",
-                            xmlns=XMLNS,
-                            name=name,
-                            description=description,
-                            type=serv_type)
-        resp, body = self.post("services", str(Document(post_body)))
+        post_body = common.Element("service",
+                                   xmlns=XMLNS,
+                                   name=name,
+                                   description=description,
+                                   type=serv_type)
+        resp, body = self.post("services", str(common.Document(post_body)))
         body = self._parse_body(etree.fromstring(body))
         return resp, body