diff --git a/ceilometer/alarm/evaluator/__init__.py b/ceilometer/alarm/evaluator/__init__.py index 8f0abd414..0362ea87d 100644 --- a/ceilometer/alarm/evaluator/__init__.py +++ b/ceilometer/alarm/evaluator/__init__.py @@ -19,16 +19,17 @@ import abc import croniter import datetime -import pytz from ceilometerclient import client as ceiloclient from oslo.config import cfg +import pytz import six from ceilometer.openstack.common.gettextutils import _ from ceilometer.openstack.common import log from ceilometer.openstack.common import timeutils + LOG = log.getLogger(__name__) UNKNOWN = 'insufficient data' diff --git a/ceilometer/alarm/notifier/rest.py b/ceilometer/alarm/notifier/rest.py index 0526a9a1b..f8b30facc 100644 --- a/ceilometer/alarm/notifier/rest.py +++ b/ceilometer/alarm/notifier/rest.py @@ -19,7 +19,7 @@ import eventlet from oslo.config import cfg import requests -from six.moves.urllib import parse as urlparse +import six.moves.urllib.parse as urlparse from ceilometer.alarm import notifier from ceilometer.openstack.common.gettextutils import _ diff --git a/ceilometer/cli.py b/ceilometer/cli.py index 74dede9c5..b0ac118ee 100644 --- a/ceilometer/cli.py +++ b/ceilometer/cli.py @@ -28,8 +28,6 @@ import eventlet # first read() or select(), thread need to be patched too, because # oslo.messaging use threading.local eventlet.monkey_patch(socket=True, select=True, thread=True) - - from oslo.config import cfg from ceilometer.alarm import service as alarm_service @@ -48,6 +46,7 @@ from ceilometer import service from ceilometer import storage from ceilometer import transformer + OPTS = [ cfg.StrOpt('evaluation_service', default='ceilometer.alarm.service.SingletonAlarmService', diff --git a/ceilometer/compute/nova_notifier.py b/ceilometer/compute/nova_notifier.py index 7022fb645..58e500e94 100644 --- a/ceilometer/compute/nova_notifier.py +++ b/ceilometer/compute/nova_notifier.py @@ -17,27 +17,24 @@ import sys +from nova.compute import flavors +from nova import conductor from nova import notifications from nova.openstack.common import log as logging from nova.openstack.common.notifier import api as notifier_api +from nova import utils +from stevedore import extension # HACK(dhellmann): Insert the nova version of openstack.common into # sys.modules as though it was the copy from ceilometer, so that when # we use modules from ceilometer below they do not re-define options. # use the real ceilometer base package import ceilometer # noqa -for name in ['openstack', 'openstack.common', 'openstack.common.log']: - sys.modules['ceilometer.' + name] = sys.modules['nova.' + name] - -from nova.compute import flavors -from nova import conductor -from nova import utils - -from stevedore import extension - from ceilometer.compute.virt import inspector from ceilometer.openstack.common.gettextutils import _ +for name in ['openstack', 'openstack.common', 'openstack.common.log']: + sys.modules['ceilometer.' + name] = sys.modules['nova.' + name] # This module runs inside the nova compute # agent, which only configures the "nova" logger. diff --git a/ceilometer/dispatcher/__init__.py b/ceilometer/dispatcher/__init__.py index 8b14f2825..a7baf5e73 100644 --- a/ceilometer/dispatcher/__init__.py +++ b/ceilometer/dispatcher/__init__.py @@ -16,9 +16,9 @@ # under the License. import abc -import six from oslo.config import cfg +import six from stevedore import named from ceilometer.openstack.common.gettextutils import _ diff --git a/ceilometer/notifier.py b/ceilometer/notifier.py index 6cbc26c0d..53e06643d 100644 --- a/ceilometer/notifier.py +++ b/ceilometer/notifier.py @@ -15,14 +15,14 @@ # License for the specific language governing permissions and limitations # under the License. +from stevedore import extension + from ceilometer.openstack.common import context as req_context +from ceilometer.openstack.common.gettextutils import _ from ceilometer.openstack.common import log as logging from ceilometer import pipeline from ceilometer import transformer -from ceilometer.openstack.common.gettextutils import _ -from stevedore import extension - LOG = logging.getLogger(__name__) diff --git a/ceilometer/objectstore/swift.py b/ceilometer/objectstore/swift.py index cb2fd03f6..a671905cf 100644 --- a/ceilometer/objectstore/swift.py +++ b/ceilometer/objectstore/swift.py @@ -21,7 +21,7 @@ from __future__ import absolute_import from keystoneclient import exceptions from oslo.config import cfg -from six.moves.urllib import parse as urlparse +import six.moves.urllib.parse as urlparse from swiftclient import client as swift from ceilometer.central import plugin diff --git a/ceilometer/publisher/rpc.py b/ceilometer/publisher/rpc.py index e189d9117..3de9dbc62 100644 --- a/ceilometer/publisher/rpc.py +++ b/ceilometer/publisher/rpc.py @@ -24,7 +24,7 @@ import operator from oslo.config import cfg import oslo.messaging import oslo.messaging._drivers.common -from six.moves.urllib import parse as urlparse +import six.moves.urllib.parse as urlparse from ceilometer import messaging from ceilometer.openstack.common.gettextutils import _ diff --git a/ceilometer/storage/__init__.py b/ceilometer/storage/__init__.py index 93050c942..359a2fba3 100644 --- a/ceilometer/storage/__init__.py +++ b/ceilometer/storage/__init__.py @@ -19,7 +19,7 @@ from oslo.config import cfg import six -from six.moves.urllib import parse as urlparse +import six.moves.urllib.parse as urlparse from stevedore import driver from ceilometer.openstack.common.gettextutils import _ diff --git a/ceilometer/storage/impl_mongodb.py b/ceilometer/storage/impl_mongodb.py index a44a9b3ca..b8654c59f 100644 --- a/ceilometer/storage/impl_mongodb.py +++ b/ceilometer/storage/impl_mongodb.py @@ -29,9 +29,8 @@ import uuid import bson.code import bson.objectid -import pymongo - from oslo.config import cfg +import pymongo from ceilometer.openstack.common import log from ceilometer.openstack.common import timeutils diff --git a/ceilometer/tests/alarm/test_notifier.py b/ceilometer/tests/alarm/test_notifier.py index 5ea724790..2d03a7a0a 100644 --- a/ceilometer/tests/alarm/test_notifier.py +++ b/ceilometer/tests/alarm/test_notifier.py @@ -17,7 +17,7 @@ import mock import requests -from six.moves.urllib import parse as urlparse +import six.moves.urllib.parse as urlparse from ceilometer.alarm import service from ceilometer.openstack.common import context diff --git a/ceilometer/tests/alarm/test_singleton_alarm_svc.py b/ceilometer/tests/alarm/test_singleton_alarm_svc.py index 5ac82875b..7b16c143c 100644 --- a/ceilometer/tests/alarm/test_singleton_alarm_svc.py +++ b/ceilometer/tests/alarm/test_singleton_alarm_svc.py @@ -17,8 +17,6 @@ """Tests for ceilometer.alarm.service.SingletonAlarmService. """ import mock - - from stevedore import extension from ceilometer.alarm import service diff --git a/ceilometer/tests/base.py b/ceilometer/tests/base.py index f980f44d4..f0c797134 100644 --- a/ceilometer/tests/base.py +++ b/ceilometer/tests/base.py @@ -19,11 +19,10 @@ """ import functools import os.path -import six import eventlet import oslo.messaging -import oslo.messaging.conffixture +import six from testtools import testcase from ceilometer import messaging @@ -52,12 +51,6 @@ class BaseTestCase(test.BaseTestCase): 'ceilometer.messaging.get_transport', return_value=self.transport)) - def setUp(self): - super(BaseTestCase, self).setUp() - self.useFixture(mockpatch.Patch( - 'oslo.config.cfg._get_config_dirs', - return_value=[self.path_get('etc/ceilometer')])) - def assertTimestampEqual(self, first, second, msg=None): """Checks that two timestamps are equals. diff --git a/ceilometer/tests/compute/virt/vmware/test_inspector.py b/ceilometer/tests/compute/virt/vmware/test_inspector.py index d5ee4c85e..1ecd7923c 100644 --- a/ceilometer/tests/compute/virt/vmware/test_inspector.py +++ b/ceilometer/tests/compute/virt/vmware/test_inspector.py @@ -17,7 +17,6 @@ Tests for VMware Vsphere inspector. """ import mock - from oslo.vmware import api from ceilometer.compute.virt import inspector as virt_inspector diff --git a/ceilometer/tests/event/test_endpoint.py b/ceilometer/tests/event/test_endpoint.py index 83e3bdff6..658b15d85 100644 --- a/ceilometer/tests/event/test_endpoint.py +++ b/ceilometer/tests/event/test_endpoint.py @@ -17,7 +17,6 @@ """Tests for Ceilometer notify daemon.""" import mock - from oslo.config import cfg import oslo.messaging from stevedore import extension diff --git a/ceilometer/tests/objectstore/test_swift_middleware.py b/ceilometer/tests/objectstore/test_swift_middleware.py index 8ffe44e37..09ae7fc12 100644 --- a/ceilometer/tests/objectstore/test_swift_middleware.py +++ b/ceilometer/tests/objectstore/test_swift_middleware.py @@ -16,9 +16,9 @@ # License for the specific language governing permissions and limitations # under the License. +import mock import six -import mock try: # Swift >= 1.7.5 import swift.common.swob diff --git a/ceilometer/tests/orchestration/test_notifications.py b/ceilometer/tests/orchestration/test_notifications.py index ebcc9fcd4..33a2d1cfc 100644 --- a/ceilometer/tests/orchestration/test_notifications.py +++ b/ceilometer/tests/orchestration/test_notifications.py @@ -17,6 +17,7 @@ import datetime import mock from oslo.config import cfg +from ceilometer.openstack.common import log from ceilometer.openstack.common import test from ceilometer.orchestration import notifications from ceilometer import sample @@ -38,7 +39,6 @@ STACK_ARN = u'arn:openstack:heat::%s:stacks/%s/%s' % (TENANT_ID, CONF = cfg.CONF CONF.set_override('use_stderr', True) -from ceilometer.openstack.common import log LOG = log.getLogger(__name__) diff --git a/ceilometer/tests/storage/test_impl_sqlalchemy.py b/ceilometer/tests/storage/test_impl_sqlalchemy.py index 9c6e9bfb5..112182baa 100644 --- a/ceilometer/tests/storage/test_impl_sqlalchemy.py +++ b/ceilometer/tests/storage/test_impl_sqlalchemy.py @@ -31,7 +31,6 @@ from ceilometer.openstack.common import timeutils from ceilometer.storage import impl_sqlalchemy from ceilometer.storage import models from ceilometer.storage.sqlalchemy import models as sql_models - from ceilometer.tests import base as test_base from ceilometer.tests import db as tests_db from ceilometer.tests.storage import test_storage_scenarios as scenarios diff --git a/ceilometer/tests/test_notification.py b/ceilometer/tests/test_notification.py index e54e2d625..c334b4771 100644 --- a/ceilometer/tests/test_notification.py +++ b/ceilometer/tests/test_notification.py @@ -18,7 +18,6 @@ import eventlet import mock - import oslo.messaging import oslo.messaging.conffixture from stevedore import extension diff --git a/ceilometer/transformer/__init__.py b/ceilometer/transformer/__init__.py index 4dcb2ad73..e747a322a 100644 --- a/ceilometer/transformer/__init__.py +++ b/ceilometer/transformer/__init__.py @@ -16,8 +16,8 @@ # under the License. import abc -import six +import six from stevedore import extension diff --git a/tox.ini b/tox.ini index a1e2df600..fcc177457 100644 --- a/tox.ini +++ b/tox.ini @@ -38,10 +38,9 @@ commands = {posargs} [flake8] # H305 imports not grouped correctly -# H307 like imports should be grouped together # H405 multi line docstring summary not separated with an empty line # H904 Wrap long lines in parentheses instead of a backslash -ignore = H305,H307,H405,H904 +ignore = H305,H405,H904 builtins = _ exclude=.venv,.git,.tox,dist,doc,./ceilometer/openstack/common,*lib/python*,*egg,tools,nova_tests,build show-source = True