full pep8 compliance (part1)
first stage of moving to full pep8 compliance Change-Id: I4626a0949da5b9c49776d1e16cb9ebb49b4e6723
This commit is contained in:
parent
6de3134f29
commit
6f77240c02
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
|
|
||||||
from ceilometer.alarm import evaluator
|
from ceilometer.alarm import evaluator
|
||||||
from ceilometer.alarm.evaluator import OK, ALARM, UNKNOWN
|
|
||||||
from ceilometer.openstack.common.gettextutils import _
|
from ceilometer.openstack.common.gettextutils import _
|
||||||
from ceilometer.openstack.common import log
|
from ceilometer.openstack.common import log
|
||||||
|
|
||||||
@ -43,12 +42,12 @@ class CombinationEvaluator(evaluator.Evaluator):
|
|||||||
"""
|
"""
|
||||||
missing_states = len(alarm.rule['alarm_ids']) - len(states)
|
missing_states = len(alarm.rule['alarm_ids']) - len(states)
|
||||||
sufficient = missing_states == 0
|
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'
|
reason = _('%(missing_states)d alarms in %(alarm_ids)s'
|
||||||
' are in unknown state') % \
|
' are in unknown state') % \
|
||||||
{'missing_states': missing_states,
|
{'missing_states': missing_states,
|
||||||
'alarm_ids': ",".join(alarm.rule['alarm_ids'])}
|
'alarm_ids': ",".join(alarm.rule['alarm_ids'])}
|
||||||
self._refresh(alarm, UNKNOWN, reason)
|
self._refresh(alarm, evaluator.UNKNOWN, reason)
|
||||||
return sufficient
|
return sufficient
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -80,10 +79,10 @@ class CombinationEvaluator(evaluator.Evaluator):
|
|||||||
"""Transition alarm state if necessary.
|
"""Transition alarm state if necessary.
|
||||||
"""
|
"""
|
||||||
op = alarm.rule['operator']
|
op = alarm.rule['operator']
|
||||||
if COMPARATORS[op](s == ALARM for s in underlying_states):
|
if COMPARATORS[op](s == evaluator.ALARM for s in underlying_states):
|
||||||
state = ALARM
|
state = evaluator.ALARM
|
||||||
else:
|
else:
|
||||||
state = OK
|
state = evaluator.OK
|
||||||
|
|
||||||
continuous = alarm.repeat_actions
|
continuous = alarm.repeat_actions
|
||||||
reason = self._reason(alarm, state)
|
reason = self._reason(alarm, state)
|
||||||
@ -96,7 +95,7 @@ class CombinationEvaluator(evaluator.Evaluator):
|
|||||||
state = self._get_alarm_state(_id)
|
state = self._get_alarm_state(_id)
|
||||||
#note(sileht): alarm can be evaluated only with
|
#note(sileht): alarm can be evaluated only with
|
||||||
#stable state of other alarm
|
#stable state of other alarm
|
||||||
if state and state != UNKNOWN:
|
if state and state != evaluator.UNKNOWN:
|
||||||
states.append(state)
|
states.append(state)
|
||||||
|
|
||||||
if self._sufficient_states(alarm, states):
|
if self._sufficient_states(alarm, states):
|
||||||
|
@ -21,7 +21,6 @@ import datetime
|
|||||||
import operator
|
import operator
|
||||||
|
|
||||||
from ceilometer.alarm import evaluator
|
from ceilometer.alarm import evaluator
|
||||||
from ceilometer.alarm.evaluator import OK, ALARM, UNKNOWN
|
|
||||||
from ceilometer.openstack.common.gettextutils import _
|
from ceilometer.openstack.common.gettextutils import _
|
||||||
from ceilometer.openstack.common import log
|
from ceilometer.openstack.common import log
|
||||||
from ceilometer.openstack.common import timeutils
|
from ceilometer.openstack.common import timeutils
|
||||||
@ -91,17 +90,17 @@ class ThresholdEvaluator(evaluator.Evaluator):
|
|||||||
transitioning to unknown otherwise.
|
transitioning to unknown otherwise.
|
||||||
"""
|
"""
|
||||||
sufficient = len(statistics) >= self.quorum
|
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[
|
reason = _('%d datapoints are unknown') % alarm.rule[
|
||||||
'evaluation_periods']
|
'evaluation_periods']
|
||||||
self._refresh(alarm, UNKNOWN, reason)
|
self._refresh(alarm, evaluator.UNKNOWN, reason)
|
||||||
return sufficient
|
return sufficient
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _reason(alarm, statistics, distilled, state):
|
def _reason(alarm, statistics, distilled, state):
|
||||||
"""Fabricate reason string."""
|
"""Fabricate reason string."""
|
||||||
count = len(statistics)
|
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'])
|
last = getattr(statistics[-1], alarm.rule['statistic'])
|
||||||
transition = alarm.state != state
|
transition = alarm.state != state
|
||||||
if transition:
|
if transition:
|
||||||
@ -129,16 +128,16 @@ class ThresholdEvaluator(evaluator.Evaluator):
|
|||||||
"""
|
"""
|
||||||
distilled = all(compared)
|
distilled = all(compared)
|
||||||
unequivocal = distilled or not any(compared)
|
unequivocal = distilled or not any(compared)
|
||||||
unknown = alarm.state == UNKNOWN
|
unknown = alarm.state == evaluator.UNKNOWN
|
||||||
continuous = alarm.repeat_actions
|
continuous = alarm.repeat_actions
|
||||||
|
|
||||||
if unequivocal:
|
if unequivocal:
|
||||||
state = ALARM if distilled else OK
|
state = evaluator.ALARM if distilled else evaluator.OK
|
||||||
reason = self._reason(alarm, statistics, distilled, state)
|
reason = self._reason(alarm, statistics, distilled, state)
|
||||||
if alarm.state != state or continuous:
|
if alarm.state != state or continuous:
|
||||||
self._refresh(alarm, state, reason)
|
self._refresh(alarm, state, reason)
|
||||||
elif unknown or continuous:
|
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
|
state = trending_state if unknown else alarm.state
|
||||||
reason = self._reason(alarm, statistics, distilled, state)
|
reason = self._reason(alarm, statistics, distilled, state)
|
||||||
self._refresh(alarm, state, reason)
|
self._refresh(alarm, state, reason)
|
||||||
|
@ -37,7 +37,7 @@ metadata_headers = X-TEST
|
|||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
from swift.common.utils import split_path, get_logger
|
from swift.common import utils
|
||||||
import webob
|
import webob
|
||||||
|
|
||||||
REQUEST = webob
|
REQUEST = webob
|
||||||
@ -68,7 +68,7 @@ class CeilometerMiddleware(object):
|
|||||||
|
|
||||||
def __init__(self, app, conf):
|
def __init__(self, app, conf):
|
||||||
self.app = app
|
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()
|
self.metadata_headers = [h.strip().replace('-', '_').lower()
|
||||||
for h in conf.get(
|
for h in conf.get(
|
||||||
@ -119,7 +119,8 @@ class CeilometerMiddleware(object):
|
|||||||
def publish_sample(self, env, bytes_received, bytes_sent):
|
def publish_sample(self, env, bytes_received, bytes_sent):
|
||||||
req = REQUEST.Request(env)
|
req = REQUEST.Request(env)
|
||||||
try:
|
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:
|
except ValueError:
|
||||||
return
|
return
|
||||||
now = timeutils.utcnow().isoformat()
|
now = timeutils.utcnow().isoformat()
|
||||||
|
@ -26,8 +26,7 @@ import six
|
|||||||
from ceilometer.compute import manager
|
from ceilometer.compute import manager
|
||||||
from ceilometer.compute.pollsters import cpu
|
from ceilometer.compute.pollsters import cpu
|
||||||
from ceilometer.compute.virt import inspector as virt_inspector
|
from ceilometer.compute.virt import inspector as virt_inspector
|
||||||
|
from ceilometer.tests.compute.pollsters import base
|
||||||
from . import base
|
|
||||||
|
|
||||||
|
|
||||||
class TestCPUPollster(base.TestPollsterBase):
|
class TestCPUPollster(base.TestPollsterBase):
|
||||||
|
@ -23,8 +23,7 @@ import mock
|
|||||||
from ceilometer.compute import manager
|
from ceilometer.compute import manager
|
||||||
from ceilometer.compute.pollsters import disk
|
from ceilometer.compute.pollsters import disk
|
||||||
from ceilometer.compute.virt import inspector as virt_inspector
|
from ceilometer.compute.virt import inspector as virt_inspector
|
||||||
|
from ceilometer.tests.compute.pollsters import base
|
||||||
from . import base
|
|
||||||
|
|
||||||
|
|
||||||
class TestDiskPollsters(base.TestPollsterBase):
|
class TestDiskPollsters(base.TestPollsterBase):
|
||||||
|
@ -22,8 +22,7 @@ import mock
|
|||||||
|
|
||||||
from ceilometer.compute import manager
|
from ceilometer.compute import manager
|
||||||
from ceilometer.compute.pollsters import instance as pollsters_instance
|
from ceilometer.compute.pollsters import instance as pollsters_instance
|
||||||
|
from ceilometer.tests.compute.pollsters import base
|
||||||
from . import base
|
|
||||||
|
|
||||||
|
|
||||||
class TestInstancePollster(base.TestPollsterBase):
|
class TestInstancePollster(base.TestPollsterBase):
|
||||||
|
@ -23,8 +23,7 @@ import mock
|
|||||||
from ceilometer.compute import manager
|
from ceilometer.compute import manager
|
||||||
from ceilometer.compute.pollsters import net
|
from ceilometer.compute.pollsters import net
|
||||||
from ceilometer.compute.virt import inspector as virt_inspector
|
from ceilometer.compute.virt import inspector as virt_inspector
|
||||||
|
from ceilometer.tests.compute.pollsters import base
|
||||||
from . import base
|
|
||||||
|
|
||||||
|
|
||||||
class TestNetPollster(base.TestPollsterBase):
|
class TestNetPollster(base.TestPollsterBase):
|
||||||
|
2
tox.ini
2
tox.ini
@ -45,7 +45,7 @@ deps = -r{toxinidir}/requirements.txt
|
|||||||
commands = {posargs}
|
commands = {posargs}
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
ignore = H301
|
ignore = H302
|
||||||
builtins = _
|
builtins = _
|
||||||
exclude=.venv,.git,.tox,dist,doc,./ceilometer/openstack/common,*lib/python*,*egg,tools,nova_tests,build
|
exclude=.venv,.git,.tox,dist,doc,./ceilometer/openstack/common,*lib/python*,*egg,tools,nova_tests,build
|
||||||
show-source = True
|
show-source = True
|
||||||
|
Loading…
Reference in New Issue
Block a user