Stop using function deprecated in Python 3
Python 3 deprecated the logger.warn method in favor of warning. DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead Change-Id: Idbd4de3c7c631fb2c235701c9b300c37a90d9538
This commit is contained in:
		@@ -208,9 +208,10 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            if not service_type:
 | 
					            if not service_type:
 | 
				
			||||||
                LOG.warn(_LW('Plugin cannot return an endpoint without '
 | 
					                LOG.warning(_LW(
 | 
				
			||||||
                             'knowing the service type that is required. Add '
 | 
					                    'Plugin cannot return an endpoint without knowing the '
 | 
				
			||||||
                             'service_type to endpoint filtering data.'))
 | 
					                    'service type that is required. Add service_type to '
 | 
				
			||||||
 | 
					                    'endpoint filtering data.'))
 | 
				
			||||||
                return None
 | 
					                return None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if not interface:
 | 
					            if not interface:
 | 
				
			||||||
@@ -243,9 +244,10 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
 | 
				
			|||||||
            # NOTE(jamielennox): Again if we can't contact the server we fall
 | 
					            # NOTE(jamielennox): Again if we can't contact the server we fall
 | 
				
			||||||
            # back to just returning the URL from the catalog. This may not be
 | 
					            # back to just returning the URL from the catalog. This may not be
 | 
				
			||||||
            # the best default but we need it for now.
 | 
					            # the best default but we need it for now.
 | 
				
			||||||
            LOG.warn(_LW('Failed to contact the endpoint at %s for discovery. '
 | 
					            LOG.warning(_LW(
 | 
				
			||||||
                         'Fallback to using that endpoint as the base url.'),
 | 
					                'Failed to contact the endpoint at %s for discovery. Fallback '
 | 
				
			||||||
                     url)
 | 
					                'to using that endpoint as the base url.'),
 | 
				
			||||||
 | 
					                url)
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            url = disc.url_for(version)
 | 
					            url = disc.url_for(version)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -130,9 +130,9 @@ class BaseGenericPlugin(base.BaseIdentityPlugin):
 | 
				
			|||||||
        except (exceptions.DiscoveryFailure,
 | 
					        except (exceptions.DiscoveryFailure,
 | 
				
			||||||
                exceptions.HTTPError,
 | 
					                exceptions.HTTPError,
 | 
				
			||||||
                exceptions.ConnectionError):
 | 
					                exceptions.ConnectionError):
 | 
				
			||||||
            LOG.warn(_LW('Discovering versions from the identity service '
 | 
					            LOG.warning(_LW('Discovering versions from the identity service '
 | 
				
			||||||
                         'failed when creating the password plugin. '
 | 
					                            'failed when creating the password plugin. '
 | 
				
			||||||
                         'Attempting to determine version from URL.'))
 | 
					                            'Attempting to determine version from URL.'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            url_parts = urlparse.urlparse(self.auth_url)
 | 
					            url_parts = urlparse.urlparse(self.auth_url)
 | 
				
			||||||
            path = url_parts.path.lower()
 | 
					            path = url_parts.path.lower()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -750,8 +750,8 @@ class AuthProtocol(object):
 | 
				
			|||||||
            return token
 | 
					            return token
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            if not self.delay_auth_decision:
 | 
					            if not self.delay_auth_decision:
 | 
				
			||||||
                self.LOG.warn('Unable to find authentication token'
 | 
					                self.LOG.warning('Unable to find authentication token'
 | 
				
			||||||
                              ' in headers')
 | 
					                                 ' in headers')
 | 
				
			||||||
                self.LOG.debug('Headers: %s', env)
 | 
					                self.LOG.debug('Headers: %s', env)
 | 
				
			||||||
            raise InvalidUserToken('Unable to find token in headers')
 | 
					            raise InvalidUserToken('Unable to find token in headers')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -804,8 +804,8 @@ class AuthProtocol(object):
 | 
				
			|||||||
        if self.cert_file and self.key_file:
 | 
					        if self.cert_file and self.key_file:
 | 
				
			||||||
            kwargs['cert'] = (self.cert_file, self.key_file)
 | 
					            kwargs['cert'] = (self.cert_file, self.key_file)
 | 
				
			||||||
        elif self.cert_file or self.key_file:
 | 
					        elif self.cert_file or self.key_file:
 | 
				
			||||||
            self.LOG.warn('Cannot use only a cert or key file. '
 | 
					            self.LOG.warning('Cannot use only a cert or key file. '
 | 
				
			||||||
                          'Please provide both. Ignoring.')
 | 
					                             'Please provide both. Ignoring.')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        kwargs['verify'] = self.ssl_ca_file or True
 | 
					        kwargs['verify'] = self.ssl_ca_file or True
 | 
				
			||||||
        if self.ssl_insecure:
 | 
					        if self.ssl_insecure:
 | 
				
			||||||
@@ -822,7 +822,8 @@ class AuthProtocol(object):
 | 
				
			|||||||
                    self.LOG.error('HTTP connection exception: %s', e)
 | 
					                    self.LOG.error('HTTP connection exception: %s', e)
 | 
				
			||||||
                    raise NetworkError('Unable to communicate with keystone')
 | 
					                    raise NetworkError('Unable to communicate with keystone')
 | 
				
			||||||
                # NOTE(vish): sleep 0.5, 1, 2
 | 
					                # NOTE(vish): sleep 0.5, 1, 2
 | 
				
			||||||
                self.LOG.warn('Retrying on HTTP connection exception: %s', e)
 | 
					                self.LOG.warning('Retrying on HTTP connection exception: %s',
 | 
				
			||||||
 | 
					                                 e)
 | 
				
			||||||
                time.sleep(2.0 ** retry / 2)
 | 
					                time.sleep(2.0 ** retry / 2)
 | 
				
			||||||
                retry += 1
 | 
					                retry += 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -896,12 +897,12 @@ class AuthProtocol(object):
 | 
				
			|||||||
            datetime_expiry = timeutils.parse_isotime(expiry)
 | 
					            datetime_expiry = timeutils.parse_isotime(expiry)
 | 
				
			||||||
            return (token, timeutils.normalize_time(datetime_expiry))
 | 
					            return (token, timeutils.normalize_time(datetime_expiry))
 | 
				
			||||||
        except (AssertionError, KeyError):
 | 
					        except (AssertionError, KeyError):
 | 
				
			||||||
            self.LOG.warn(
 | 
					            self.LOG.warning(
 | 
				
			||||||
                'Unexpected response from keystone service: %s', data)
 | 
					                'Unexpected response from keystone service: %s', data)
 | 
				
			||||||
            raise ServiceError('invalid json response')
 | 
					            raise ServiceError('invalid json response')
 | 
				
			||||||
        except (ValueError):
 | 
					        except (ValueError):
 | 
				
			||||||
            data['access']['token']['id'] = '<SANITIZED>'
 | 
					            data['access']['token']['id'] = '<SANITIZED>'
 | 
				
			||||||
            self.LOG.warn(
 | 
					            self.LOG.warning(
 | 
				
			||||||
                'Unable to parse expiration time from token: %s', data)
 | 
					                'Unable to parse expiration time from token: %s', data)
 | 
				
			||||||
            raise ServiceError('invalid json response')
 | 
					            raise ServiceError('invalid json response')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -948,13 +949,13 @@ class AuthProtocol(object):
 | 
				
			|||||||
            return data
 | 
					            return data
 | 
				
			||||||
        except NetworkError:
 | 
					        except NetworkError:
 | 
				
			||||||
            self.LOG.debug('Token validation failure.', exc_info=True)
 | 
					            self.LOG.debug('Token validation failure.', exc_info=True)
 | 
				
			||||||
            self.LOG.warn('Authorization failed for token')
 | 
					            self.LOG.warning('Authorization failed for token')
 | 
				
			||||||
            raise InvalidUserToken('Token authorization failed')
 | 
					            raise InvalidUserToken('Token authorization failed')
 | 
				
			||||||
        except Exception:
 | 
					        except Exception:
 | 
				
			||||||
            self.LOG.debug('Token validation failure.', exc_info=True)
 | 
					            self.LOG.debug('Token validation failure.', exc_info=True)
 | 
				
			||||||
            if token_id:
 | 
					            if token_id:
 | 
				
			||||||
                self._token_cache.store_invalid(token_id)
 | 
					                self._token_cache.store_invalid(token_id)
 | 
				
			||||||
            self.LOG.warn('Authorization failed for token')
 | 
					            self.LOG.warning('Authorization failed for token')
 | 
				
			||||||
            raise InvalidUserToken('Token authorization failed')
 | 
					            raise InvalidUserToken('Token authorization failed')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _build_user_headers(self, token_info):
 | 
					    def _build_user_headers(self, token_info):
 | 
				
			||||||
@@ -1143,7 +1144,7 @@ class AuthProtocol(object):
 | 
				
			|||||||
        if response.status_code == 200:
 | 
					        if response.status_code == 200:
 | 
				
			||||||
            return data
 | 
					            return data
 | 
				
			||||||
        if response.status_code == 404:
 | 
					        if response.status_code == 404:
 | 
				
			||||||
            self.LOG.warn('Authorization failed for token')
 | 
					            self.LOG.warning('Authorization failed for token')
 | 
				
			||||||
            raise InvalidUserToken('Token authorization failed')
 | 
					            raise InvalidUserToken('Token authorization failed')
 | 
				
			||||||
        if response.status_code == 401:
 | 
					        if response.status_code == 401:
 | 
				
			||||||
            self.LOG.info(
 | 
					            self.LOG.info(
 | 
				
			||||||
@@ -1156,7 +1157,7 @@ class AuthProtocol(object):
 | 
				
			|||||||
            self.LOG.info('Retrying validation')
 | 
					            self.LOG.info('Retrying validation')
 | 
				
			||||||
            return self.verify_uuid_token(user_token, False)
 | 
					            return self.verify_uuid_token(user_token, False)
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            self.LOG.warn('Invalid user token. Keystone response: %s', data)
 | 
					            self.LOG.warning('Invalid user token. Keystone response: %s', data)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            raise InvalidUserToken()
 | 
					            raise InvalidUserToken()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -455,8 +455,8 @@ class Session(object):
 | 
				
			|||||||
            try:
 | 
					            try:
 | 
				
			||||||
                location = resp.headers['location']
 | 
					                location = resp.headers['location']
 | 
				
			||||||
            except KeyError:
 | 
					            except KeyError:
 | 
				
			||||||
                logger.warn(_LW("Failed to redirect request to %s as new "
 | 
					                logger.warning(_LW("Failed to redirect request to %s as new "
 | 
				
			||||||
                                "location was not provided."), resp.url)
 | 
					                                   "location was not provided."), resp.url)
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                # NOTE(jamielennox): We don't pass through connect_retry_delay.
 | 
					                # NOTE(jamielennox): We don't pass through connect_retry_delay.
 | 
				
			||||||
                # This request actually worked so we can reset the delay count.
 | 
					                # This request actually worked so we can reset the delay count.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -927,7 +927,7 @@ class CommonAuthTokenMiddlewareTest(object):
 | 
				
			|||||||
                self.msg = None
 | 
					                self.msg = None
 | 
				
			||||||
                self.debugmsg = None
 | 
					                self.debugmsg = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            def warn(self, msg=None, *args, **kwargs):
 | 
					            def warning(self, msg=None, *args, **kwargs):
 | 
				
			||||||
                self.msg = msg
 | 
					                self.msg = msg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            def debug(self, msg=None, *args, **kwargs):
 | 
					            def debug(self, msg=None, *args, **kwargs):
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -331,7 +331,7 @@ class positional(object):
 | 
				
			|||||||
                if self._enforcement == self.EXCEPT:
 | 
					                if self._enforcement == self.EXCEPT:
 | 
				
			||||||
                    raise TypeError(message)
 | 
					                    raise TypeError(message)
 | 
				
			||||||
                elif self._enforcement == self.WARN:
 | 
					                elif self._enforcement == self.WARN:
 | 
				
			||||||
                    logger.warn(message)
 | 
					                    logger.warning(message)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return func(*args, **kwargs)
 | 
					            return func(*args, **kwargs)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user