Fix snmp pollster to not ignore valid meters
Change-Id: Iecffab082f384df6c2fdb5f29754f674c9184b67 Closes-Bug: #1503189
This commit is contained in:
parent
decebfd9f1
commit
dc30bca3fb
@ -258,6 +258,11 @@ def setup_meters_config():
|
|||||||
def load_definition(config_def):
|
def load_definition(config_def):
|
||||||
mappings = {}
|
mappings = {}
|
||||||
for meter_def in config_def.get('metric', []):
|
for meter_def in config_def.get('metric', []):
|
||||||
meter = MeterDefinition(meter_def)
|
try:
|
||||||
mappings[meter.name] = meter
|
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
|
return mappings
|
||||||
|
@ -65,6 +65,26 @@ class TestMeterDefinition(test_base.BaseTestCase):
|
|||||||
except generic.MeterDefinitionException as e:
|
except generic.MeterDefinitionException as e:
|
||||||
self.assertEqual("Unrecognized type value invalid", e.message)
|
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):
|
class FakeInspector(inspector_base.Inspector):
|
||||||
net_metadata = dict(name='test.teest',
|
net_metadata = dict(name='test.teest',
|
||||||
|
Loading…
Reference in New Issue
Block a user