py3: nfv update urllib compatibility
There is incompatible urllib usage. Use six library instead of urllib.quote to fix incompatibility. The Request object add_data method doesn't exist anymore. Use direct access to data field instead. This commit extracted urllib.parse.quote usage from Charles Short's work Iecfe9b83245847b07aaaa0ec1aadad4734a9d118. Added changes for Request.add_data usage on top of it. Story: 2008454 Task: 42727 Co-authored-by: Charles Short <charles.short@windriver.com> Signed-off-by: Dan Voiculeasa <dan.voiculeasa@windriver.com> Change-Id: Ifd82ea8d4134a2a6301e5b10d4b0546833ed6193 (cherry picked from commit 522a3b3660e280d58352d1efe33bfdb8ab2e0461)
This commit is contained in:
parent
8acf167a69
commit
14fa1e4667
@ -59,7 +59,7 @@ def get_token(auth_uri, project_name, project_domain_name, username, password,
|
||||
"domain": {"name": project_domain_name}
|
||||
}}}})
|
||||
|
||||
request_info.add_data(payload)
|
||||
request_info.data = payload
|
||||
|
||||
request = urllib.request.urlopen(request_info, timeout=30)
|
||||
# Identity API v3 returns token id in X-Subject-Token
|
||||
|
@ -32,7 +32,7 @@ def request(token_id, method, api_cmd, api_cmd_headers=None,
|
||||
request_info.add_header(header_type, header_value)
|
||||
|
||||
if api_cmd_payload is not None:
|
||||
request_info.add_data(api_cmd_payload)
|
||||
request_info.data = api_cmd_payload
|
||||
|
||||
url_request = urllib.request.urlopen(request_info,
|
||||
timeout=timeout_in_secs)
|
||||
|
@ -58,7 +58,7 @@ def get_token(directory):
|
||||
"name": directory.auth_project,
|
||||
"domain": {"name": directory.auth_project_domain_name}
|
||||
}}}})
|
||||
request_info.add_data(payload)
|
||||
request_info.data = payload
|
||||
|
||||
# WARNING: Any change to the timeout must be reflected in the config.ini
|
||||
# file for the nfvi plugins.
|
||||
|
@ -309,7 +309,7 @@ def _rest_api_request(token_id, method, api_cmd, api_cmd_headers,
|
||||
request_info.add_header(header_type, header_value)
|
||||
|
||||
if api_cmd_payload is not None:
|
||||
request_info.add_data(api_cmd_payload)
|
||||
request_info.data = api_cmd_payload
|
||||
|
||||
DLOG.verbose("Rest-API method=%s, api_cmd=%s, api_cmd_headers=%s, "
|
||||
"api_cmd_payload=%s" % (method, api_cmd, api_cmd_headers,
|
||||
|
@ -53,7 +53,7 @@ def validate_token(directory, admin_token, token_id):
|
||||
}
|
||||
}})
|
||||
|
||||
request_info.add_data(payload)
|
||||
request_info.data = payload
|
||||
|
||||
request = urllib.request.urlopen(request_info)
|
||||
# Identity API v3 returns token id in X-Subject-Token
|
||||
@ -114,7 +114,7 @@ def get_token(directory):
|
||||
"name": directory.auth_project,
|
||||
"domain": {"name": directory.auth_project_domain_name}
|
||||
}}}})
|
||||
request_info.add_data(payload)
|
||||
request_info.data = payload
|
||||
|
||||
request = urllib.request.urlopen(request_info)
|
||||
# Identity API v3 returns token id in X-Subject-Token
|
||||
|
@ -35,7 +35,7 @@ def rest_api_request(token, method, url, headers=None, body=None):
|
||||
request_info.add_header("X-Auth-Token", token.get_id())
|
||||
|
||||
if body is not None and '' != body:
|
||||
request_info.add_data(body)
|
||||
request_info.data = body
|
||||
|
||||
# Enable Debug
|
||||
# handler = urllib.request.HTTPHandler(debuglevel=1)
|
||||
|
@ -15,7 +15,7 @@
|
||||
from paste.proxy import parse_headers
|
||||
from paste.proxy import TransparentProxy
|
||||
from six.moves import http_client as httplib
|
||||
import urllib
|
||||
from six.moves import urllib
|
||||
|
||||
from oslo_log import log as logging
|
||||
|
||||
@ -90,7 +90,7 @@ class DebugProxy(Application):
|
||||
body = ''
|
||||
|
||||
path = (environ.get('SCRIPT_NAME', '') + environ.get('PATH_INFO', ''))
|
||||
path = urllib.quote(path)
|
||||
path = urllib.parse.quote(path)
|
||||
if 'QUERY_STRING' in environ:
|
||||
path += '?' + environ['QUERY_STRING']
|
||||
LOG.debug("REQ header: (%s)" % headers)
|
||||
|
Loading…
x
Reference in New Issue
Block a user