Merge "encode the url parameters"

This commit is contained in:
Jenkins 2015-12-16 13:55:26 +00:00 committed by Gerrit Code Review
commit 8b33427d1a
2 changed files with 10 additions and 7 deletions

View File

@ -16,6 +16,7 @@
"""
Fping interface.
"""
from six.moves import urllib
from novaclient import base
@ -41,14 +42,14 @@ class FpingManager(base.ManagerWithFind):
exclude = exclude or []
params = []
if all_tenants:
params.append("all_tenants=1")
params.append(("all_tenants", 1))
if include:
params.append("include=%s" % ",".join(include))
params.append(("include", ",".join(include)))
elif exclude:
params.append("exclude=%s" % ",".join(exclude))
params.append(("exclude", ",".join(exclude)))
uri = "/os-fping"
if params:
uri = "%s?%s" % (uri, "&".join(params))
uri = "%s?%s" % (uri, urllib.parse.urlencode(params))
return self._list(uri, "servers")
def get(self, server):

View File

@ -16,6 +16,8 @@
"""
service interface
"""
from six.moves import urllib
from novaclient import api_versions
from novaclient import base
@ -42,11 +44,11 @@ class ServiceManager(base.ManagerWithFind):
url = "/os-services"
filters = []
if host:
filters.append("host=%s" % host)
filters.append(("host", host))
if binary:
filters.append("binary=%s" % binary)
filters.append(("binary", binary))
if filters:
url = "%s?%s" % (url, "&".join(filters))
url = "%s?%s" % (url, urllib.parse.urlencode(filters))
return self._list(url, "services")
@api_versions.wraps("2.0", "2.10")