Merge "replace string format arguments with function parameters"
This commit is contained in:
@@ -330,7 +330,7 @@ def cms_sign_data(data_to_sign, signing_cert_file_name, signing_key_file_name,
|
|||||||
process, data, (signing_cert_file_name, signing_key_file_name))
|
process, data, (signing_cert_file_name, signing_key_file_name))
|
||||||
|
|
||||||
if retcode or ('Error' in err):
|
if retcode or ('Error' in err):
|
||||||
LOG.error('Signing error: %s' % err)
|
LOG.error('Signing error: %s', err)
|
||||||
if retcode == 3:
|
if retcode == 3:
|
||||||
LOG.error('Signing error: Unable to load certificate - '
|
LOG.error('Signing error: Unable to load certificate - '
|
||||||
'ensure you have configured PKI with '
|
'ensure you have configured PKI with '
|
||||||
|
@@ -443,8 +443,7 @@ class HTTPClient(baseclient.Client, base.BaseAuthPlugin):
|
|||||||
auth_ref = None
|
auth_ref = None
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
auth_ref = None
|
auth_ref = None
|
||||||
_logger.warning('Unable to retrieve token from keyring %s' % (
|
_logger.warning('Unable to retrieve token from keyring %s', e)
|
||||||
e))
|
|
||||||
return (keyring_key, auth_ref)
|
return (keyring_key, auth_ref)
|
||||||
|
|
||||||
def store_auth_ref_into_keyring(self, keyring_key):
|
def store_auth_ref_into_keyring(self, keyring_key):
|
||||||
@@ -457,7 +456,7 @@ class HTTPClient(baseclient.Client, base.BaseAuthPlugin):
|
|||||||
keyring_key,
|
keyring_key,
|
||||||
pickle.dumps(self.auth_ref))
|
pickle.dumps(self.auth_ref))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
_logger.warning("Failed to store token into keyring %s" % (e))
|
_logger.warning("Failed to store token into keyring %s", e)
|
||||||
|
|
||||||
def _process_management_url(self, region_name):
|
def _process_management_url(self, region_name):
|
||||||
try:
|
try:
|
||||||
@@ -540,8 +539,8 @@ class HTTPClient(baseclient.Client, base.BaseAuthPlugin):
|
|||||||
body_resp = jsonutils.loads(resp.text)
|
body_resp = jsonutils.loads(resp.text)
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
body_resp = None
|
body_resp = None
|
||||||
_logger.debug("Could not decode JSON from body: %s"
|
_logger.debug("Could not decode JSON from body: %s",
|
||||||
% resp.text)
|
resp.text)
|
||||||
else:
|
else:
|
||||||
_logger.debug("No body was returned.")
|
_logger.debug("No body was returned.")
|
||||||
body_resp = None
|
body_resp = None
|
||||||
|
@@ -102,7 +102,7 @@ class S3Token(object):
|
|||||||
"""Common initialization code."""
|
"""Common initialization code."""
|
||||||
self.app = app
|
self.app = app
|
||||||
self.logger = logging.getLogger(conf.get('log_name', __name__))
|
self.logger = logging.getLogger(conf.get('log_name', __name__))
|
||||||
self.logger.debug('Starting the %s component' % PROTOCOL_NAME)
|
self.logger.debug('Starting the %s component', PROTOCOL_NAME)
|
||||||
self.reseller_prefix = conf.get('reseller_prefix', 'AUTH_')
|
self.reseller_prefix = conf.get('reseller_prefix', 'AUTH_')
|
||||||
# where to find the auth service (we use this to validate tokens)
|
# where to find the auth service (we use this to validate tokens)
|
||||||
|
|
||||||
@@ -149,13 +149,13 @@ class S3Token(object):
|
|||||||
headers=headers, data=creds_json,
|
headers=headers, data=creds_json,
|
||||||
verify=self.verify)
|
verify=self.verify)
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
self.logger.info('HTTP connection exception: %s' % e)
|
self.logger.info('HTTP connection exception: %s', e)
|
||||||
resp = self.deny_request('InvalidURI')
|
resp = self.deny_request('InvalidURI')
|
||||||
raise ServiceError(resp)
|
raise ServiceError(resp)
|
||||||
|
|
||||||
if response.status_code < 200 or response.status_code >= 300:
|
if response.status_code < 200 or response.status_code >= 300:
|
||||||
self.logger.debug('Keystone reply error: status=%s reason=%s' %
|
self.logger.debug('Keystone reply error: status=%s reason=%s',
|
||||||
(response.status_code, response.reason))
|
response.status_code, response.reason)
|
||||||
resp = self.deny_request('AccessDenied')
|
resp = self.deny_request('AccessDenied')
|
||||||
raise ServiceError(resp)
|
raise ServiceError(resp)
|
||||||
|
|
||||||
@@ -192,7 +192,7 @@ class S3Token(object):
|
|||||||
access, signature = auth_header.split(' ')[-1].rsplit(':', 1)
|
access, signature = auth_header.split(' ')[-1].rsplit(':', 1)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
msg = 'You have an invalid Authorization header: %s'
|
msg = 'You have an invalid Authorization header: %s'
|
||||||
self.logger.debug(msg % (auth_header))
|
self.logger.debug(msg, auth_header)
|
||||||
return self.deny_request('InvalidURI')(environ, start_response)
|
return self.deny_request('InvalidURI')(environ, start_response)
|
||||||
|
|
||||||
# NOTE(chmou): This is to handle the special case with nova
|
# NOTE(chmou): This is to handle the special case with nova
|
||||||
@@ -215,7 +215,7 @@ class S3Token(object):
|
|||||||
'token': token,
|
'token': token,
|
||||||
'signature': signature}}
|
'signature': signature}}
|
||||||
creds_json = jsonutils.dumps(creds)
|
creds_json = jsonutils.dumps(creds)
|
||||||
self.logger.debug('Connecting to Keystone sending this JSON: %s' %
|
self.logger.debug('Connecting to Keystone sending this JSON: %s',
|
||||||
creds_json)
|
creds_json)
|
||||||
# NOTE(vish): We could save a call to keystone by having
|
# NOTE(vish): We could save a call to keystone by having
|
||||||
# keystone return token, tenant, user, and roles
|
# keystone return token, tenant, user, and roles
|
||||||
@@ -230,11 +230,11 @@ class S3Token(object):
|
|||||||
except ServiceError as e:
|
except ServiceError as e:
|
||||||
resp = e.args[0]
|
resp = e.args[0]
|
||||||
msg = 'Received error, exiting middleware with error: %s'
|
msg = 'Received error, exiting middleware with error: %s'
|
||||||
self.logger.debug(msg % (resp.status_code))
|
self.logger.debug(msg, resp.status_code)
|
||||||
return resp(environ, start_response)
|
return resp(environ, start_response)
|
||||||
|
|
||||||
self.logger.debug('Keystone Reply: Status: %d, Output: %s' % (
|
self.logger.debug('Keystone Reply: Status: %d, Output: %s',
|
||||||
resp.status_code, resp.content))
|
resp.status_code, resp.content)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
identity_info = resp.json()
|
identity_info = resp.json()
|
||||||
@@ -242,12 +242,12 @@ class S3Token(object):
|
|||||||
tenant = identity_info['access']['token']['tenant']
|
tenant = identity_info['access']['token']['tenant']
|
||||||
except (ValueError, KeyError):
|
except (ValueError, KeyError):
|
||||||
error = 'Error on keystone reply: %d %s'
|
error = 'Error on keystone reply: %d %s'
|
||||||
self.logger.debug(error % (resp.status_code, str(resp.content)))
|
self.logger.debug(error, resp.status_code, resp.content)
|
||||||
return self.deny_request('InvalidURI')(environ, start_response)
|
return self.deny_request('InvalidURI')(environ, start_response)
|
||||||
|
|
||||||
req.headers['X-Auth-Token'] = token_id
|
req.headers['X-Auth-Token'] = token_id
|
||||||
tenant_to_connect = force_tenant or tenant['id']
|
tenant_to_connect = force_tenant or tenant['id']
|
||||||
self.logger.debug('Connecting with tenant: %s' % (tenant_to_connect))
|
self.logger.debug('Connecting with tenant: %s', tenant_to_connect)
|
||||||
new_tenant_name = '%s%s' % (self.reseller_prefix, tenant_to_connect)
|
new_tenant_name = '%s%s' % (self.reseller_prefix, tenant_to_connect)
|
||||||
environ['PATH_INFO'] = environ['PATH_INFO'].replace(account,
|
environ['PATH_INFO'] = environ['PATH_INFO'].replace(account,
|
||||||
new_tenant_name)
|
new_tenant_name)
|
||||||
|
Reference in New Issue
Block a user