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
This commit is contained in:
zhangguoqing 2016-01-04 14:45:04 +00:00
parent 216082b439
commit ff28020ab7
7 changed files with 35 additions and 33 deletions

View File

@ -98,7 +98,7 @@ def _get_pagination_max_limit():
if max_limit == 0: if max_limit == 0:
raise ValueError() raise ValueError()
except ValueError: except ValueError:
LOG.warn(_("Invalid value for pagination_max_limit: %s. It " LOG.warning(_("Invalid value for pagination_max_limit: %s. It "
"should be an integer greater to 0"), "should be an integer greater to 0"),
cfg.CONF.pagination_max_limit) cfg.CONF.pagination_max_limit)
return max_limit return max_limit

View File

@ -556,7 +556,7 @@ class ExtensionManager(object):
ext_name = mod_name[0].upper() + mod_name[1:] ext_name = mod_name[0].upper() + mod_name[1:]
new_ext_class = getattr(mod, ext_name, None) new_ext_class = getattr(mod, ext_name, None)
if not new_ext_class: if not new_ext_class:
LOG.warn(_('Did not find expected name ' LOG.warning(_('Did not find expected name '
'"%(ext_name)s" in %(file)s'), '"%(ext_name)s" in %(file)s'),
{'ext_name': ext_name, {'ext_name': ext_name,
'file': ext_path}) 'file': ext_path})
@ -564,8 +564,9 @@ class ExtensionManager(object):
new_ext = new_ext_class() new_ext = new_ext_class()
self.add_extension(new_ext) self.add_extension(new_ext)
except Exception as exception: except Exception as exception:
LOG.warn(_("Extension file %(f)s wasn't loaded due to " LOG.warning(_("Extension file %(f)s wasn't loaded due to "
"%(exception)s"), {'f': f, 'exception': exception}) "%(exception)s"),
{'f': f, 'exception': exception})
def add_extension(self, ext): def add_extension(self, ext):
# Do nothing if the extension doesn't check out # Do nothing if the extension doesn't check out

View File

@ -497,7 +497,7 @@ class VNFMPluginDb(vnfm.VNFMPluginBase, db_base.CommonDbMixin):
filter(~Device.status.in_(exclude_status)). filter(~Device.status.in_(exclude_status)).
with_lockmode('update').one()) with_lockmode('update').one())
except orm_exc.NoResultFound: except orm_exc.NoResultFound:
LOG.warn(_('no device found %s'), device_id) LOG.warning(_('no device found %s'), device_id)
return False return False
device_db.update({'status': new_status}) device_db.update({'status': new_status})

View File

@ -79,8 +79,8 @@ 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(_('task run outlasted interval by %s sec') % LOG.warning(_('task run outlasted interval by %s '
-delay) '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()

View File

@ -92,7 +92,7 @@ def _set_rules(data):
for pol in policies.keys(): for pol in policies.keys():
if any([pol.startswith(depr_pol) for depr_pol in if any([pol.startswith(depr_pol) for depr_pol in
DEPRECATED_POLICY_MAP.keys()]): DEPRECATED_POLICY_MAP.keys()]):
LOG.warn(_("Found deprecated policy rule:%s. Please consider " LOG.warning(_("Found deprecated policy rule:%s. Please consider "
"upgrading your policy configuration file"), pol) "upgrading your policy configuration file"), pol)
pol_name, action = pol.rsplit(':', 1) pol_name, action = pol.rsplit(':', 1)
try: try:
@ -134,7 +134,7 @@ def _build_subattr_match_rule(attr_name, attr, action, target):
validate = attr['validate'] validate = attr['validate']
key = filter(lambda k: k.startswith('type:dict'), validate.keys()) key = filter(lambda k: k.startswith('type:dict'), validate.keys())
if not key: if not key:
LOG.warn(_("Unable to find data type descriptor for attribute %s"), LOG.warning(_("Unable to find data type descriptor for attribute %s"),
attr_name) attr_name)
return return
data = validate[key[0]] data = validate[key[0]]

View File

@ -339,7 +339,7 @@ class DeviceHeat(abstract_driver.DeviceAbstractDriver):
LOG.debug(_('stack status: %(stack)s %(status)s'), LOG.debug(_('stack status: %(stack)s %(status)s'),
{'stack': str(stack), 'status': status}) {'stack': str(stack), 'status': status})
if stack_retries == 0: if stack_retries == 0:
LOG.warn(_("Resource creation is" LOG.warning(_("Resource creation is"
" not completed within %(wait)s seconds as " " not completed within %(wait)s seconds as "
"creation of Stack %(stack)s is not completed"), "creation of Stack %(stack)s is not completed"),
{'wait': (STACK_RETRIES * STACK_RETRY_WAIT), {'wait': (STACK_RETRIES * STACK_RETRY_WAIT),
@ -428,13 +428,13 @@ class DeviceHeat(abstract_driver.DeviceAbstractDriver):
stack_retries = stack_retries - 1 stack_retries = stack_retries - 1
if stack_retries == 0: if stack_retries == 0:
LOG.warn(_("Resource cleanup for device is" LOG.warning(_("Resource cleanup for device is"
" not completed within %(wait)s seconds as " " not completed within %(wait)s seconds as "
"deletion of Stack %(stack)s is not completed"), "deletion of Stack %(stack)s is not completed"),
{'wait': (STACK_RETRIES * STACK_RETRY_WAIT), {'wait': (STACK_RETRIES * STACK_RETRY_WAIT),
'stack': device_id}) 'stack': device_id})
if status != 'DELETE_COMPLETE': if status != 'DELETE_COMPLETE':
LOG.warn(_("device (%(device_id)d) deletion is not completed. " LOG.warning(_("device (%(device_id)d) deletion is not completed. "
"%(stack_status)s"), "%(stack_status)s"),
{'device_id': device_id, 'stack_status': status}) {'device_id': device_id, 'stack_status': status})
@ -470,7 +470,7 @@ class HeatClient(object):
try: try:
self.stacks.delete(stack_id) self.stacks.delete(stack_id)
except heatException.HTTPNotFound: except heatException.HTTPNotFound:
LOG.warn(_("Stack %(stack)s created by service chain driver is " LOG.warning(_("Stack %(stack)s created by service chain driver is "
"not found at cleanup"), {'stack': stack_id}) "not found at cleanup"), {'stack': stack_id})
def get(self, stack_id): def get(self, stack_id):

View File

@ -83,7 +83,8 @@ class DeviceMgmtOpenWRT(abstract_driver.DeviceMGMTAbstractDriver):
continue continue
mgmt_ip_address = mgmt_url.get(vdu, '') mgmt_ip_address = mgmt_url.get(vdu, '')
if not mgmt_ip_address: if not mgmt_ip_address:
LOG.warn(_('tried to configure unknown mgmt address %s'), LOG.warning(_('tried to configure unknown mgmt '
'address %s'),
vdu) vdu)
continue continue
self._config_service(mgmt_ip_address, key, conf_value) self._config_service(mgmt_ip_address, key, conf_value)