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: Icafbee2e8615aa8a246de3e2e796c685257b6cd4
changes/13/819613/2
Takashi Kajinami 10 months ago committed by Manpreet Kaur
parent 65b7fa8cd5
commit fee4d127dd
  1. 1
      HACKING.rst
  2. 2
      samples/mgmt_driver/kubernetes_mgmt.py
  3. 12
      tacker/conductor/conductor_server.py
  4. 12
      tacker/glance_store/store.py
  5. 13
      tacker/hacking/checks.py
  6. 1
      tox.ini

@ -9,6 +9,7 @@ Tacker Specific Commandments
----------------------------
- [N320] Validate that LOG messages, except debug ones, have translations
- [T301] Log.warn is deprecated. Enforce use of LOG.warning.
Creating Unit Tests
-------------------

@ -274,7 +274,7 @@ class KubernetesMgmtDriver(vnflcm_abstract_driver.VnflcmMgmtAbstractDriver):
msg = 'Failed to find specified zone id' \
' related to Vnfc Resource {} in grant'.format(
vnfc_id)
LOG.warn(msg)
LOG.warning(msg)
else:
for zone in grant.zones:
if add_resource_zone_id == zone.id:

@ -1791,7 +1791,7 @@ class Conductor(manager.Manager, v2_hook.ConductorV2Hook):
notification_type=notification.get('notificationType')
)
if not vnf_lcm_subscriptions:
LOG.warn(
LOG.warning(
"vnf_lcm_subscription not found id[%s]" %
notification.get('vnfInstanceId'))
return -1
@ -1851,20 +1851,20 @@ class Conductor(manager.Manager, v2_hook.ConductorV2Hook):
"reason": str(e)})
self._retry_check(num)
except Exception as e:
LOG.warn("send error[%s]" % str(e))
LOG.warn(traceback.format_exc())
LOG.warning("send error[%s]" % str(e))
LOG.warning(traceback.format_exc())
continue
except Exception as e:
LOG.warn("Internal Sever Error[%s]" % str(e))
LOG.warn(traceback.format_exc())
LOG.warning("Internal Sever Error[%s]" % str(e))
LOG.warning(traceback.format_exc())
return -2
return 0
def _retry_check(self, retry_count):
time.sleep(CONF.vnf_lcm.retry_wait)
if retry_count == CONF.vnf_lcm.retry_num:
LOG.warn(
LOG.warning(
"Number of retries exceeded retry count [%s]" %
CONF.vnf_lcm.retry_num)

@ -52,8 +52,8 @@ def get_csar_data_iter(body):
return data_iter
except Exception as e:
error = encodeutils.exception_to_unicode(e)
LOG.warn("Failed to open csar URL: %(url)s due to error: %(error)s",
{"url": url, "error": error})
LOG.warning("Failed to open csar URL: %(url)s due to error: %(error)s",
{"url": url, "error": error})
raise exceptions.VNFPackageURLInvalid(url=url)
@ -73,10 +73,10 @@ def store_csar(context, package_uuid, body):
context=context)
except Exception as e:
error = encodeutils.exception_to_unicode(e)
LOG.warn("Failed to store csar data in glance store for "
"package %(uuid)s due to error: %(error)s",
{"uuid": package_uuid,
"error": error})
LOG.warning("Failed to store csar data in glance store for "
"package %(uuid)s due to error: %(error)s",
{"uuid": package_uuid,
"error": error})
raise exceptions.UploadFailedToGlanceStore(uuid=package_uuid,
error=error)
finally:

@ -46,3 +46,16 @@ def validate_log_translations(physical_line, logical_line, filename):
msg = "N320: Log messages require translations!"
if log_translation.match(logical_line):
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 = ("T301: LOG.warn is deprecated, please use LOG.warning!")
if "LOG.warn(" in logical_line:
yield (0, msg)

@ -130,6 +130,7 @@ import_exceptions = tacker._i18n
[flake8:local-plugins]
extension =
N320 = checks:validate_log_translations
T301 = checks:no_log_warn
paths = ./tacker/hacking
[testenv:config-gen]

Loading…
Cancel
Save