Make parameter list generation consistent using urlencode().
Ensure that each client is generating the parameter list
correctly by using the urllib.urlencode method.
Fixes: bug 1086574
Change-Id: I9008a57fe94ccec1f3bea95f314860ff8017cb42
diff --git a/tempest/services/compute/json/flavors_client.py b/tempest/services/compute/json/flavors_client.py
index 01708a2..dc825df 100644
--- a/tempest/services/compute/json/flavors_client.py
+++ b/tempest/services/compute/json/flavors_client.py
@@ -17,6 +17,7 @@
from tempest.common.rest_client import RestClient
import json
+import urllib
class FlavorsClientJSON(RestClient):
@@ -28,12 +29,8 @@
def list_flavors(self, params=None):
url = 'flavors'
- if params is not None:
- param_list = []
- for param, value in params.iteritems():
- param_list.append("%s=%s&" % (param, value))
-
- url = "flavors?" + "".join(param_list)
+ if params:
+ url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
body = json.loads(body)
@@ -41,12 +38,8 @@
def list_flavors_with_detail(self, params=None):
url = 'flavors/detail'
- if params is not None:
- param_list = []
- for param, value in params.iteritems():
- param_list.append("%s=%s&" % (param, value))
-
- url = "flavors/detail?" + "".join(param_list)
+ if params:
+ url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
body = json.loads(body)