Python 3 deprecated the logger.warn method in favor of warning
According to https://docs.python.org/3/library/logging.html#logging.warning, We prefer to use warning to avoid DeprecationWarning. Change-Id: I29e960b3ba179e0701a57aee84cff6bdf4105db5
This commit is contained in:
parent
342b0913b4
commit
a89ac06029
@ -95,11 +95,11 @@ class RetryDecorator(object):
|
|||||||
result = f(*args, **kwargs)
|
result = f(*args, **kwargs)
|
||||||
except self._exceptions:
|
except self._exceptions:
|
||||||
with excutils.save_and_reraise_exception() as ctxt:
|
with excutils.save_and_reraise_exception() as ctxt:
|
||||||
LOG.warn(_LW("Exception which is in the suggested list of "
|
LOG.warning(_LW("Exception which is in the suggested list "
|
||||||
"exceptions occurred while invoking function:"
|
"of exceptions occurred while invoking "
|
||||||
" %s."),
|
"function: %s."),
|
||||||
func_name,
|
func_name,
|
||||||
exc_info=True)
|
exc_info=True)
|
||||||
if (self._max_retry_count != -1 and
|
if (self._max_retry_count != -1 and
|
||||||
self._retry_count >= self._max_retry_count):
|
self._retry_count >= self._max_retry_count):
|
||||||
LOG.error(_LE("Cannot retry upon suggested exception "
|
LOG.error(_LE("Cannot retry upon suggested exception "
|
||||||
@ -494,8 +494,8 @@ class VMwareAPISession(object):
|
|||||||
lease,
|
lease,
|
||||||
'error')
|
'error')
|
||||||
except exceptions.VimException:
|
except exceptions.VimException:
|
||||||
LOG.warn(_LW("Error occurred while reading error message for "
|
LOG.warning(_LW("Error occurred while reading error message for "
|
||||||
"lease: %s."),
|
"lease: %s."),
|
||||||
lease,
|
lease,
|
||||||
exc_info=True)
|
exc_info=True)
|
||||||
return "Unknown"
|
return "Unknown"
|
||||||
|
@ -79,8 +79,9 @@ class FixedIntervalLoopingCall(LoopingCallBase):
|
|||||||
break
|
break
|
||||||
delay = interval - timeutils.delta_seconds(start, end)
|
delay = interval - timeutils.delta_seconds(start, end)
|
||||||
if delay <= 0:
|
if delay <= 0:
|
||||||
LOG.warn(_LW('task run outlasted interval by %s sec'),
|
LOG.warning(_LW('task run outlasted interval '
|
||||||
-delay)
|
'by %s sec'),
|
||||||
|
-delay)
|
||||||
greenthread.sleep(delay if delay > 0 else 0)
|
greenthread.sleep(delay if delay > 0 else 0)
|
||||||
except LoopingCallDone as e:
|
except LoopingCallDone as e:
|
||||||
self.stop()
|
self.stop()
|
||||||
|
@ -168,8 +168,8 @@ class ImageTransferException(VMwareDriverException):
|
|||||||
|
|
||||||
|
|
||||||
def _print_deprecation_warning(clazz):
|
def _print_deprecation_warning(clazz):
|
||||||
LOG.warn(_LW("Exception %s is deprecated, it will be removed in the "
|
LOG.warning(_LW("Exception %s is deprecated, it will be removed in the "
|
||||||
"next release."), clazz.__name__)
|
"next release."), clazz.__name__)
|
||||||
|
|
||||||
|
|
||||||
class VMwareDriverConfigurationException(VMwareDriverException):
|
class VMwareDriverConfigurationException(VMwareDriverException):
|
||||||
|
@ -196,7 +196,7 @@ def get_pbm_wsdl_location(vc_version):
|
|||||||
pbm_service_wsdl = os.path.join(curr_dir, 'wsdl', major_minor,
|
pbm_service_wsdl = os.path.join(curr_dir, 'wsdl', major_minor,
|
||||||
'pbmService.wsdl')
|
'pbmService.wsdl')
|
||||||
if not os.path.exists(pbm_service_wsdl):
|
if not os.path.exists(pbm_service_wsdl):
|
||||||
LOG.warn(_LW("PBM WSDL file %s not found."), pbm_service_wsdl)
|
LOG.warning(_LW("PBM WSDL file %s not found."), pbm_service_wsdl)
|
||||||
return
|
return
|
||||||
pbm_wsdl = urlparse.urljoin('file:', urllib.pathname2url(pbm_service_wsdl))
|
pbm_wsdl = urlparse.urljoin('file:', urllib.pathname2url(pbm_service_wsdl))
|
||||||
LOG.debug("Using PBM WSDL location: %s.", pbm_wsdl)
|
LOG.debug("Using PBM WSDL location: %s.", pbm_wsdl)
|
||||||
|
@ -152,8 +152,8 @@ class FileHandle(object):
|
|||||||
try:
|
try:
|
||||||
self._file_handle.close()
|
self._file_handle.close()
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.warn(_LW("Error occurred while closing the file handle"),
|
LOG.warning(_LW("Error occurred while closing the file handle"),
|
||||||
exc_info=True)
|
exc_info=True)
|
||||||
|
|
||||||
def _build_vim_cookie_header(self, vim_cookies):
|
def _build_vim_cookie_header(self, vim_cookies):
|
||||||
"""Build ESX host session cookie header."""
|
"""Build ESX host session cookie header."""
|
||||||
@ -300,8 +300,8 @@ class FileWriteHandle(FileHandle):
|
|||||||
try:
|
try:
|
||||||
self._conn.getresponse()
|
self._conn.getresponse()
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.warn(_LW("Error occurred while reading the HTTP response."),
|
LOG.warning(_LW("Error occurred while reading the HTTP response."),
|
||||||
exc_info=True)
|
exc_info=True)
|
||||||
super(FileWriteHandle, self).close()
|
super(FileWriteHandle, self).close()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
@ -473,9 +473,10 @@ class VmdkWriteHandle(FileHandle):
|
|||||||
{'url': self._url,
|
{'url': self._url,
|
||||||
'state': state})
|
'state': state})
|
||||||
except exceptions.VimException:
|
except exceptions.VimException:
|
||||||
LOG.warn(_LW("Error occurred while releasing the lease for %s."),
|
LOG.warning(_LW("Error occurred while releasing the lease "
|
||||||
self._url,
|
"for %s."),
|
||||||
exc_info=True)
|
self._url,
|
||||||
|
exc_info=True)
|
||||||
super(VmdkWriteHandle, self).close()
|
super(VmdkWriteHandle, self).close()
|
||||||
LOG.debug("Closed VMDK write handle for %s.", self._url)
|
LOG.debug("Closed VMDK write handle for %s.", self._url)
|
||||||
|
|
||||||
@ -611,9 +612,10 @@ class VmdkReadHandle(FileHandle):
|
|||||||
{'url': self._url,
|
{'url': self._url,
|
||||||
'state': state})
|
'state': state})
|
||||||
except exceptions.VimException:
|
except exceptions.VimException:
|
||||||
LOG.warn(_LW("Error occurred while releasing the lease for %s."),
|
LOG.warning(_LW("Error occurred while releasing the lease "
|
||||||
self._url,
|
"for %s."),
|
||||||
exc_info=True)
|
self._url,
|
||||||
|
exc_info=True)
|
||||||
raise
|
raise
|
||||||
super(VmdkReadHandle, self).close()
|
super(VmdkReadHandle, self).close()
|
||||||
LOG.debug("Closed VMDK read handle for %s.", self._url)
|
LOG.debug("Closed VMDK read handle for %s.", self._url)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user