diff --git a/ceilometer/alarm/evaluator/__init__.py b/ceilometer/alarm/evaluator/__init__.py index 8f0abd41..0362ea87 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 0526a9a1..f8b30fac 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 74dede9c..b0ac118e 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 7022fb64..58e500e9 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 8b14f282..a7baf5e7 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 6cbc26c0..53e06643 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 cb2fd03f..a671905c 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 e189d911..3de9dbc6 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 93050c94..359a2fba 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 a44a9b3c..b8654c59 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 5ea72479..2d03a7a0 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 5ac82875..7b16c143 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 f980f44d..f0c79713 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 d5ee4c85..1ecd7923 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 83e3bdff..658b15d8 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 8ffe44e3..09ae7fc1 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 ebcc9fcd..33a2d1cf 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 9c6e9bfb..112182ba 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 e54e2d62..c334b477 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 4dcb2ad7..e747a322 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 a1e2df60..fcc17745 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