Browse Source

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
Tom Barron 3 years ago
parent
commit
72ab1442ad

+ 0
- 2
manila/api/v2/share_replicas.py View File

@@ -15,7 +15,6 @@
15 15
 
16 16
 """The Share Replication API."""
17 17
 
18
-from oslo_log import log
19 18
 import six
20 19
 import webob
21 20
 from webob import exc
@@ -30,7 +29,6 @@ from manila.i18n import _
30 29
 from manila import share
31 30
 
32 31
 
33
-LOG = log.getLogger(__name__)
34 32
 MIN_SUPPORTED_API_VERSION = '2.11'
35 33
 
36 34
 

+ 0
- 3
manila/compute/nova.py View File

@@ -21,7 +21,6 @@ from novaclient import client as nova_client
21 21
 from novaclient import exceptions as nova_exception
22 22
 from novaclient import utils
23 23
 from oslo_config import cfg
24
-from oslo_log import log
25 24
 import six
26 25
 
27 26
 from manila.common import client_auth
@@ -102,8 +101,6 @@ CONF.register_opts(nova_opts, NOVA_GROUP)
102 101
 ks_loading.register_session_conf_options(CONF, NOVA_GROUP)
103 102
 ks_loading.register_auth_conf_options(CONF, NOVA_GROUP)
104 103
 
105
-LOG = log.getLogger(__name__)
106
-
107 104
 
108 105
 def list_opts():
109 106
     return client_auth.AuthClientLoader.list_opts(NOVA_GROUP)

+ 0
- 2
manila/share/drivers/glusterfs/__init__.py View File

@@ -29,7 +29,6 @@ import socket
29 29
 import sys
30 30
 
31 31
 from oslo_config import cfg
32
-from oslo_log import log
33 32
 
34 33
 from manila import exception
35 34
 from manila.i18n import _
@@ -39,7 +38,6 @@ from manila.share.drivers.ganesha import utils as ganesha_utils
39 38
 from manila.share.drivers.glusterfs import layout
40 39
 from manila import utils
41 40
 
42
-LOG = log.getLogger(__name__)
43 41
 
44 42
 GlusterfsManilaShare_opts = [
45 43
     cfg.StrOpt('glusterfs_nfs_server_type',

+ 0
- 5
manila/share/drivers/netapp/dataontap/protocols/cifs_cmode.py View File

@@ -17,8 +17,6 @@ NetApp cDOT CIFS protocol helper class.
17 17
 
18 18
 import re
19 19
 
20
-from oslo_log import log
21
-
22 20
 from manila.common import constants
23 21
 from manila import exception
24 22
 from manila.i18n import _
@@ -26,9 +24,6 @@ from manila.share.drivers.netapp.dataontap.protocols import base
26 24
 from manila.share.drivers.netapp import utils as na_utils
27 25
 
28 26
 
29
-LOG = log.getLogger(__name__)
30
-
31
-
32 27
 class NetAppCmodeCIFSHelper(base.NetAppBaseHelper):
33 28
     """NetApp cDOT CIFS protocol helper class."""
34 29
 

+ 0
- 4
manila/share/utils.py View File

@@ -16,10 +16,6 @@
16 16
 
17 17
 """Share-related Utilities and helpers."""
18 18
 
19
-from oslo_log import log
20
-
21
-LOG = log.getLogger(__name__)
22
-
23 19
 DEFAULT_POOL_NAME = '_pool0'
24 20
 
25 21
 

+ 0
- 3
manila/tests/share/drivers/emc/plugins/vnx/utils.py View File

@@ -17,12 +17,9 @@ import doctest
17 17
 
18 18
 from lxml import doctestcompare
19 19
 import mock
20
-from oslo_log import log
21 20
 import six
22 21
 
23 22
 
24
-LOG = log.getLogger(__name__)
25
-
26 23
 CHECKER = doctestcompare.LXMLOutputChecker()
27 24
 PARSE_XML = doctest.register_optionflag('PARSE_XML')
28 25
 

+ 0
- 7
manila/tests/share/drivers/netapp/dataontap/protocols/test_cifs_cmode.py View File

@@ -19,7 +19,6 @@ import copy
19 19
 
20 20
 import ddt
21 21
 import mock
22
-from oslo_log import log
23 22
 
24 23
 from manila.common import constants
25 24
 from manila import exception
@@ -35,12 +34,6 @@ class NetAppClusteredCIFSHelperTestCase(test.TestCase):
35 34
     def setUp(self):
36 35
         super(NetAppClusteredCIFSHelperTestCase, self).setUp()
37 36
 
38
-        # Mock loggers as themselves to allow logger arg validation
39
-        mock_logger = log.getLogger('mock_logger')
40
-        self.mock_object(cifs_cmode.LOG,
41
-                         'error',
42
-                         mock.Mock(side_effect=mock_logger.error))
43
-
44 37
         self.mock_context = mock.Mock()
45 38
 
46 39
         self.mock_client = mock.Mock()

+ 0
- 4
manila/tests/share/drivers/zfssa/test_zfssarest.py View File

@@ -15,7 +15,6 @@
15 15
 Unit tests for Oracle's ZFSSA REST API.
16 16
 """
17 17
 import mock
18
-from oslo_log import log
19 18
 
20 19
 from manila import exception
21 20
 from manila.share.drivers.zfssa import restclient
@@ -24,9 +23,6 @@ from manila import test
24 23
 from manila.tests import fake_zfssa
25 24
 
26 25
 
27
-LOG = log.getLogger(__name__)
28
-
29
-
30 26
 class ZFSSAApiTestCase(test.TestCase):
31 27
     """Tests ZFSSAApi."""
32 28
 

+ 0
- 4
manila/volume/cinder.py View File

@@ -23,7 +23,6 @@ from cinderclient import exceptions as cinder_exception
23 23
 from cinderclient.v2 import client as cinder_client
24 24
 from keystoneauth1 import loading as ks_loading
25 25
 from oslo_config import cfg
26
-from oslo_log import log
27 26
 import six
28 27
 
29 28
 from manila.common import client_auth
@@ -107,9 +106,6 @@ ks_loading.register_session_conf_options(CONF, CINDER_GROUP)
107 106
 ks_loading.register_auth_conf_options(CONF, CINDER_GROUP)
108 107
 
109 108
 
110
-LOG = log.getLogger(__name__)
111
-
112
-
113 109
 def list_opts():
114 110
     return client_auth.AuthClientLoader.list_opts(CINDER_GROUP)
115 111
 

+ 28
- 0
tools/check_logging.sh View File

@@ -0,0 +1,28 @@
1
+#!/bin/bash
2
+
3
+tree=$1
4
+
5
+tmpfile=$(mktemp)
6
+
7
+find $tree -name '*.py' \
8
+    | xargs grep -l 'import log' \
9
+    | xargs grep -l '^LOG =' \
10
+    | xargs grep -c  'LOG' \
11
+    | grep ':1$' \
12
+    | awk -F ':' '{print $1}' > $tmpfile
13
+
14
+count=$(wc -l < $tmpfile)
15
+
16
+if [[ count -eq 0 ]]; then
17
+    rm $tmpfile
18
+    exit 0
19
+fi
20
+
21
+echo 'Found files with unused LOG variable (see https://review.openstack.org/#/c/301054):'
22
+cat $tmpfile
23
+rm $tmpfile
24
+exit 1
25
+
26
+
27
+
28
+

+ 2
- 0
tox.ini View File

@@ -40,7 +40,9 @@ commands =
40 40
          contrib/ci/post_test_hook.sh \
41 41
          devstack/plugin.sh \
42 42
          tools/cover.sh \
43
+         tools/check_logging.sh \
43 44
          run_tests.sh
45
+  {toxinidir}/tools/check_logging.sh {toxinidir}/manila
44 46
 
45 47
 [testenv:genconfig]
46 48
 whitelist_externals = bash

Loading…
Cancel
Save