LOG.warn -> 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.

In addition to this there will be a hacking rule to prevent this
(https://review.openstack.org/#/c/262257/)

TrivialFix

Change-Id: I3967a52682500bfe4ceccd42fe6155778128d8fb
This commit is contained in:
Gary Kotton 2015-12-31 01:35:31 -08:00
parent a17cf32886
commit e704ae1329
12 changed files with 54 additions and 53 deletions

View File

@ -118,7 +118,7 @@ class ChanceScheduler(object):
active_agents = plugin.db.get_lbaas_agents(context, active=True)
if not active_agents:
LOG.warn(
LOG.warning(
_LW('No active lbaas agents for load balancer %s'),
loadbalancer.id)
return
@ -126,8 +126,8 @@ class ChanceScheduler(object):
candidates = plugin.db.get_lbaas_agent_candidates(device_driver,
active_agents)
if not candidates:
LOG.warn(_LW('No lbaas agent supporting device driver %s'),
device_driver)
LOG.warning(_LW('No lbaas agent supporting device driver %s'),
device_driver)
return
chosen_agent = random.choice(candidates)

View File

@ -154,8 +154,8 @@ class HaproxyNSDriver(agent_device_driver.AgentDeviceDriver):
lb_stats['members'] = self._get_servers_stats(parsed_stats)
return lb_stats
else:
LOG.warn(_LW('Stats socket not found for loadbalancer %s') %
loadbalancer_id)
LOG.warning(_LW('Stats socket not found for loadbalancer %s'),
loadbalancer_id)
return {}
@n_utils.synchronized('haproxy-driver')
@ -228,7 +228,7 @@ class HaproxyNSDriver(agent_device_driver.AgentDeviceDriver):
return self._parse_stats(raw_stats)
except socket.error as e:
LOG.warn(_LW('Error while connecting to stats socket: %s'), e)
LOG.warning(_LW('Error while connecting to stats socket: %s'), e)
return {}
def _parse_stats(self, raw_stats):

View File

@ -117,8 +117,8 @@ class HaproxyNSDriver(driver_base.LoadBalancerBaseDriver):
self.update_instance(loadbalancer)
except RuntimeError:
# do not stop anything this is a minor error
LOG.warn(_LW("Existing load balancer %s could not be deployed"
" on the system.") % loadbalancer.id)
LOG.warning(_LW("Existing load balancer %s could not be "
"deployed on the system."), loadbalancer.id)
def _retrieve_deployed_instance_dirs(self):
if not os.path.exists(self.state_path):
@ -282,7 +282,7 @@ class HaproxyNSDriver(driver_base.LoadBalancerBaseDriver):
return self._parse_stats(raw_stats)
except socket.error as e:
LOG.warn(_LW('Error while connecting to stats socket: %s'), e)
LOG.warning(_LW('Error while connecting to stats socket: %s'), e)
return {}
def _parse_stats(self, raw_stats):
@ -350,8 +350,8 @@ class HaproxyNSDriver(driver_base.LoadBalancerBaseDriver):
if ip_lib.device_exists(device.name):
self.vif_driver.unplug(device.name, namespace=namespace)
except RuntimeError as re:
LOG.warn(_LW('An error happened on namespace cleanup: '
'%s') % re.message)
LOG.warning(_LW('An error happened on namespace cleanup: '
'%s'), re.message)
ns.garbage_collect_namespace()
def _kill_processes(self, loadbalancer_id):
@ -429,8 +429,8 @@ class HaproxyNSDriver(driver_base.LoadBalancerBaseDriver):
lb_stats['members'] = self._get_servers_stats(parsed_stats)
return lb_stats
else:
LOG.warn(_LW('Stats socket not found for load balancer %s'),
loadbalancer.id)
LOG.warning(_LW('Stats socket not found for load balancer %s'),
loadbalancer.id)
return {}

View File

@ -114,14 +114,15 @@ class SchedulerBase(object):
active_agents = plugin.get_lbaas_agents(context, active=True)
if not active_agents:
LOG.warn(_LW('No active lbaas agents for pool %s'), pool['id'])
LOG.warning(_LW('No active lbaas agents for pool %s'),
pool['id'])
return
candidates = plugin.get_lbaas_agent_candidates(device_driver,
active_agents)
if not candidates:
LOG.warn(_LW('No lbaas agent supporting device driver %s'),
device_driver)
LOG.warning(_LW('No lbaas agent supporting device driver %s'),
device_driver)
return
chosen_agent = self._schedule(candidates, plugin, context)

View File

@ -175,7 +175,7 @@ class HaproxyNSDriver(agent_device_driver.AgentDeviceDriver):
pool_stats['members'] = self._get_servers_stats(parsed_stats)
return pool_stats
else:
LOG.warn(_LW('Stats socket not found for pool %s'), pool_id)
LOG.warning(_LW('Stats socket not found for pool %s'), pool_id)
return {}
def _get_backend_stats(self, parsed_stats):
@ -217,7 +217,7 @@ class HaproxyNSDriver(agent_device_driver.AgentDeviceDriver):
return self._parse_stats(raw_stats)
except socket.error as e:
LOG.warn(_LW('Error while connecting to stats socket: %s'), e)
LOG.warning(_LW('Error while connecting to stats socket: %s'), e)
return {}
def _parse_stats(self, raw_stats):

View File

@ -18,9 +18,9 @@ from neutron_lbaas._i18n import _LW
from neutron_lbaas.drivers.haproxy import synchronous_namespace_driver
LOG = logging.getLogger(__name__)
LOG.warn(_LW("This path has been deprecated. "
"Use neutron_lbaas.drivers.haproxy."
"synchronous_namespace_driver instead."))
LOG.warning(_LW("This path has been deprecated. "
"Use neutron_lbaas.drivers.haproxy."
"synchronous_namespace_driver instead."))
class HaproxyNSDriver(synchronous_namespace_driver.HaproxyNSDriver):

View File

@ -18,6 +18,6 @@ from neutron_lbaas._i18n import _LW
from neutron_lbaas.drivers import logging_noop
LOG = logging.getLogger(__name__)
LOG.warn(_LW("This path has been deprecated. "
"Use neutron_lbaas.drivers.logging_noop instead."))
LOG.warning(_LW("This path has been deprecated. "
"Use neutron_lbaas.drivers.logging_noop instead."))
__path__ = logging_noop.__path__

View File

@ -64,13 +64,13 @@ def get_network_from_name(name, compute_networks_client):
name, networks))
if caller:
msg = '(%s) %s' % (caller, msg)
LOG.warn(msg)
LOG.warning(msg)
raise exceptions.InvalidConfiguration()
else:
msg = "Network with name: %s not found" % name
if caller:
msg = '(%s) %s' % (caller, msg)
LOG.warn(msg)
LOG.warning(msg)
raise exceptions.InvalidConfiguration()
# To be consistent between neutron and nova network always use name even
# if label is used in the api response. If neither is present than then
@ -80,7 +80,7 @@ def get_network_from_name(name, compute_networks_client):
msg = "Network found from list doesn't contain a valid name or label"
if caller:
msg = '(%s) %s' % (caller, msg)
LOG.warn(msg)
LOG.warning(msg)
raise exceptions.InvalidConfiguration()
network['name'] = name
return network
@ -135,6 +135,6 @@ def set_networks_kwarg(network, kwargs=None):
if 'id' in network.keys():
params.update({"networks": [{'uuid': network['id']}]})
else:
LOG.warn('The provided network dict: %s was invalid and did not '
' contain an id' % network)
LOG.warning('The provided network dict: %s was invalid and did '
'not contain an id', network)
return params

View File

@ -348,24 +348,24 @@ class IsolatedCreds(cred_provider.CredentialProvider):
try:
net_client.delete_router(router_id)
except lib_exc.NotFound:
LOG.warn('router with name: %s not found for delete' %
router_name)
LOG.warning('router with name: %s not found for delete',
router_name)
def _clear_isolated_subnet(self, subnet_id, subnet_name):
net_client = self.network_admin_client
try:
net_client.delete_subnet(subnet_id)
except lib_exc.NotFound:
LOG.warn('subnet with name: %s not found for delete' %
subnet_name)
LOG.warning('subnet with name: %s not found for delete',
subnet_name)
def _clear_isolated_network(self, network_id, network_name):
net_client = self.network_admin_client
try:
net_client.delete_network(network_id)
except lib_exc.NotFound:
LOG.warn('network with name: %s not found for delete' %
network_name)
LOG.warning('network with name: %s not found for delete',
network_name)
def _cleanup_default_secgroup(self, tenant):
net_client = self.network_admin_client
@ -376,8 +376,8 @@ class IsolatedCreds(cred_provider.CredentialProvider):
try:
net_client.delete_security_group(secgroup['id'])
except lib_exc.NotFound:
LOG.warn('Security group %s, id %s not found for clean-up' %
(secgroup['name'], secgroup['id']))
LOG.warning('Security group %s, id %s not found for clean-up',
secgroup['name'], secgroup['id'])
def _clear_isolated_net_resources(self):
net_client = self.network_admin_client
@ -396,8 +396,8 @@ class IsolatedCreds(cred_provider.CredentialProvider):
net_client.remove_router_interface_with_subnet_id(
creds.router['id'], creds.subnet['id'])
except lib_exc.NotFound:
LOG.warn('router with name: %s not found for delete' %
creds.router['name'])
LOG.warning('router with name: %s not found for delete',
creds.router['name'])
self._clear_isolated_router(creds.router['id'],
creds.router['name'])
if (not self.network_resources or
@ -417,15 +417,15 @@ class IsolatedCreds(cred_provider.CredentialProvider):
try:
self.creds_client.delete_user(creds.user_id)
except lib_exc.NotFound:
LOG.warn("user with name: %s not found for delete" %
creds.username)
LOG.warning("user with name: %s not found for delete",
creds.username)
try:
if CONF.service_available.neutron:
self._cleanup_default_secgroup(creds.tenant_id)
self.creds_client.delete_project(creds.tenant_id)
except lib_exc.NotFound:
LOG.warn("tenant with name: %s not found for delete" %
creds.tenant_name)
LOG.warning("tenant with name: %s not found for delete",
creds.tenant_name)
self.isolated_creds = {}
def is_multi_user(self):

View File

@ -70,8 +70,8 @@ def clear_validation_resources(os, validation_data=None):
try:
keypair_client.delete_keypair(keypair_name)
except lib_exc.NotFound:
LOG.warn("Keypair %s is not found when attempting to delete"
% keypair_name)
LOG.warning("Keypair %s is not found when attempting to "
"delete", keypair_name)
except Exception as exc:
LOG.exception('Exception raised while deleting key %s'
% keypair_name)
@ -84,8 +84,8 @@ def clear_validation_resources(os, validation_data=None):
security_group_client.delete_security_group(sec_id)
security_group_client.wait_for_resource_deletion(sec_id)
except lib_exc.NotFound:
LOG.warn("Security group %s is not found when attempting to "
" delete" % sec_id)
LOG.warning("Security group %s is not found when attempting "
"to delete", sec_id)
except lib_exc.Conflict as exc:
LOG.exception('Conflict while deleting security '
'group %s VM might not be deleted ' % sec_id)
@ -102,8 +102,8 @@ def clear_validation_resources(os, validation_data=None):
try:
floating_client.delete_floating_ip(fip_id)
except lib_exc.NotFound:
LOG.warn('Floating ip %s not found while attempting to delete'
% fip_id)
LOG.warning('Floating ip %s not found while attempting to delete',
fip_id)
except Exception as exc:
LOG.exception('Exception raised while deleting ip %s '
% fip_id)

View File

@ -381,8 +381,8 @@ class BaseTestCase(testtools.testcase.WithAttributes,
cls.validation_resources = vresources.create_validation_resources(
cls.os, cls.validation_resources)
else:
LOG.warn("Client manager not found, validation resources not"
" created")
LOG.warning("Client manager not found, validation resources not"
" created")
@classmethod
def resource_cleanup(cls):
@ -396,8 +396,8 @@ class BaseTestCase(testtools.testcase.WithAttributes,
cls.validation_resources)
cls.validation_resources = {}
else:
LOG.warn("Client manager not found, validation resources not"
" deleted")
LOG.warning("Client manager not found, validation resources "
"not deleted")
def setUp(self):
super(BaseTestCase, self).setUp()

View File

@ -775,7 +775,7 @@ class NetworkScenarioTest(ScenarioTest):
try:
source.ping_host(dest)
except lib_exc.SSHExecCommandFailed:
LOG.warn(_LW(
LOG.warning(_LW(
"Failed to ping IP {des} via a ssh connection from: {src}"
).format(des=dest, src=source.ssh_client.host))
return not should_succeed