Remove unused logging import and LOG global
This patch removes unused global LOG variable and logging imports from various manila modules, and adds a script to be run as part of pep8 that will ensure that these do not creep back into the codebase. Change-Id: I162c4b2478df45aaf6ea8009b102d6de1a4e309e
This commit is contained in:
parent
9f1ee1809d
commit
72ab1442ad
@ -15,7 +15,6 @@
|
||||
|
||||
"""The Share Replication API."""
|
||||
|
||||
from oslo_log import log
|
||||
import six
|
||||
import webob
|
||||
from webob import exc
|
||||
@ -30,7 +29,6 @@ from manila.i18n import _
|
||||
from manila import share
|
||||
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
MIN_SUPPORTED_API_VERSION = '2.11'
|
||||
|
||||
|
||||
|
@ -21,7 +21,6 @@ from novaclient import client as nova_client
|
||||
from novaclient import exceptions as nova_exception
|
||||
from novaclient import utils
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
import six
|
||||
|
||||
from manila.common import client_auth
|
||||
@ -102,8 +101,6 @@ CONF.register_opts(nova_opts, NOVA_GROUP)
|
||||
ks_loading.register_session_conf_options(CONF, NOVA_GROUP)
|
||||
ks_loading.register_auth_conf_options(CONF, NOVA_GROUP)
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
def list_opts():
|
||||
return client_auth.AuthClientLoader.list_opts(NOVA_GROUP)
|
||||
|
@ -29,7 +29,6 @@ import socket
|
||||
import sys
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
|
||||
from manila import exception
|
||||
from manila.i18n import _
|
||||
@ -39,7 +38,6 @@ from manila.share.drivers.ganesha import utils as ganesha_utils
|
||||
from manila.share.drivers.glusterfs import layout
|
||||
from manila import utils
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
GlusterfsManilaShare_opts = [
|
||||
cfg.StrOpt('glusterfs_nfs_server_type',
|
||||
|
@ -17,8 +17,6 @@ NetApp cDOT CIFS protocol helper class.
|
||||
|
||||
import re
|
||||
|
||||
from oslo_log import log
|
||||
|
||||
from manila.common import constants
|
||||
from manila import exception
|
||||
from manila.i18n import _
|
||||
@ -26,9 +24,6 @@ from manila.share.drivers.netapp.dataontap.protocols import base
|
||||
from manila.share.drivers.netapp import utils as na_utils
|
||||
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
class NetAppCmodeCIFSHelper(base.NetAppBaseHelper):
|
||||
"""NetApp cDOT CIFS protocol helper class."""
|
||||
|
||||
|
@ -16,10 +16,6 @@
|
||||
|
||||
"""Share-related Utilities and helpers."""
|
||||
|
||||
from oslo_log import log
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
DEFAULT_POOL_NAME = '_pool0'
|
||||
|
||||
|
||||
|
@ -17,12 +17,9 @@ import doctest
|
||||
|
||||
from lxml import doctestcompare
|
||||
import mock
|
||||
from oslo_log import log
|
||||
import six
|
||||
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
CHECKER = doctestcompare.LXMLOutputChecker()
|
||||
PARSE_XML = doctest.register_optionflag('PARSE_XML')
|
||||
|
||||
|
@ -19,7 +19,6 @@ import copy
|
||||
|
||||
import ddt
|
||||
import mock
|
||||
from oslo_log import log
|
||||
|
||||
from manila.common import constants
|
||||
from manila import exception
|
||||
@ -35,12 +34,6 @@ class NetAppClusteredCIFSHelperTestCase(test.TestCase):
|
||||
def setUp(self):
|
||||
super(NetAppClusteredCIFSHelperTestCase, self).setUp()
|
||||
|
||||
# Mock loggers as themselves to allow logger arg validation
|
||||
mock_logger = log.getLogger('mock_logger')
|
||||
self.mock_object(cifs_cmode.LOG,
|
||||
'error',
|
||||
mock.Mock(side_effect=mock_logger.error))
|
||||
|
||||
self.mock_context = mock.Mock()
|
||||
|
||||
self.mock_client = mock.Mock()
|
||||
|
@ -15,7 +15,6 @@
|
||||
Unit tests for Oracle's ZFSSA REST API.
|
||||
"""
|
||||
import mock
|
||||
from oslo_log import log
|
||||
|
||||
from manila import exception
|
||||
from manila.share.drivers.zfssa import restclient
|
||||
@ -24,9 +23,6 @@ from manila import test
|
||||
from manila.tests import fake_zfssa
|
||||
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
class ZFSSAApiTestCase(test.TestCase):
|
||||
"""Tests ZFSSAApi."""
|
||||
|
||||
|
@ -23,7 +23,6 @@ from cinderclient import exceptions as cinder_exception
|
||||
from cinderclient.v2 import client as cinder_client
|
||||
from keystoneauth1 import loading as ks_loading
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
import six
|
||||
|
||||
from manila.common import client_auth
|
||||
@ -107,9 +106,6 @@ ks_loading.register_session_conf_options(CONF, CINDER_GROUP)
|
||||
ks_loading.register_auth_conf_options(CONF, CINDER_GROUP)
|
||||
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
def list_opts():
|
||||
return client_auth.AuthClientLoader.list_opts(CINDER_GROUP)
|
||||
|
||||
|
28
tools/check_logging.sh
Executable file
28
tools/check_logging.sh
Executable file
@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
tree=$1
|
||||
|
||||
tmpfile=$(mktemp)
|
||||
|
||||
find $tree -name '*.py' \
|
||||
| xargs grep -l 'import log' \
|
||||
| xargs grep -l '^LOG =' \
|
||||
| xargs grep -c 'LOG' \
|
||||
| grep ':1$' \
|
||||
| awk -F ':' '{print $1}' > $tmpfile
|
||||
|
||||
count=$(wc -l < $tmpfile)
|
||||
|
||||
if [[ count -eq 0 ]]; then
|
||||
rm $tmpfile
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo 'Found files with unused LOG variable (see https://review.openstack.org/#/c/301054):'
|
||||
cat $tmpfile
|
||||
rm $tmpfile
|
||||
exit 1
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user