Use LOG.warning instead of deprecated LOG.warn
The LOG.warn method is deprecated[1] and the LOG.warning method should be used instead. [1] https://docs.python.org/3/library/logging.html#logging.warning Change-Id: I87d33f215a064a70cea989d524dc26affeea0c3e
This commit is contained in:
parent
83194a5f4f
commit
a03e10ceb0
@ -24,6 +24,7 @@ Cinder Specific Commandments
|
||||
sequence of key-value pairs.
|
||||
- [C337] Ensure the standard library mock modules is used and not the third
|
||||
party mock library that was needed for Python 2 support.
|
||||
- [C338] Log.warn is deprecated. Enforce use of LOG.warning.
|
||||
|
||||
General
|
||||
-------
|
||||
|
@ -386,3 +386,16 @@ def no_third_party_mock(logical_line):
|
||||
msg = ('C337: Unit tests should use the standard library "mock" '
|
||||
'module, not the third party mock lib.')
|
||||
yield(0, msg)
|
||||
|
||||
|
||||
@core.flake8ext
|
||||
def no_log_warn(logical_line):
|
||||
"""Disallow 'LOG.warn('
|
||||
|
||||
Use LOG.warning() instead of Deprecated LOG.warn().
|
||||
https://docs.python.org/3/library/logging.html#logging.warning
|
||||
"""
|
||||
|
||||
msg = ("C338: LOG.warn is deprecated, please use LOG.warning!")
|
||||
if "LOG.warn(" in logical_line:
|
||||
yield (0, msg)
|
||||
|
@ -209,6 +209,18 @@ class HackingTestCase(test.TestCase):
|
||||
self.assertEqual(1, len(list(checks.no_mutable_default_args(
|
||||
"def foo (bar={}):"))))
|
||||
|
||||
def test_no_log_warn(self):
|
||||
code = """
|
||||
LOG.warn("LOG.warn is deprecated")
|
||||
"""
|
||||
errors = [(1, 0, 'C338')]
|
||||
self._assert_has_errors(code, checks.no_log_warn,
|
||||
expected_errors=errors)
|
||||
code = """
|
||||
LOG.warning("LOG.warn is deprecated")
|
||||
"""
|
||||
self._assert_has_no_errors(code, checks.no_log_warn)
|
||||
|
||||
def test_check_datetime_now(self):
|
||||
self.assertEqual(1, len(list(checks.check_datetime_now(
|
||||
"datetime.now", False))))
|
||||
|
@ -677,10 +677,10 @@ class NetAppBlockStorageCmodeLibrary(block_base.NetAppBlockStorageLibrary,
|
||||
try:
|
||||
dest_client.destroy_lun(lun_path)
|
||||
except Exception:
|
||||
LOG.warn('Error cleaning up LUN %s in destination volume. '
|
||||
'Verify if destination volume still exists in pool '
|
||||
'%s and delete it manually to avoid unused '
|
||||
'resources.', lun_path, dest_pool)
|
||||
LOG.warning('Error cleaning up LUN %s in destination volume. '
|
||||
'Verify if destination volume still exists in '
|
||||
'pool %s and delete it manually to avoid unused '
|
||||
'resources.', lun_path, dest_pool)
|
||||
|
||||
def _copy_lun(self, volume, src_ontap_volume, src_vserver,
|
||||
dest_ontap_volume, dest_vserver, dest_lun_name=None,
|
||||
@ -803,7 +803,7 @@ class NetAppBlockStorageCmodeLibrary(block_base.NetAppBlockStorageLibrary,
|
||||
'performing operations with this volume. Check the '
|
||||
'migration status on the storage side and set '
|
||||
'volume status manually if migration succeeded.'))
|
||||
LOG.warn(error_msg, volume.id)
|
||||
LOG.warning(error_msg, volume.id)
|
||||
updates['status'] = fields.VolumeStatus.MAINTENANCE
|
||||
except na_utils.NetAppDriverException as e:
|
||||
error_msg = (_('Failed to migrate volume %(vol)s from pool '
|
||||
|
@ -1085,10 +1085,10 @@ class NetAppCmodeNfsDriver(nfs_base.NetAppNfsDriver,
|
||||
try:
|
||||
dest_client.delete_file(file_path)
|
||||
except Exception:
|
||||
LOG.warn('Error cleaning up file %s in destination volume. '
|
||||
'Verify if destination volume still exists in pool '
|
||||
'%s and delete it manually to avoid unused '
|
||||
'resources.', file_path, dest_pool)
|
||||
LOG.warning('Error cleaning up file %s in destination volume. '
|
||||
'Verify if destination volume still exists in '
|
||||
'pool %s and delete it manually to avoid unused '
|
||||
'resources.', file_path, dest_pool)
|
||||
|
||||
def _copy_file(self, volume, src_ontap_volume, src_vserver,
|
||||
dest_ontap_volume, dest_vserver, dest_file_name=None,
|
||||
|
@ -642,10 +642,10 @@ class Acs5000CommonDriver(san.SanDriver,
|
||||
'wanted': wanted_name})
|
||||
is_existed = self._cmd.get_volume(wanted_name)
|
||||
if len(is_existed) == 1:
|
||||
LOG.warn('volume name %(wanted)s is existed, The two volumes '
|
||||
'%(wanted)s and %(new)s may be on the same system.',
|
||||
{'new': existing_name,
|
||||
'wanted': wanted_name})
|
||||
LOG.warning('volume name %(wanted)s is existed, The two volumes '
|
||||
'%(wanted)s and %(new)s may be on the same system.',
|
||||
{'new': existing_name,
|
||||
'wanted': wanted_name})
|
||||
return {'_name_id': new_volume['_name_id'] or new_volume['id']}
|
||||
else:
|
||||
self._cmd.set_volume_property(existing_name,
|
||||
@ -730,10 +730,10 @@ class Acs5000CommonDriver(san.SanDriver,
|
||||
size = int(vol_backend.get('size_mb', 0))
|
||||
size_gb = int(math.ceil(size / 1024))
|
||||
if (size_gb * 1024) > size:
|
||||
LOG.warn('Volume %(vol)s capacity is %(mb)s MB, '
|
||||
'extend to %(gb)s GB.', {'vol': ref['source-name'],
|
||||
'mb': size,
|
||||
'gb': size_gb})
|
||||
LOG.warning('Volume %(vol)s capacity is %(mb)s MB, '
|
||||
'extend to %(gb)s GB.', {'vol': ref['source-name'],
|
||||
'mb': size,
|
||||
'gb': size_gb})
|
||||
self._cmd.extend_volume(ref['source-name'], size_gb)
|
||||
return size_gb
|
||||
|
||||
|
@ -139,9 +139,9 @@ class Acs5000FCDriver(acs5000_common.Acs5000CommonDriver):
|
||||
target_wwpns = self._get_connected_wwpns()
|
||||
if len(target_wwpns) == 0:
|
||||
target_wwpns = []
|
||||
LOG.warn('terminate_connection: Did not find '
|
||||
'available fc wwpns when volume %s '
|
||||
'delete lun map.', volume.id)
|
||||
LOG.warning('terminate_connection: Did not find '
|
||||
'available fc wwpns when volume %s '
|
||||
'delete lun map.', volume.id)
|
||||
|
||||
initiator_target = {}
|
||||
for i_wwpn in initiator_wwpns:
|
||||
@ -155,9 +155,9 @@ class Acs5000FCDriver(acs5000_common.Acs5000CommonDriver):
|
||||
self.protocol,
|
||||
initiator_wwpns)
|
||||
else:
|
||||
LOG.warn('volume %s has been mapped to multi VMs, and these VMs '
|
||||
'belong to the same host. The mapping cancellation '
|
||||
'request is aborted.', volume.id)
|
||||
LOG.warning('volume %s has been mapped to multi VMs, and these '
|
||||
'VMs belong to the same host. The mapping '
|
||||
'cancellation request is aborted.', volume.id)
|
||||
zone_utils.remove_fc_zone(properties)
|
||||
LOG.debug('leave: terminate_connection: volume '
|
||||
'%(vol)s with connector %(conn)s',
|
||||
|
@ -115,9 +115,9 @@ class Acs5000ISCSIDriver(acs5000_common.Acs5000CommonDriver):
|
||||
self.protocol,
|
||||
initiator)
|
||||
else:
|
||||
LOG.warn('volume %s has been mapped to multi VMs, and these VMs '
|
||||
'belong to the same host. The mapping cancellation '
|
||||
'request is aborted.', volume.id)
|
||||
LOG.warning('volume %s has been mapped to multi VMs, and these '
|
||||
'VMs belong to the same host. The mapping '
|
||||
'cancellation request is aborted.', volume.id)
|
||||
LOG.debug('leave: terminate_connection: volume '
|
||||
'%(vol)s with connector %(conn)s',
|
||||
{'vol': volume.id, 'conn': connector})
|
||||
|
Loading…
Reference in New Issue
Block a user