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."""
|
"""The Share Replication API."""
|
||||||
|
|
||||||
from oslo_log import log
|
|
||||||
import six
|
import six
|
||||||
import webob
|
import webob
|
||||||
from webob import exc
|
from webob import exc
|
||||||
|
@ -30,7 +29,6 @@ from manila.i18n import _
|
||||||
from manila import share
|
from manila import share
|
||||||
|
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
|
||||||
MIN_SUPPORTED_API_VERSION = '2.11'
|
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 exceptions as nova_exception
|
||||||
from novaclient import utils
|
from novaclient import utils
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from manila.common import client_auth
|
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_session_conf_options(CONF, NOVA_GROUP)
|
||||||
ks_loading.register_auth_conf_options(CONF, NOVA_GROUP)
|
ks_loading.register_auth_conf_options(CONF, NOVA_GROUP)
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
def list_opts():
|
def list_opts():
|
||||||
return client_auth.AuthClientLoader.list_opts(NOVA_GROUP)
|
return client_auth.AuthClientLoader.list_opts(NOVA_GROUP)
|
||||||
|
|
|
@ -29,7 +29,6 @@ import socket
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log
|
|
||||||
|
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila.i18n import _
|
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.share.drivers.glusterfs import layout
|
||||||
from manila import utils
|
from manila import utils
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
|
||||||
|
|
||||||
GlusterfsManilaShare_opts = [
|
GlusterfsManilaShare_opts = [
|
||||||
cfg.StrOpt('glusterfs_nfs_server_type',
|
cfg.StrOpt('glusterfs_nfs_server_type',
|
||||||
|
|
|
@ -17,8 +17,6 @@ NetApp cDOT CIFS protocol helper class.
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from oslo_log import log
|
|
||||||
|
|
||||||
from manila.common import constants
|
from manila.common import constants
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila.i18n import _
|
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
|
from manila.share.drivers.netapp import utils as na_utils
|
||||||
|
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class NetAppCmodeCIFSHelper(base.NetAppBaseHelper):
|
class NetAppCmodeCIFSHelper(base.NetAppBaseHelper):
|
||||||
"""NetApp cDOT CIFS protocol helper class."""
|
"""NetApp cDOT CIFS protocol helper class."""
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,6 @@
|
||||||
|
|
||||||
"""Share-related Utilities and helpers."""
|
"""Share-related Utilities and helpers."""
|
||||||
|
|
||||||
from oslo_log import log
|
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
|
||||||
|
|
||||||
DEFAULT_POOL_NAME = '_pool0'
|
DEFAULT_POOL_NAME = '_pool0'
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,9 @@ import doctest
|
||||||
|
|
||||||
from lxml import doctestcompare
|
from lxml import doctestcompare
|
||||||
import mock
|
import mock
|
||||||
from oslo_log import log
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
|
||||||
|
|
||||||
CHECKER = doctestcompare.LXMLOutputChecker()
|
CHECKER = doctestcompare.LXMLOutputChecker()
|
||||||
PARSE_XML = doctest.register_optionflag('PARSE_XML')
|
PARSE_XML = doctest.register_optionflag('PARSE_XML')
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ import copy
|
||||||
|
|
||||||
import ddt
|
import ddt
|
||||||
import mock
|
import mock
|
||||||
from oslo_log import log
|
|
||||||
|
|
||||||
from manila.common import constants
|
from manila.common import constants
|
||||||
from manila import exception
|
from manila import exception
|
||||||
|
@ -35,12 +34,6 @@ class NetAppClusteredCIFSHelperTestCase(test.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(NetAppClusteredCIFSHelperTestCase, self).setUp()
|
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_context = mock.Mock()
|
||||||
|
|
||||||
self.mock_client = mock.Mock()
|
self.mock_client = mock.Mock()
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
Unit tests for Oracle's ZFSSA REST API.
|
Unit tests for Oracle's ZFSSA REST API.
|
||||||
"""
|
"""
|
||||||
import mock
|
import mock
|
||||||
from oslo_log import log
|
|
||||||
|
|
||||||
from manila import exception
|
from manila import exception
|
||||||
from manila.share.drivers.zfssa import restclient
|
from manila.share.drivers.zfssa import restclient
|
||||||
|
@ -24,9 +23,6 @@ from manila import test
|
||||||
from manila.tests import fake_zfssa
|
from manila.tests import fake_zfssa
|
||||||
|
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class ZFSSAApiTestCase(test.TestCase):
|
class ZFSSAApiTestCase(test.TestCase):
|
||||||
"""Tests ZFSSAApi."""
|
"""Tests ZFSSAApi."""
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ from cinderclient import exceptions as cinder_exception
|
||||||
from cinderclient.v2 import client as cinder_client
|
from cinderclient.v2 import client as cinder_client
|
||||||
from keystoneauth1 import loading as ks_loading
|
from keystoneauth1 import loading as ks_loading
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from manila.common import client_auth
|
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)
|
ks_loading.register_auth_conf_options(CONF, CINDER_GROUP)
|
||||||
|
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
def list_opts():
|
def list_opts():
|
||||||
return client_auth.AuthClientLoader.list_opts(CINDER_GROUP)
|
return client_auth.AuthClientLoader.list_opts(CINDER_GROUP)
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
2
tox.ini
2
tox.ini
|
@ -40,7 +40,9 @@ commands =
|
||||||
contrib/ci/post_test_hook.sh \
|
contrib/ci/post_test_hook.sh \
|
||||||
devstack/plugin.sh \
|
devstack/plugin.sh \
|
||||||
tools/cover.sh \
|
tools/cover.sh \
|
||||||
|
tools/check_logging.sh \
|
||||||
run_tests.sh
|
run_tests.sh
|
||||||
|
{toxinidir}/tools/check_logging.sh {toxinidir}/manila
|
||||||
|
|
||||||
[testenv:genconfig]
|
[testenv:genconfig]
|
||||||
whitelist_externals = bash
|
whitelist_externals = bash
|
||||||
|
|
Loading…
Reference in New Issue