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,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

View File

@ -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

View File

@ -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})

View File

@ -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()

View File

@ -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):

View File

@ -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)

View File

@ -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)