diff --git a/ceilometer/alarm/evaluator/combination.py b/ceilometer/alarm/evaluator/combination.py index 25f0c9e18..05aec965c 100644 --- a/ceilometer/alarm/evaluator/combination.py +++ b/ceilometer/alarm/evaluator/combination.py @@ -18,7 +18,6 @@ from ceilometer.alarm import evaluator -from ceilometer.alarm.evaluator import OK, ALARM, UNKNOWN from ceilometer.openstack.common.gettextutils import _ from ceilometer.openstack.common import log @@ -43,12 +42,12 @@ class CombinationEvaluator(evaluator.Evaluator): """ missing_states = len(alarm.rule['alarm_ids']) - len(states) sufficient = missing_states == 0 - if not sufficient and alarm.state != UNKNOWN: + if not sufficient and alarm.state != evaluator.UNKNOWN: reason = _('%(missing_states)d alarms in %(alarm_ids)s' ' are in unknown state') % \ {'missing_states': missing_states, 'alarm_ids': ",".join(alarm.rule['alarm_ids'])} - self._refresh(alarm, UNKNOWN, reason) + self._refresh(alarm, evaluator.UNKNOWN, reason) return sufficient @staticmethod @@ -80,10 +79,10 @@ class CombinationEvaluator(evaluator.Evaluator): """Transition alarm state if necessary. """ op = alarm.rule['operator'] - if COMPARATORS[op](s == ALARM for s in underlying_states): - state = ALARM + if COMPARATORS[op](s == evaluator.ALARM for s in underlying_states): + state = evaluator.ALARM else: - state = OK + state = evaluator.OK continuous = alarm.repeat_actions reason = self._reason(alarm, state) @@ -96,7 +95,7 @@ class CombinationEvaluator(evaluator.Evaluator): state = self._get_alarm_state(_id) #note(sileht): alarm can be evaluated only with #stable state of other alarm - if state and state != UNKNOWN: + if state and state != evaluator.UNKNOWN: states.append(state) if self._sufficient_states(alarm, states): diff --git a/ceilometer/alarm/evaluator/threshold.py b/ceilometer/alarm/evaluator/threshold.py index 9c166faa0..8c0012ddc 100644 --- a/ceilometer/alarm/evaluator/threshold.py +++ b/ceilometer/alarm/evaluator/threshold.py @@ -21,7 +21,6 @@ import datetime import operator from ceilometer.alarm import evaluator -from ceilometer.alarm.evaluator import OK, ALARM, UNKNOWN from ceilometer.openstack.common.gettextutils import _ from ceilometer.openstack.common import log from ceilometer.openstack.common import timeutils @@ -91,17 +90,17 @@ class ThresholdEvaluator(evaluator.Evaluator): transitioning to unknown otherwise. """ sufficient = len(statistics) >= self.quorum - if not sufficient and alarm.state != UNKNOWN: + if not sufficient and alarm.state != evaluator.UNKNOWN: reason = _('%d datapoints are unknown') % alarm.rule[ 'evaluation_periods'] - self._refresh(alarm, UNKNOWN, reason) + self._refresh(alarm, evaluator.UNKNOWN, reason) return sufficient @staticmethod def _reason(alarm, statistics, distilled, state): """Fabricate reason string.""" count = len(statistics) - disposition = 'inside' if state == OK else 'outside' + disposition = 'inside' if state == evaluator.OK else 'outside' last = getattr(statistics[-1], alarm.rule['statistic']) transition = alarm.state != state if transition: @@ -129,16 +128,16 @@ class ThresholdEvaluator(evaluator.Evaluator): """ distilled = all(compared) unequivocal = distilled or not any(compared) - unknown = alarm.state == UNKNOWN + unknown = alarm.state == evaluator.UNKNOWN continuous = alarm.repeat_actions if unequivocal: - state = ALARM if distilled else OK + state = evaluator.ALARM if distilled else evaluator.OK reason = self._reason(alarm, statistics, distilled, state) if alarm.state != state or continuous: self._refresh(alarm, state, reason) elif unknown or continuous: - trending_state = ALARM if compared[-1] else OK + trending_state = evaluator.ALARM if compared[-1] else evaluator.OK state = trending_state if unknown else alarm.state reason = self._reason(alarm, statistics, distilled, state) self._refresh(alarm, state, reason) diff --git a/ceilometer/objectstore/swift_middleware.py b/ceilometer/objectstore/swift_middleware.py index 36432ed3b..75a3033a2 100644 --- a/ceilometer/objectstore/swift_middleware.py +++ b/ceilometer/objectstore/swift_middleware.py @@ -37,7 +37,7 @@ metadata_headers = X-TEST from __future__ import absolute_import -from swift.common.utils import split_path, get_logger +from swift.common import utils import webob REQUEST = webob @@ -68,7 +68,7 @@ class CeilometerMiddleware(object): def __init__(self, app, conf): self.app = app - self.logger = get_logger(conf, log_route='ceilometer') + self.logger = utils.get_logger(conf, log_route='ceilometer') self.metadata_headers = [h.strip().replace('-', '_').lower() for h in conf.get( @@ -119,7 +119,8 @@ class CeilometerMiddleware(object): def publish_sample(self, env, bytes_received, bytes_sent): req = REQUEST.Request(env) try: - version, account, container, obj = split_path(req.path, 2, 4, True) + version, account, container, obj = utils.split_path(req.path, 2, + 4, True) except ValueError: return now = timeutils.utcnow().isoformat() diff --git a/ceilometer/tests/compute/pollsters/test_cpu.py b/ceilometer/tests/compute/pollsters/test_cpu.py index 1c111076f..31d976450 100644 --- a/ceilometer/tests/compute/pollsters/test_cpu.py +++ b/ceilometer/tests/compute/pollsters/test_cpu.py @@ -26,8 +26,7 @@ import six from ceilometer.compute import manager from ceilometer.compute.pollsters import cpu from ceilometer.compute.virt import inspector as virt_inspector - -from . import base +from ceilometer.tests.compute.pollsters import base class TestCPUPollster(base.TestPollsterBase): diff --git a/ceilometer/tests/compute/pollsters/test_diskio.py b/ceilometer/tests/compute/pollsters/test_diskio.py index be0b6a114..7c31ebe40 100644 --- a/ceilometer/tests/compute/pollsters/test_diskio.py +++ b/ceilometer/tests/compute/pollsters/test_diskio.py @@ -23,8 +23,7 @@ import mock from ceilometer.compute import manager from ceilometer.compute.pollsters import disk from ceilometer.compute.virt import inspector as virt_inspector - -from . import base +from ceilometer.tests.compute.pollsters import base class TestDiskPollsters(base.TestPollsterBase): diff --git a/ceilometer/tests/compute/pollsters/test_instance.py b/ceilometer/tests/compute/pollsters/test_instance.py index acdaead1a..9d56c6df2 100644 --- a/ceilometer/tests/compute/pollsters/test_instance.py +++ b/ceilometer/tests/compute/pollsters/test_instance.py @@ -22,8 +22,7 @@ import mock from ceilometer.compute import manager from ceilometer.compute.pollsters import instance as pollsters_instance - -from . import base +from ceilometer.tests.compute.pollsters import base class TestInstancePollster(base.TestPollsterBase): diff --git a/ceilometer/tests/compute/pollsters/test_net.py b/ceilometer/tests/compute/pollsters/test_net.py index 6e846c287..eb817220f 100644 --- a/ceilometer/tests/compute/pollsters/test_net.py +++ b/ceilometer/tests/compute/pollsters/test_net.py @@ -23,8 +23,7 @@ import mock from ceilometer.compute import manager from ceilometer.compute.pollsters import net from ceilometer.compute.virt import inspector as virt_inspector - -from . import base +from ceilometer.tests.compute.pollsters import base class TestNetPollster(base.TestPollsterBase): diff --git a/tox.ini b/tox.ini index 5e1c6b8e2..e696f5d0e 100644 --- a/tox.ini +++ b/tox.ini @@ -45,7 +45,7 @@ deps = -r{toxinidir}/requirements.txt commands = {posargs} [flake8] -ignore = H301 +ignore = H302 builtins = _ exclude=.venv,.git,.tox,dist,doc,./ceilometer/openstack/common,*lib/python*,*egg,tools,nova_tests,build show-source = True