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: I3a057080b7b888b2c246ad9910ddba564b07dbd9
Closes-Bug: #1530742
This commit is contained in:
zhangguoqing 2016-01-04 06:17:21 +00:00
parent 99da10d2e1
commit 6c0966470c
9 changed files with 43 additions and 41 deletions

View File

@ -278,8 +278,8 @@ class BaseV2ComputeTest(api_version_utils.BaseMicroversionTest,
# into the delete_volume method as a convenience to the caller.
volumes_client.wait_for_resource_deletion(volume_id)
except lib_exc.NotFound:
LOG.warn("Unable to delete volume '%s' since it was not found. "
"Maybe it was already deleted?" % volume_id)
LOG.warning("Unable to delete volume '%s' since it was not found. "
"Maybe it was already deleted?" % volume_id)
@classmethod
def prepare_instance_network(cls):

View File

@ -201,7 +201,8 @@ def create_resources(opts, resources):
if tenant not in existing:
tenants_admin.create_tenant(tenant)
else:
LOG.warn("Tenant '%s' already exists in this environment" % tenant)
LOG.warning("Tenant '%s' already exists in this environment"
% tenant)
LOG.info('Tenants created')
for u in resources['users']:
try:
@ -220,8 +221,8 @@ def create_resources(opts, resources):
enabled=True)
break
else:
LOG.warn("User '%s' already exists in this environment. "
"New name generated" % u['name'])
LOG.warning("User '%s' already exists in this environment. "
"New name generated" % u['name'])
u['name'] = random_user_name(opts.tag, u['prefix'])
LOG.info('Users created')

View File

@ -311,7 +311,8 @@ def create_tenants(tenants):
if tenant not in existing:
admin.tenants.create_tenant(tenant)['tenant']
else:
LOG.warn("Tenant '%s' already exists in this environment" % tenant)
LOG.warning("Tenant '%s' already exists in this environment"
% tenant)
def destroy_tenants(tenants):
@ -376,8 +377,8 @@ def create_users(users):
try:
identity.get_user_by_username(admin.identity,
tenant['id'], u['name'])
LOG.warn("User '%s' already exists in this environment"
% u['name'])
LOG.warning("User '%s' already exists in this environment"
% u['name'])
except lib_exc.NotFound:
admin.identity.create_user(
u['name'], u['pass'], tenant['id'],
@ -1074,7 +1075,7 @@ def destroy_resources():
destroy_secgroups(RES['secgroups'])
destroy_users(RES['users'])
destroy_tenants(RES['tenants'])
LOG.warn("Destroy mode incomplete")
LOG.warning("Destroy mode incomplete")
def get_options():

View File

@ -285,24 +285,24 @@ class DynamicCredentialProvider(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):
client = self.subnets_admin_client
try:
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.networks_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):
nsg_client = self.security_groups_admin_client
@ -313,8 +313,8 @@ class DynamicCredentialProvider(cred_provider.CredentialProvider):
try:
nsg_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
@ -333,8 +333,8 @@ class DynamicCredentialProvider(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
@ -354,15 +354,15 @@ class DynamicCredentialProvider(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._creds = {}
def is_multi_user(self):

View File

@ -49,13 +49,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.InvalidTestResource(type='network', name=name)
else:
msg = "Network with name: %s not found" % name
if caller:
msg = '(%s) %s' % (caller, msg)
LOG.warn(msg)
LOG.warning(msg)
raise exceptions.InvalidTestResource(type='network', name=name)
# 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
@ -65,7 +65,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.InvalidTestResource(type='network', name=name)
network['name'] = name
return network
@ -122,6 +122,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

@ -73,8 +73,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)
@ -87,8 +87,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)
@ -105,8 +105,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

@ -932,8 +932,8 @@ class NetworkScenarioTest(ScenarioTest):
try:
source.ping_host(dest, nic=nic)
except lib_exc.SSHExecCommandFailed:
LOG.warn('Failed to ping IP: %s via a ssh connection from: %s.'
% (dest, source.ssh_client.host))
LOG.warning('Failed to ping IP: %s via a ssh connection '
'from: %s.' % (dest, source.ssh_client.host))
return not should_succeed
return should_succeed

View File

@ -106,7 +106,7 @@ def terminate_all_processes(check_interval=20):
if process['process'].is_alive():
try:
pid = process['process'].pid
LOG.warn("Process %d hangs. Send SIGKILL." % pid)
LOG.warning("Process %d hangs. Send SIGKILL." % pid)
os.kill(pid, signal.SIGKILL)
except Exception:
pass

View File

@ -375,8 +375,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):
@ -391,8 +391,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()