Merge "Fix snmp pollster to not ignore valid meters"
This commit is contained in:
commit
ac75a23813
@ -258,6 +258,11 @@ def setup_meters_config():
|
||||
def load_definition(config_def):
|
||||
mappings = {}
|
||||
for meter_def in config_def.get('metric', []):
|
||||
meter = MeterDefinition(meter_def)
|
||||
mappings[meter.name] = meter
|
||||
try:
|
||||
meter = MeterDefinition(meter_def)
|
||||
mappings[meter.name] = meter
|
||||
except MeterDefinitionException as me:
|
||||
errmsg = (_LE("Error loading meter definition : %(err)s")
|
||||
% dict(err=me.message))
|
||||
LOG.error(errmsg)
|
||||
return mappings
|
||||
|
@ -65,6 +65,26 @@ class TestMeterDefinition(test_base.BaseTestCase):
|
||||
except generic.MeterDefinitionException as e:
|
||||
self.assertEqual("Unrecognized type value invalid", e.message)
|
||||
|
||||
@mock.patch('ceilometer.hardware.pollsters.generic.LOG')
|
||||
def test_bad_metric_skip(self, LOG):
|
||||
cfg = {'metric': [dict(name='test1',
|
||||
type='gauge',
|
||||
unit='B',
|
||||
snmp_inspector={}),
|
||||
dict(name='test_bad',
|
||||
type='invalid',
|
||||
unit='B',
|
||||
snmp_inspector={}),
|
||||
dict(name='test2',
|
||||
type='gauge',
|
||||
unit='B',
|
||||
snmp_inspector={})]}
|
||||
data = generic.load_definition(cfg)
|
||||
self.assertEqual(2, len(data))
|
||||
LOG.error.assert_called_with(
|
||||
"Error loading meter definition : "
|
||||
"Unrecognized type value invalid")
|
||||
|
||||
|
||||
class FakeInspector(inspector_base.Inspector):
|
||||
net_metadata = dict(name='test.teest',
|
||||
|
Loading…
Reference in New Issue
Block a user