Merge "Keep py3.X compatibility for urllib"
diff --git a/manila_tempest_tests/services/share/json/shares_client.py b/manila_tempest_tests/services/share/json/shares_client.py
index 3eeea5e..040b541 100644
--- a/manila_tempest_tests/services/share/json/shares_client.py
+++ b/manila_tempest_tests/services/share/json/shares_client.py
@@ -15,9 +15,10 @@
 
 import json
 import time
-import urllib
 
 import six
+from six.moves.urllib import parse as urlparse
+
 from tempest import config  # noqa
 from tempest_lib.common import rest_client
 from tempest_lib.common.utils import data_utils
@@ -111,7 +112,7 @@
     def list_shares(self, detailed=False, params=None):
         """Get list of shares w/o filters."""
         uri = 'shares/detail' if detailed else 'shares'
-        uri += '?%s' % urllib.urlencode(params) if params else ''
+        uri += '?%s' % urlparse.urlencode(params) if params else ''
         resp, body = self.get(uri)
         self.expected_success(200, resp.status)
         return self._parse_resp(body)
@@ -206,7 +207,7 @@
     def list_snapshots(self, detailed=False, params=None):
         """Get list of share snapshots w/o filters."""
         uri = 'snapshots/detail' if detailed else 'snapshots'
-        uri += '?%s' % urllib.urlencode(params) if params else ''
+        uri += '?%s' % urlparse.urlencode(params) if params else ''
         resp, body = self.get(uri)
         self.expected_success(200, resp.status)
         return self._parse_resp(body)
@@ -456,7 +457,7 @@
         """List services."""
         uri = 'os-services'
         if params:
-            uri += '?%s' % urllib.urlencode(params)
+            uri += '?%s' % urlparse.urlencode(params)
         resp, body = self.get(uri)
         self.expected_success(200, resp.status)
         return self._parse_resp(body)
@@ -524,7 +525,7 @@
         if detailed:
             uri += '/detail'
         if params:
-            uri += "?%s" % urllib.urlencode(params)
+            uri += "?%s" % urlparse.urlencode(params)
         resp, body = self.get(uri)
         self.expected_success(200, resp.status)
         return self._parse_resp(body)
@@ -566,7 +567,7 @@
         """List the details of all shares."""
         uri = "share-networks/detail"
         if params:
-            uri += "?%s" % urllib.urlencode(params)
+            uri += "?%s" % urlparse.urlencode(params)
         resp, body = self.get(uri)
         self.expected_success(200, resp.status)
         return self._parse_resp(body)
@@ -612,7 +613,7 @@
     def list_share_types(self, params=None):
         uri = 'types'
         if params is not None:
-            uri += '?%s' % urllib.urlencode(params)
+            uri += '?%s' % urlparse.urlencode(params)
         resp, body = self.get(uri)
         self.expected_success(200, resp.status)
         return self._parse_resp(body)
@@ -679,7 +680,7 @@
     def get_share_type_extra_specs(self, share_type_id, params=None):
         uri = "types/%s/extra_specs" % share_type_id
         if params is not None:
-            uri += '?%s' % urllib.urlencode(params)
+            uri += '?%s' % urlparse.urlencode(params)
         resp, body = self.get(uri)
         self.expected_success(200, resp.status)
         return self._parse_resp(body)
@@ -713,7 +714,7 @@
         """Get list of share servers."""
         uri = "share-servers"
         if search_opts:
-            uri += "?%s" % urllib.urlencode(search_opts)
+            uri += "?%s" % urlparse.urlencode(search_opts)
         resp, body = self.get(uri)
         self.expected_success(200, resp.status)
         return self._parse_resp(body)
@@ -747,7 +748,7 @@
         if detail:
             uri += '/detail'
         if search_opts:
-            uri += "?%s" % urllib.urlencode(search_opts)
+            uri += "?%s" % urlparse.urlencode(search_opts)
         resp, body = self.get(uri)
         self.expected_success(200, resp.status)
         return json.loads(body)
diff --git a/manila_tempest_tests/services/share/v2/json/shares_client.py b/manila_tempest_tests/services/share/v2/json/shares_client.py
index a965a36..806f108 100644
--- a/manila_tempest_tests/services/share/v2/json/shares_client.py
+++ b/manila_tempest_tests/services/share/v2/json/shares_client.py
@@ -15,8 +15,8 @@
 
 import json
 import time
-import urllib
 
+from six.moves.urllib import parse as urlparse
 from tempest import config
 from tempest_lib.common.utils import data_utils
 from tempest_lib import exceptions
@@ -223,7 +223,7 @@
                     version=LATEST_MICROVERSION):
         """Get list of shares w/o filters."""
         uri = 'shares/detail' if detailed else 'shares'
-        uri += '?%s' % urllib.urlencode(params) if params else ''
+        uri += '?%s' % urlparse.urlencode(params) if params else ''
         resp, body = self.get(uri, version=version)
         self.expected_success(200, resp.status)
         return self._parse_resp(body)
@@ -241,7 +241,7 @@
     def delete_share(self, share_id, params=None,
                      version=LATEST_MICROVERSION):
         uri = "shares/%s" % share_id
-        uri += '?%s' % (urllib.urlencode(params) if params else '')
+        uri += '?%s' % (urlparse.urlencode(params) if params else '')
         resp, body = self.delete(uri, version=version)
         self.expected_success(202, resp.status)
         return body
@@ -444,7 +444,7 @@
             else:
                 url = 'os-services'
         if params:
-            url += '?%s' % urllib.urlencode(params)
+            url += '?%s' % urlparse.urlencode(params)
         resp, body = self.get(url, version=version)
         self.expected_success(200, resp.status)
         return self._parse_resp(body)
@@ -454,7 +454,7 @@
     def list_share_types(self, params=None, version=LATEST_MICROVERSION):
         uri = 'types'
         if params is not None:
-            uri += '?%s' % urllib.urlencode(params)
+            uri += '?%s' % urlparse.urlencode(params)
         resp, body = self.get(uri, version=version)
         self.expected_success(200, resp.status)
         return self._parse_resp(body)
@@ -604,7 +604,7 @@
                                 version=LATEST_MICROVERSION):
         """Get list of consistency groups w/o filters."""
         uri = 'consistency-groups%s' % ('/detail' if detailed else '')
-        uri += '?%s' % (urllib.urlencode(params) if params else '')
+        uri += '?%s' % (urlparse.urlencode(params) if params else '')
         resp, body = self.get(uri, headers=EXPERIMENTAL, extra_headers=True,
                               version=version)
         self.expected_success(200, resp.status)
@@ -700,7 +700,7 @@
                          version=LATEST_MICROVERSION):
         """Get list of cgsnapshots w/o filters."""
         uri = 'cgsnapshots/detail' if detailed else 'cgsnapshots'
-        uri += '?%s' % (urllib.urlencode(params) if params else '')
+        uri += '?%s' % (urlparse.urlencode(params) if params else '')
         resp, body = self.get(uri, headers=EXPERIMENTAL, extra_headers=True,
                               version=version)
         self.expected_success(200, resp.status)