From ff28020ab78f610baa0cc113fe36d7f71afa86eb Mon Sep 17 00:00:00 2001 From: zhangguoqing Date: Mon, 4 Jan 2016 14:45:04 +0000 Subject: [PATCH] Change LOG.warn to LOG.warning Python 3 deprecated the logger.warn method, see: https://docs.python.org/3/library/logging.html#logging.warning so we prefer to use warning to avoid DeprecationWarning. Change-Id: Iafbe78cdcfac329d3795853fe8cc38e549279375 Closes-Bug: #1530742 --- tacker/api/api_common.py | 6 ++--- tacker/api/extensions.py | 13 +++++----- tacker/db/vm/vm_db.py | 2 +- tacker/openstack/common/loopingcall.py | 4 +-- tacker/policy.py | 8 +++--- tacker/vm/drivers/heat/heat.py | 30 +++++++++++------------ tacker/vm/mgmt_drivers/openwrt/openwrt.py | 5 ++-- 7 files changed, 35 insertions(+), 33 deletions(-) diff --git a/tacker/api/api_common.py b/tacker/api/api_common.py index 6e3071f4b..4847d16fa 100644 --- a/tacker/api/api_common.py +++ b/tacker/api/api_common.py @@ -98,9 +98,9 @@ def _get_pagination_max_limit(): if max_limit == 0: raise ValueError() except ValueError: - LOG.warn(_("Invalid value for pagination_max_limit: %s. It " - "should be an integer greater to 0"), - cfg.CONF.pagination_max_limit) + LOG.warning(_("Invalid value for pagination_max_limit: %s. It " + "should be an integer greater to 0"), + cfg.CONF.pagination_max_limit) return max_limit diff --git a/tacker/api/extensions.py b/tacker/api/extensions.py index cf74d7c94..bba12c0b2 100644 --- a/tacker/api/extensions.py +++ b/tacker/api/extensions.py @@ -556,16 +556,17 @@ class ExtensionManager(object): ext_name = mod_name[0].upper() + mod_name[1:] new_ext_class = getattr(mod, ext_name, None) if not new_ext_class: - LOG.warn(_('Did not find expected name ' - '"%(ext_name)s" in %(file)s'), - {'ext_name': ext_name, - 'file': ext_path}) + LOG.warning(_('Did not find expected name ' + '"%(ext_name)s" in %(file)s'), + {'ext_name': ext_name, + 'file': ext_path}) continue new_ext = new_ext_class() self.add_extension(new_ext) except Exception as exception: - LOG.warn(_("Extension file %(f)s wasn't loaded due to " - "%(exception)s"), {'f': f, 'exception': exception}) + LOG.warning(_("Extension file %(f)s wasn't loaded due to " + "%(exception)s"), + {'f': f, 'exception': exception}) def add_extension(self, ext): # Do nothing if the extension doesn't check out diff --git a/tacker/db/vm/vm_db.py b/tacker/db/vm/vm_db.py index 18bf8b8ca..2cafb8e1b 100644 --- a/tacker/db/vm/vm_db.py +++ b/tacker/db/vm/vm_db.py @@ -497,7 +497,7 @@ class VNFMPluginDb(vnfm.VNFMPluginBase, db_base.CommonDbMixin): filter(~Device.status.in_(exclude_status)). with_lockmode('update').one()) except orm_exc.NoResultFound: - LOG.warn(_('no device found %s'), device_id) + LOG.warning(_('no device found %s'), device_id) return False device_db.update({'status': new_status}) diff --git a/tacker/openstack/common/loopingcall.py b/tacker/openstack/common/loopingcall.py index c09f32bc3..f226d0419 100644 --- a/tacker/openstack/common/loopingcall.py +++ b/tacker/openstack/common/loopingcall.py @@ -79,8 +79,8 @@ class FixedIntervalLoopingCall(LoopingCallBase): break delay = interval - timeutils.delta_seconds(start, end) if delay <= 0: - LOG.warn(_('task run outlasted interval by %s sec') % - -delay) + LOG.warning(_('task run outlasted interval by %s ' + 'sec') % -delay) greenthread.sleep(delay if delay > 0 else 0) except LoopingCallDone as e: self.stop() diff --git a/tacker/policy.py b/tacker/policy.py index 622cd102d..d7d6e586c 100644 --- a/tacker/policy.py +++ b/tacker/policy.py @@ -92,8 +92,8 @@ def _set_rules(data): for pol in policies.keys(): if any([pol.startswith(depr_pol) for depr_pol in DEPRECATED_POLICY_MAP.keys()]): - LOG.warn(_("Found deprecated policy rule:%s. Please consider " - "upgrading your policy configuration file"), pol) + LOG.warning(_("Found deprecated policy rule:%s. Please consider " + "upgrading your policy configuration file"), pol) pol_name, action = pol.rsplit(':', 1) try: new_actions = DEPRECATED_ACTION_MAP[action] @@ -134,8 +134,8 @@ def _build_subattr_match_rule(attr_name, attr, action, target): validate = attr['validate'] key = filter(lambda k: k.startswith('type:dict'), validate.keys()) if not key: - LOG.warn(_("Unable to find data type descriptor for attribute %s"), - attr_name) + LOG.warning(_("Unable to find data type descriptor for attribute %s"), + attr_name) return data = validate[key[0]] if not isinstance(data, dict): diff --git a/tacker/vm/drivers/heat/heat.py b/tacker/vm/drivers/heat/heat.py index f13fa65a6..862006e3c 100644 --- a/tacker/vm/drivers/heat/heat.py +++ b/tacker/vm/drivers/heat/heat.py @@ -339,11 +339,11 @@ class DeviceHeat(abstract_driver.DeviceAbstractDriver): LOG.debug(_('stack status: %(stack)s %(status)s'), {'stack': str(stack), 'status': status}) if stack_retries == 0: - LOG.warn(_("Resource creation is" - " not completed within %(wait)s seconds as " - "creation of Stack %(stack)s is not completed"), - {'wait': (STACK_RETRIES * STACK_RETRY_WAIT), - 'stack': device_id}) + LOG.warning(_("Resource creation is" + " not completed within %(wait)s seconds as " + "creation of Stack %(stack)s is not completed"), + {'wait': (STACK_RETRIES * STACK_RETRY_WAIT), + 'stack': device_id}) if status != 'CREATE_COMPLETE': raise vnfm.DeviceCreateWaitFailed(device_id=device_id) outputs = stack.outputs @@ -428,15 +428,15 @@ class DeviceHeat(abstract_driver.DeviceAbstractDriver): stack_retries = stack_retries - 1 if stack_retries == 0: - LOG.warn(_("Resource cleanup for device is" - " not completed within %(wait)s seconds as " - "deletion of Stack %(stack)s is not completed"), - {'wait': (STACK_RETRIES * STACK_RETRY_WAIT), - 'stack': device_id}) + LOG.warning(_("Resource cleanup for device is" + " not completed within %(wait)s seconds as " + "deletion of Stack %(stack)s is not completed"), + {'wait': (STACK_RETRIES * STACK_RETRY_WAIT), + 'stack': device_id}) if status != 'DELETE_COMPLETE': - LOG.warn(_("device (%(device_id)d) deletion is not completed. " - "%(stack_status)s"), - {'device_id': device_id, 'stack_status': status}) + LOG.warning(_("device (%(device_id)d) deletion is not completed. " + "%(stack_status)s"), + {'device_id': device_id, 'stack_status': status}) @log.log def attach_interface(self, plugin, context, device_id, port_id): @@ -470,8 +470,8 @@ class HeatClient(object): try: self.stacks.delete(stack_id) except heatException.HTTPNotFound: - LOG.warn(_("Stack %(stack)s created by service chain driver is " - "not found at cleanup"), {'stack': stack_id}) + LOG.warning(_("Stack %(stack)s created by service chain driver is " + "not found at cleanup"), {'stack': stack_id}) def get(self, stack_id): return self.stacks.get(stack_id) diff --git a/tacker/vm/mgmt_drivers/openwrt/openwrt.py b/tacker/vm/mgmt_drivers/openwrt/openwrt.py index 5ff0479a8..2d07c3577 100644 --- a/tacker/vm/mgmt_drivers/openwrt/openwrt.py +++ b/tacker/vm/mgmt_drivers/openwrt/openwrt.py @@ -83,7 +83,8 @@ class DeviceMgmtOpenWRT(abstract_driver.DeviceMGMTAbstractDriver): continue mgmt_ip_address = mgmt_url.get(vdu, '') if not mgmt_ip_address: - LOG.warn(_('tried to configure unknown mgmt address %s'), - vdu) + LOG.warning(_('tried to configure unknown mgmt ' + 'address %s'), + vdu) continue self._config_service(mgmt_ip_address, key, conf_value)