Start to use Hacking
Instead of ignoring all Hacking warnings, blacklist those that need lots of changes and fix the easy one. Change-Id: I0a31982b1ff17c54e1347bff5358bb9f8e637b6f
This commit is contained in:
parent
0e2274253e
commit
f37c7092d6
@ -804,7 +804,7 @@ class AlarmsController(rest.RestController):
|
|||||||
@wsme.validate(Alarm)
|
@wsme.validate(Alarm)
|
||||||
@wsme_pecan.wsexpose(Alarm, body=Alarm, status_code=201)
|
@wsme_pecan.wsexpose(Alarm, body=Alarm, status_code=201)
|
||||||
def post(self, data):
|
def post(self, data):
|
||||||
"""Create a new alarm"""
|
"""Create a new alarm."""
|
||||||
conn = pecan.request.storage_conn
|
conn = pecan.request.storage_conn
|
||||||
|
|
||||||
data.user_id = pecan.request.headers.get('X-User-Id')
|
data.user_id = pecan.request.headers.get('X-User-Id')
|
||||||
@ -832,7 +832,7 @@ class AlarmsController(rest.RestController):
|
|||||||
@wsme.validate(Alarm)
|
@wsme.validate(Alarm)
|
||||||
@wsme_pecan.wsexpose(Alarm, wtypes.text, body=Alarm)
|
@wsme_pecan.wsexpose(Alarm, wtypes.text, body=Alarm)
|
||||||
def put(self, alarm_id, data):
|
def put(self, alarm_id, data):
|
||||||
"""Modify an alarm"""
|
"""Modify an alarm."""
|
||||||
conn = pecan.request.storage_conn
|
conn = pecan.request.storage_conn
|
||||||
data.state_timestamp = wsme.Unset
|
data.state_timestamp = wsme.Unset
|
||||||
data.alarm_id = alarm_id
|
data.alarm_id = alarm_id
|
||||||
@ -858,7 +858,7 @@ class AlarmsController(rest.RestController):
|
|||||||
|
|
||||||
@wsme_pecan.wsexpose(None, wtypes.text, status_code=204)
|
@wsme_pecan.wsexpose(None, wtypes.text, status_code=204)
|
||||||
def delete(self, alarm_id):
|
def delete(self, alarm_id):
|
||||||
"""Delete an alarm"""
|
"""Delete an alarm."""
|
||||||
conn = pecan.request.storage_conn
|
conn = pecan.request.storage_conn
|
||||||
auth_project = acl.get_limited_to_project(pecan.request.headers)
|
auth_project = acl.get_limited_to_project(pecan.request.headers)
|
||||||
alarms = list(conn.get_alarms(alarm_id=alarm_id,
|
alarms = list(conn.get_alarms(alarm_id=alarm_id,
|
||||||
@ -870,7 +870,7 @@ class AlarmsController(rest.RestController):
|
|||||||
|
|
||||||
@wsme_pecan.wsexpose(Alarm, wtypes.text)
|
@wsme_pecan.wsexpose(Alarm, wtypes.text)
|
||||||
def get_one(self, alarm_id):
|
def get_one(self, alarm_id):
|
||||||
"""Return one alarm"""
|
"""Return one alarm."""
|
||||||
conn = pecan.request.storage_conn
|
conn = pecan.request.storage_conn
|
||||||
auth_project = acl.get_limited_to_project(pecan.request.headers)
|
auth_project = acl.get_limited_to_project(pecan.request.headers)
|
||||||
alarms = list(conn.get_alarms(alarm_id=alarm_id,
|
alarms = list(conn.get_alarms(alarm_id=alarm_id,
|
||||||
|
@ -91,7 +91,7 @@ class UDPCollectorService(os_service.Service):
|
|||||||
data, source = udp.recvfrom(64 * 1024)
|
data, source = udp.recvfrom(64 * 1024)
|
||||||
try:
|
try:
|
||||||
counter = msgpack.loads(data)
|
counter = msgpack.loads(data)
|
||||||
except:
|
except Exception:
|
||||||
LOG.warn(_("UDP: Cannot decode data sent by %s"), str(source))
|
LOG.warn(_("UDP: Cannot decode data sent by %s"), str(source))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
|
@ -31,7 +31,8 @@ from collections import defaultdict
|
|||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
from ceilometer.openstack.common import log, timeutils
|
from ceilometer.openstack.common import log
|
||||||
|
from ceilometer.openstack.common import timeutils
|
||||||
from ceilometer.storage import base
|
from ceilometer.storage import base
|
||||||
from ceilometer.storage import models
|
from ceilometer.storage import models
|
||||||
|
|
||||||
@ -134,11 +135,11 @@ class Connection(base.Connection):
|
|||||||
self.METER_TABLE]:
|
self.METER_TABLE]:
|
||||||
try:
|
try:
|
||||||
self.conn.disable_table(table)
|
self.conn.disable_table(table)
|
||||||
except:
|
except Exception:
|
||||||
LOG.debug('Cannot disable table but ignoring error')
|
LOG.debug('Cannot disable table but ignoring error')
|
||||||
try:
|
try:
|
||||||
self.conn.delete_table(table)
|
self.conn.delete_table(table)
|
||||||
except:
|
except Exception:
|
||||||
LOG.debug('Cannot delete table but ignoring error')
|
LOG.debug('Cannot delete table but ignoring error')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -292,8 +293,7 @@ class Connection(base.Connection):
|
|||||||
:param metaquery: Optional dict with metadata to match on.
|
:param metaquery: Optional dict with metadata to match on.
|
||||||
"""
|
"""
|
||||||
def make_resource(data):
|
def make_resource(data):
|
||||||
""" transform HBase fields to Resource model
|
"""Transform HBase fields to Resource model."""
|
||||||
"""
|
|
||||||
# convert HBase metadata e.g. f:r_display_name to display_name
|
# convert HBase metadata e.g. f:r_display_name to display_name
|
||||||
data['f:metadata'] = dict((k[4:], v)
|
data['f:metadata'] = dict((k[4:], v)
|
||||||
for k, v in data.iteritems()
|
for k, v in data.iteritems()
|
||||||
@ -397,8 +397,7 @@ class Connection(base.Connection):
|
|||||||
"""Return an iterable of models.Sample instances
|
"""Return an iterable of models.Sample instances
|
||||||
"""
|
"""
|
||||||
def make_sample(data):
|
def make_sample(data):
|
||||||
""" transform HBase fields to Sample model
|
"""Transform HBase fields to Sample model."""
|
||||||
"""
|
|
||||||
data = json.loads(data['f:message'])
|
data = json.loads(data['f:message'])
|
||||||
data['timestamp'] = timeutils.parse_strtime(data['timestamp'])
|
data['timestamp'] = timeutils.parse_strtime(data['timestamp'])
|
||||||
return models.Sample(**data)
|
return models.Sample(**data)
|
||||||
@ -410,7 +409,7 @@ class Connection(base.Connection):
|
|||||||
gen = self.meter.scan(filter=q, row_start=start, row_stop=stop)
|
gen = self.meter.scan(filter=q, row_start=start, row_stop=stop)
|
||||||
|
|
||||||
for ignored, meter in gen:
|
for ignored, meter in gen:
|
||||||
# TODO (shengjie) put this implementation here because it's failing
|
# TODO(shengjie) put this implementation here because it's failing
|
||||||
# the test. bp hbase-meter-table-enhancement will address this
|
# the test. bp hbase-meter-table-enhancement will address this
|
||||||
# properly.
|
# properly.
|
||||||
# handle metaquery
|
# handle metaquery
|
||||||
@ -593,8 +592,8 @@ class MTable(object):
|
|||||||
ret[row] = data
|
ret[row] = data
|
||||||
rows = ret
|
rows = ret
|
||||||
elif filter:
|
elif filter:
|
||||||
# TODO: we should really parse this properly, but at the moment we
|
# TODO(jdanjou): we should really parse this properly,
|
||||||
# are only going to support AND here
|
# but at the moment we are only going to support AND here
|
||||||
filters = filter.split('AND')
|
filters = filter.split('AND')
|
||||||
for f in filters:
|
for f in filters:
|
||||||
# Extract filter name and its arguments
|
# Extract filter name and its arguments
|
||||||
@ -763,7 +762,7 @@ def make_query_from_filter(sample_filter, require_meter=True):
|
|||||||
|
|
||||||
|
|
||||||
def _make_rowkey_scan(meter, rts_start=None, rts_end=None):
|
def _make_rowkey_scan(meter, rts_start=None, rts_end=None):
|
||||||
""" if it's meter filter without start and end,
|
"""If it's meter filter without start and end,
|
||||||
start_row = meter while end_row = meter + MAX_BYTE
|
start_row = meter while end_row = meter + MAX_BYTE
|
||||||
"""
|
"""
|
||||||
if not rts_start:
|
if not rts_start:
|
||||||
|
@ -30,9 +30,16 @@ import ceilometer.openstack.common.db.sqlalchemy.session as sqlalchemy_session
|
|||||||
from ceilometer.storage import base
|
from ceilometer.storage import base
|
||||||
from ceilometer.storage import models as api_models
|
from ceilometer.storage import models as api_models
|
||||||
from ceilometer.storage.sqlalchemy import migration
|
from ceilometer.storage.sqlalchemy import migration
|
||||||
from ceilometer.storage.sqlalchemy.models import Meter, Project, Resource
|
from ceilometer.storage.sqlalchemy.models import Alarm
|
||||||
from ceilometer.storage.sqlalchemy.models import Source, User, Base, Alarm
|
from ceilometer.storage.sqlalchemy.models import Base
|
||||||
from ceilometer.storage.sqlalchemy.models import UniqueName, Event, Trait
|
from ceilometer.storage.sqlalchemy.models import Event
|
||||||
|
from ceilometer.storage.sqlalchemy.models import Meter
|
||||||
|
from ceilometer.storage.sqlalchemy.models import Project
|
||||||
|
from ceilometer.storage.sqlalchemy.models import Resource
|
||||||
|
from ceilometer.storage.sqlalchemy.models import Source
|
||||||
|
from ceilometer.storage.sqlalchemy.models import Trait
|
||||||
|
from ceilometer.storage.sqlalchemy.models import UniqueName
|
||||||
|
from ceilometer.storage.sqlalchemy.models import User
|
||||||
from ceilometer import utils
|
from ceilometer import utils
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,8 +78,7 @@ class CeilometerBase(object):
|
|||||||
return getattr(self, key)
|
return getattr(self, key)
|
||||||
|
|
||||||
def update(self, values):
|
def update(self, values):
|
||||||
""" Make the model object behave like a dict
|
"""Make the model object behave like a dict."""
|
||||||
"""
|
|
||||||
for k, v in values.iteritems():
|
for k, v in values.iteritems():
|
||||||
setattr(self, k, v)
|
setattr(self, k, v)
|
||||||
|
|
||||||
@ -151,7 +150,7 @@ class Resource(Base):
|
|||||||
|
|
||||||
|
|
||||||
class Alarm(Base):
|
class Alarm(Base):
|
||||||
"""Alarm data"""
|
"""Define Alarm data."""
|
||||||
__tablename__ = 'alarm'
|
__tablename__ = 'alarm'
|
||||||
id = Column(String(255), primary_key=True)
|
id = Column(String(255), primary_key=True)
|
||||||
enabled = Column(Boolean)
|
enabled = Column(Boolean)
|
||||||
|
@ -148,7 +148,7 @@ class BaseAgentManagerTestCase(base.TestCase):
|
|||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def setup_manager(self):
|
def setup_manager(self):
|
||||||
"""Setup subclass specific managers"""
|
"""Setup subclass specific managers."""
|
||||||
|
|
||||||
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
|
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
import mock
|
import mock
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from ceilometer.compute import pollsters
|
|
||||||
from ceilometer.compute import manager
|
from ceilometer.compute import manager
|
||||||
|
from ceilometer.compute import pollsters
|
||||||
from ceilometer.compute.virt import inspector as virt_inspector
|
from ceilometer.compute.virt import inspector as virt_inspector
|
||||||
from ceilometer.tests import base as test_base
|
from ceilometer.tests import base as test_base
|
||||||
|
|
||||||
|
@ -22,9 +22,9 @@
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from ceilometer import nova_client
|
|
||||||
from ceilometer.network import floatingip
|
|
||||||
from ceilometer.central import manager
|
from ceilometer.central import manager
|
||||||
|
from ceilometer.network import floatingip
|
||||||
|
from ceilometer import nova_client
|
||||||
from ceilometer.openstack.common import context
|
from ceilometer.openstack.common import context
|
||||||
from ceilometer.tests import base
|
from ceilometer.tests import base
|
||||||
|
|
||||||
|
2
tox.ini
2
tox.ini
@ -39,7 +39,7 @@ deps = -r{toxinidir}/requirements.txt
|
|||||||
commands = {posargs}
|
commands = {posargs}
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
ignore = E125,F401,F403,H
|
ignore = E125,F401,F403,H301,H302,H304,H306,H401,H402,H403,H404,H703
|
||||||
builtins = _
|
builtins = _
|
||||||
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools,nova_tests
|
exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools,nova_tests
|
||||||
show-source = True
|
show-source = True
|
||||||
|
Loading…
Reference in New Issue
Block a user