Remove redundant method + Zabbix fix

1. Removed redundant method from drivers -
   get_update_method as it is accessible via
   configuration and there's no need for adding
   such a function.
2. Fixed zabbix get_all bug, zabbix alarms key is
   now comprised of the alarm's host name, raw text
   description and the trigger id.

Change-Id: I2f885a1f4e12f69db15a819b62359b3290054364
This commit is contained in:
Noam Bloom 2016-08-10 13:50:01 +00:00
parent f870976e48
commit 59eecf30e7
22 changed files with 44 additions and 103 deletions

View File

@ -48,7 +48,7 @@ To forward zabbix events to Vitrage a new media script needs to be created and a
| host={HOST.NAME1} | host={HOST.NAME1}
| hostid={HOST.ID1} | hostid={HOST.ID1}
| hostip={HOST.IP1} | hostip={HOST.IP1}
| id={TRIGGER.ID} | triggerid={TRIGGER.ID}
| description={TRIGGER.NAME} | description={TRIGGER.NAME}
| rawtext={TRIGGER.NAME.ORIG} | rawtext={TRIGGER.NAME.ORIG}
| expression={TRIGGER.EXPRESSION} | expression={TRIGGER.EXPRESSION}

View File

@ -113,10 +113,6 @@ class AodhDriver(AlarmDriverBase):
else: else:
LOG.warning('Unsupported Aodh alarm of type %s' % alarm_type) LOG.warning('Unsupported Aodh alarm of type %s' % alarm_type)
@staticmethod
def get_update_method(conf):
return conf[AODH_DATASOURCE].update_method
def _parse_query(data, key): def _parse_query(data, key):
query_fields = data.get(AodhProps.QUERY, {}) query_fields = data.get(AodhProps.QUERY, {})

View File

@ -66,7 +66,3 @@ class CinderVolumeDriver(DriverBase):
'volume.detach.end', 'volume.detach.end',
'volume.delete.start', 'volume.delete.start',
'volume.delete.end'] 'volume.delete.end']
@staticmethod
def get_update_method(conf):
return conf[CINDER_VOLUME_DATASOURCE].update_method

View File

@ -113,20 +113,3 @@ class DriverBase(object):
""" """
return [] return []
@staticmethod
@abc.abstractmethod
def get_update_method(conf):
"""Return the update method for this driver
update methods available are:
None: updates only via overall snapshots
Pull: updates every [changes_interval] seconds
Push: updates by getting notifications from the datasource itself
:param conf: the datasource's configuration
:return: the update method of the datasource
:rtype: str
"""
return None

View File

@ -64,8 +64,8 @@ class ListenerService(os_service.Service):
@staticmethod @staticmethod
def _get_push_drivers(drivers, conf): def _get_push_drivers(drivers, conf):
return (driver for driver in drivers.values() return (driver_cls for datasource, driver_cls in drivers.items()
if driver.get_update_method(conf).lower() == UpdateMethod.PUSH) if conf[datasource].update_method.lower() == UpdateMethod.PUSH)
def _get_topic_listener(self, conf, topic, callback): def _get_topic_listener(self, conf, topic, callback):
# Create a listener for each topic # Create a listener for each topic

View File

@ -34,7 +34,7 @@ LOG = log.getLogger(__name__)
class NagiosDriver(AlarmDriverBase): class NagiosDriver(AlarmDriverBase):
ServiceKey = namedtuple('ServiceKey', ['host_name', 'service']) ServiceKey = namedtuple('ServiceKey', ['hostname', 'service'])
def __init__(self, conf): def __init__(self, conf):
super(NagiosDriver, self).__init__() super(NagiosDriver, self).__init__()
@ -45,7 +45,7 @@ class NagiosDriver(AlarmDriverBase):
return NAGIOS_DATASOURCE return NAGIOS_DATASOURCE
def _alarm_key(self, alarm): def _alarm_key(self, alarm):
return self.ServiceKey(host_name=alarm[NagiosProps.RESOURCE_NAME], return self.ServiceKey(hostname=alarm[NagiosProps.RESOURCE_NAME],
service=alarm[NagiosProps.SERVICE]) service=alarm[NagiosProps.SERVICE])
def _get_alarms(self): def _get_alarms(self):
@ -103,7 +103,3 @@ class NagiosDriver(AlarmDriverBase):
def _is_valid(self, alarm): def _is_valid(self, alarm):
return alarm[NagiosProps.RESOURCE_TYPE] is not None and \ return alarm[NagiosProps.RESOURCE_TYPE] is not None and \
alarm[NagiosProps.RESOURCE_NAME] is not None alarm[NagiosProps.RESOURCE_NAME] is not None
@staticmethod
def get_update_method(conf):
return conf[NAGIOS_DATASOURCE].update_method

View File

@ -21,10 +21,6 @@ from vitrage.datasources.neutron.network import NEUTRON_NETWORK_DATASOURCE
# noinspection PyAbstractClass # noinspection PyAbstractClass
class NetworkDriver(NeutronBase): class NetworkDriver(NeutronBase):
@staticmethod
def get_update_method(conf):
return conf[NEUTRON_NETWORK_DATASOURCE].update_method
@staticmethod @staticmethod
def get_event_types(conf): def get_event_types(conf):
return ['network.create.end', return ['network.create.end',

View File

@ -21,10 +21,6 @@ from vitrage.datasources.neutron.port import NEUTRON_PORT_DATASOURCE
# noinspection PyAbstractClass # noinspection PyAbstractClass
class PortDriver(NeutronBase): class PortDriver(NeutronBase):
@staticmethod
def get_update_method(conf):
return conf[NEUTRON_PORT_DATASOURCE].update_method
@staticmethod @staticmethod
def get_event_types(conf): def get_event_types(conf):
return ['port.create.end', return ['port.create.end',

View File

@ -27,10 +27,6 @@ class HostDriver(NovaDriverBase):
compute_hosts.append(host_dict) compute_hosts.append(host_dict)
return compute_hosts return compute_hosts
@staticmethod
def get_update_method(conf):
return conf[NOVA_HOST_DATASOURCE].update_method
def get_all(self, sync_mode): def get_all(self, sync_mode):
return self.make_pickleable( return self.make_pickleable(
self.filter_none_compute_hosts(self.client.hosts.list()), self.filter_none_compute_hosts(self.client.hosts.list()),

View File

@ -67,7 +67,3 @@ class InstanceDriver(NovaDriverBase):
'compute.instance.volume.detach', 'compute.instance.volume.detach',
'compute.instance.pause.end', 'compute.instance.pause.end',
'compute.instance.unpause.end'] 'compute.instance.unpause.end']
@staticmethod
def get_update_method(conf):
return conf[NOVA_INSTANCE_DATASOURCE].update_method

View File

@ -27,10 +27,6 @@ class ZoneDriver(NovaDriverBase):
zones_res.append(zone_dict) zones_res.append(zone_dict)
return zones_res return zones_res
@staticmethod
def get_update_method(conf):
return conf[NOVA_ZONE_DATASOURCE].update_method
def get_all(self, sync_mode): def get_all(self, sync_mode):
return self.make_pickleable(self.filter_internal_zone( return self.make_pickleable(self.filter_internal_zone(
self.client.availability_zones.list()), self.client.availability_zones.list()),

View File

@ -32,10 +32,6 @@ class StaticPhysicalDriver(DriverBase):
def enrich_event(event, event_type): def enrich_event(event, event_type):
pass pass
@staticmethod
def get_update_method(conf):
return conf[STATIC_PHYSICAL_DATASOURCE].update_method
ENTITIES_SECTION = 'entities' ENTITIES_SECTION = 'entities'
def __init__(self, conf): def __init__(self, conf):

View File

@ -52,7 +52,7 @@ associated with a user. Follow the steps below as a Zabbix Admin user:
host={HOST.NAME1} host={HOST.NAME1}
hostid={HOST.ID1} hostid={HOST.ID1}
hostip={HOST.IP1} hostip={HOST.IP1}
id={TRIGGER.ID} triggerid={TRIGGER.ID}
description={TRIGGER.NAME} description={TRIGGER.NAME}
rawtext={TRIGGER.NAME.ORIG} rawtext={TRIGGER.NAME.ORIG}
expression={TRIGGER.EXPRESSION} expression={TRIGGER.EXPRESSION}

View File

@ -37,7 +37,7 @@ Message:
host={HOST.NAME1} host={HOST.NAME1}
hostid={HOST.ID1} hostid={HOST.ID1}
hostip={HOST.IP1} hostip={HOST.IP1}
id={TRIGGER.ID} triggerid={TRIGGER.ID}
description={TRIGGER.NAME} description={TRIGGER.NAME}
rawtext={TRIGGER.NAME.ORIG} rawtext={TRIGGER.NAME.ORIG}
expression={TRIGGER.EXPRESSION} expression={TRIGGER.EXPRESSION}

View File

@ -32,7 +32,7 @@ LOG = log.getLogger(__name__)
class ZabbixDriver(AlarmDriverBase): class ZabbixDriver(AlarmDriverBase):
ServiceKey = namedtuple('ServiceKey', ['host_name', 'service']) ServiceKey = namedtuple('ServiceKey', ['hostname', 'triggerid'])
conf_map = None conf_map = None
def __init__(self, conf): def __init__(self, conf):
@ -47,8 +47,8 @@ class ZabbixDriver(AlarmDriverBase):
return ZABBIX_DATASOURCE return ZABBIX_DATASOURCE
def _alarm_key(self, alarm): def _alarm_key(self, alarm):
return self.ServiceKey(host_name=alarm[ZProps.RESOURCE_NAME], return self.ServiceKey(hostname=alarm[ZProps.RESOURCE_NAME],
service=alarm[ZProps.DESCRIPTION]) triggerid=alarm[ZProps.TRIGGER_ID])
def _get_alarms(self): def _get_alarms(self):
zabbix_user = self.conf.zabbix.user zabbix_user = self.conf.zabbix.user
@ -90,7 +90,6 @@ class ZabbixDriver(AlarmDriverBase):
for trigger in triggers: for trigger in triggers:
trigger[ZProps.ZABBIX_RESOURCE_NAME] = host[ZProps.HOST] trigger[ZProps.ZABBIX_RESOURCE_NAME] = host[ZProps.HOST]
trigger_id = trigger[ZProps.TRIGGER_ID] trigger_id = trigger[ZProps.TRIGGER_ID]
trigger[ZProps.RAWTEXT] = triggers_rawtexts[trigger_id] trigger[ZProps.RAWTEXT] = triggers_rawtexts[trigger_id]
alarms.append(trigger) alarms.append(trigger)
@ -118,12 +117,7 @@ class ZabbixDriver(AlarmDriverBase):
zabbix_host = alarm[ZProps.ZABBIX_RESOURCE_NAME] zabbix_host = alarm[ZProps.ZABBIX_RESOURCE_NAME]
vitrage_host = ZabbixDriver.conf_map[zabbix_host] vitrage_host = ZabbixDriver.conf_map[zabbix_host]
alarm[ZProps.RESOURCE_TYPE] = vitrage_host[ZProps.RESOURCE_TYPE] alarm[ZProps.RESOURCE_TYPE] = vitrage_host[ZProps.RESOURCE_TYPE]
vitrage_host_name = vitrage_host[ZProps.RESOURCE_NAME]
alarm[ZProps.RESOURCE_NAME] = vitrage_host[ZProps.RESOURCE_NAME] alarm[ZProps.RESOURCE_NAME] = vitrage_host[ZProps.RESOURCE_NAME]
alarm[ZProps.DESCRIPTION] = alarm[ZProps.DESCRIPTION].replace(
zabbix_host,
vitrage_host_name)
def _is_erroneous(self, alarm): def _is_erroneous(self, alarm):
return alarm and \ return alarm and \
@ -138,7 +132,11 @@ class ZabbixDriver(AlarmDriverBase):
return True return True
if new_alarm[ZProps.VALUE] == TriggerValue.PROBLEM: if new_alarm[ZProps.VALUE] == TriggerValue.PROBLEM:
return new_alarm[ZProps.PRIORITY] != old_alarm[ZProps.PRIORITY] priority_changed = \
new_alarm[ZProps.PRIORITY] != old_alarm[ZProps.PRIORITY]
description_changed = \
new_alarm[ZProps.DESCRIPTION] != old_alarm[ZProps.DESCRIPTION]
return priority_changed or description_changed
def _is_valid(self, alarm): def _is_valid(self, alarm):
return alarm[ZProps.RESOURCE_TYPE] is not None and \ return alarm[ZProps.RESOURCE_TYPE] is not None and \
@ -175,6 +173,7 @@ class ZabbixDriver(AlarmDriverBase):
if ZabbixDriver.conf_map: if ZabbixDriver.conf_map:
zabbix_host = event[ZProps.HOST] zabbix_host = event[ZProps.HOST]
event[ZProps.ZABBIX_RESOURCE_NAME] = zabbix_host
v_resource = ZabbixDriver.conf_map[zabbix_host] v_resource = ZabbixDriver.conf_map[zabbix_host]
event[ZProps.RESOURCE_NAME] = v_resource[ZProps.RESOURCE_NAME] event[ZProps.RESOURCE_NAME] = v_resource[ZProps.RESOURCE_NAME]
event[ZProps.RESOURCE_TYPE] = v_resource[ZProps.RESOURCE_TYPE] event[ZProps.RESOURCE_TYPE] = v_resource[ZProps.RESOURCE_TYPE]
@ -185,7 +184,3 @@ class ZabbixDriver(AlarmDriverBase):
@staticmethod @staticmethod
def get_event_types(conf): def get_event_types(conf):
return ['zabbix.alarm.ok', 'zabbix.alarm.problem'] return ['zabbix.alarm.ok', 'zabbix.alarm.problem']
@staticmethod
def get_update_method(conf):
return conf[ZABBIX_DATASOURCE].update_method

View File

@ -59,6 +59,11 @@ class ZabbixTransformer(AlarmTransformerBase):
update_timestamp = self._format_update_timestamp(update_timestamp, update_timestamp = self._format_update_timestamp(update_timestamp,
sample_timestamp) sample_timestamp)
zabbix_hostname = entity_event[ZProps.ZABBIX_RESOURCE_NAME]
vitrage_hostname = entity_event[ZProps.RESOURCE_NAME]
entity_event[ZProps.DESCRIPTION] = entity_event[ZProps.DESCRIPTION]\
.replace(zabbix_hostname, vitrage_hostname)
value = entity_event[ZProps.VALUE] value = entity_event[ZProps.VALUE]
entity_state = AlarmProps.INACTIVE_STATE if \ entity_state = AlarmProps.INACTIVE_STATE if \
value == TriggerValue.OK else AlarmProps.ACTIVE_STATE value == TriggerValue.OK else AlarmProps.ACTIVE_STATE
@ -133,11 +138,11 @@ class ZabbixTransformer(AlarmTransformerBase):
def _create_entity_key(self, entity_event): def _create_entity_key(self, entity_event):
sync_type = entity_event[DSProps.SYNC_TYPE] sync_type = entity_event[DSProps.SYNC_TYPE]
alarm_name = entity_event[ZProps.DESCRIPTION] alarm_id = entity_event[ZProps.TRIGGER_ID]
resource_name = entity_event[ZProps.RESOURCE_NAME] resource_name = entity_event[ZProps.RESOURCE_NAME]
return tbase.build_key(self._key_values(sync_type, return tbase.build_key(self._key_values(sync_type,
resource_name, resource_name,
alarm_name)) alarm_id))
@staticmethod @staticmethod
def _unify_time_format(entity_event): def _unify_time_format(entity_event):

View File

@ -2,8 +2,10 @@
"sync_type": "zabbix", "sync_type": "zabbix",
"resource_type": "nova\\.host", "resource_type": "nova\\.host",
"resource_name": "compute-[1-9]", "resource_name": "compute-[1-9]",
"zabbix_resource_name": "computer-[1-9]",
"description": "CPU utilization|Check_MK|Uptime", "description": "CPU utilization|Check_MK|Uptime",
"name": "CPU utilization|Check_MK|Uptime", "name": "CPU utilization|Check_MK|Uptime",
"triggerid": "[0-9]*",
"lastchange": "1469450551", "lastchange": "1469450551",
"timestamp": "2015.12.01 12:46:41", "timestamp": "2015.12.01 12:46:41",
"status": "0", "status": "0",

View File

@ -13,7 +13,6 @@
# under the License. # under the License.
from vitrage.datasources.nagios.driver import NagiosDriver from vitrage.datasources.nagios.driver import NagiosDriver
from vitrage.datasources.nagios import NAGIOS_DATASOURCE
from vitrage.tests.mocks import mock_driver from vitrage.tests.mocks import mock_driver
@ -32,10 +31,6 @@ class MockNagiosDriver(NagiosDriver):
def enrich_event(event, event_type): def enrich_event(event, event_type):
pass pass
@staticmethod
def get_update_method(conf):
return conf[NAGIOS_DATASOURCE].update_method
def __init__(self, conf): def __init__(self, conf):
super(MockNagiosDriver, self).__init__(conf) super(MockNagiosDriver, self).__init__(conf)
self.service_datas = None self.service_datas = None

View File

@ -13,7 +13,6 @@
# under the License. # under the License.
from vitrage.datasources.zabbix.driver import ZabbixDriver from vitrage.datasources.zabbix.driver import ZabbixDriver
from vitrage.datasources.zabbix import ZABBIX_DATASOURCE
from vitrage.tests.mocks import mock_driver from vitrage.tests.mocks import mock_driver
@ -32,10 +31,6 @@ class MockZabbixDriver(ZabbixDriver):
def enrich_event(event, event_type): def enrich_event(event, event_type):
pass pass
@staticmethod
def get_update_method(conf):
return conf[ZABBIX_DATASOURCE].update_method
def __init__(self, conf): def __init__(self, conf):
super(MockZabbixDriver, self).__init__(conf) super(MockZabbixDriver, self).__init__(conf)
self.alarm_datas = None self.alarm_datas = None

View File

@ -47,11 +47,11 @@ class ZabbixDriverTest(ZabbixBaseTest):
# Test Setup # Test Setup
zabbix_driver = MockZabbixDriver(self.conf) zabbix_driver = MockZabbixDriver(self.conf)
alarm_data1 = self._extract_alarm_data(description='CPU 1', status='1') alarm_data1 = self._extract_alarm_data(triggerid='1', status='1')
alarm_data2 = self._extract_alarm_data(description='CPU 2', status='1', alarm_data2 = self._extract_alarm_data(triggerid='2', status='1',
value='1') value='1')
alarm_data3 = self._extract_alarm_data(description='CPU 3', value='1') alarm_data3 = self._extract_alarm_data(triggerid='3', value='1')
alarm_data4 = self._extract_alarm_data(description='CPU 4') alarm_data4 = self._extract_alarm_data(triggerid='4')
zabbix_driver.set_alarm_datas([alarm_data1, zabbix_driver.set_alarm_datas([alarm_data1,
alarm_data2, alarm_data2,
@ -74,7 +74,7 @@ class ZabbixDriverTest(ZabbixBaseTest):
alarm_data1 = self._extract_alarm_data() alarm_data1 = self._extract_alarm_data()
alarm_data2 = self._extract_alarm_data(z_resource_name='compute-2') alarm_data2 = self._extract_alarm_data(z_resource_name='compute-2')
alarm_data3 = self._extract_alarm_data(z_resource_name='compute-2', alarm_data3 = self._extract_alarm_data(z_resource_name='compute-2',
description='Uptime') triggerid='2')
zabbix_driver.set_alarm_datas([alarm_data1, alarm_data2, alarm_data3]) zabbix_driver.set_alarm_datas([alarm_data1, alarm_data2, alarm_data3])
@ -212,7 +212,7 @@ class ZabbixDriverTest(ZabbixBaseTest):
alarm_data2 = self._extract_alarm_data(z_resource_name='compute-2', alarm_data2 = self._extract_alarm_data(z_resource_name='compute-2',
priority='1', value='1') priority='1', value='1')
alarm_data3 = self._extract_alarm_data(z_resource_name='compute-2', alarm_data3 = self._extract_alarm_data(z_resource_name='compute-2',
description='Uptime', triggerid='22222',
priority='1') priority='1')
zabbix_driver.set_alarm_datas([alarm_data1, alarm_data2, alarm_data3]) zabbix_driver.set_alarm_datas([alarm_data1, alarm_data2, alarm_data3])
@ -269,7 +269,7 @@ class ZabbixDriverTest(ZabbixBaseTest):
alarm_data2 = self._extract_alarm_data(z_resource_name='compute-2', alarm_data2 = self._extract_alarm_data(z_resource_name='compute-2',
priority='2') priority='2')
alarm_data3 = self._extract_alarm_data(z_resource_name='compute-2', alarm_data3 = self._extract_alarm_data(z_resource_name='compute-2',
description='Uptime') triggerid='2')
zabbix_driver.set_alarm_datas([alarm_data1, alarm_data2, alarm_data3]) zabbix_driver.set_alarm_datas([alarm_data1, alarm_data2, alarm_data3])
# Step action # Step action
@ -333,13 +333,13 @@ class ZabbixDriverTest(ZabbixBaseTest):
self.assertIsNotNone(changed_alarms, 'No alarms returned') self.assertIsNotNone(changed_alarms, 'No alarms returned')
self.assertEqual(0, len(changed_alarms)) self.assertEqual(0, len(changed_alarms))
# Step 5 - get changes # Step 6 - get changes
# Step setup # Step setup
alarm_data2 = self._extract_alarm_data(z_resource_name='compute-2', alarm_data2 = self._extract_alarm_data(z_resource_name='compute-2',
priority='4', priority='4',
value='1') value='1')
alarm_data3 = self._extract_alarm_data(z_resource_name='compute-2', alarm_data3 = self._extract_alarm_data(z_resource_name='compute-2',
description='Uptime', triggerid='2',
priority='4', priority='4',
value='1') value='1')
@ -348,7 +348,7 @@ class ZabbixDriverTest(ZabbixBaseTest):
expected_alarm1 = copy.copy(alarm_data2) expected_alarm1 = copy.copy(alarm_data2)
expected_alarm1[ZProps.RESOURCE_NAME] = 'host2' expected_alarm1[ZProps.RESOURCE_NAME] = 'host2'
expected_alarm2 = copy.copy(expected_alarm1) expected_alarm2 = copy.copy(expected_alarm1)
expected_alarm2[ZProps.DESCRIPTION] = 'Uptime' expected_alarm2[ZProps.TRIGGER_ID] = '2'
# Step action # Step action
alarms = zabbix_driver._get_changed_alarms() alarms = zabbix_driver._get_changed_alarms()
@ -365,7 +365,7 @@ class ZabbixDriverTest(ZabbixBaseTest):
alarm_data1 = self._extract_alarm_data(value='1') alarm_data1 = self._extract_alarm_data(value='1')
alarm_data2 = self._extract_alarm_data(z_resource_name='compute-2') alarm_data2 = self._extract_alarm_data(z_resource_name='compute-2')
alarm_data3 = self._extract_alarm_data(z_resource_name='compute-2', alarm_data3 = self._extract_alarm_data(z_resource_name='compute-2',
description='Uptime') triggerid='2')
# Step 1 - delete inactive alarm # Step 1 - delete inactive alarm
# Step setup # Step setup
@ -425,11 +425,13 @@ class ZabbixDriverTest(ZabbixBaseTest):
description='cpu', description='cpu',
status='0', status='0',
value='0', value='0',
priority='1'): priority='1',
triggerid='0'):
return {ZProps.ZABBIX_RESOURCE_NAME: z_resource_name, return {ZProps.ZABBIX_RESOURCE_NAME: z_resource_name,
ZProps.DESCRIPTION: description, ZProps.DESCRIPTION: description,
ZProps.STATUS: status, ZProps.STATUS: status,
ZProps.VALUE: value, ZProps.VALUE: value,
ZProps.PRIORITY: priority, ZProps.PRIORITY: priority,
ZProps.RESOURCE_NAME: z_resource_name} ZProps.RESOURCE_NAME: z_resource_name,
ZProps.TRIGGER_ID: triggerid}

View File

@ -70,7 +70,7 @@ class ZabbixTransformerTest(base.BaseTest):
self.assertEqual(event[DSProps.SYNC_TYPE], observed_key_fields[1]) self.assertEqual(event[DSProps.SYNC_TYPE], observed_key_fields[1])
self.assertEqual(event[ZabbixProps.RESOURCE_NAME], self.assertEqual(event[ZabbixProps.RESOURCE_NAME],
observed_key_fields[2]) observed_key_fields[2])
self.assertEqual(event[ZabbixProps.DESCRIPTION], self.assertEqual(event[ZabbixProps.TRIGGER_ID],
observed_key_fields[3]) observed_key_fields[3])
def test_zabbix_alarm_transform(self): def test_zabbix_alarm_transform(self):

View File

@ -22,14 +22,14 @@ class ZabbixBaseTest(base.BaseTest):
for alarm in alarms: for alarm in alarms:
if alarm[ZabbixProps.RESOURCE_NAME] == \ if alarm[ZabbixProps.RESOURCE_NAME] == \
expected_serv[ZabbixProps.RESOURCE_NAME] and \ expected_serv[ZabbixProps.RESOURCE_NAME] and \
alarm[ZabbixProps.DESCRIPTION] == \ alarm[ZabbixProps.TRIGGER_ID] == \
expected_serv[ZabbixProps.DESCRIPTION]: expected_serv[ZabbixProps.TRIGGER_ID]:
self._assert_expected_alarm(expected_serv, alarm) self._assert_expected_alarm(expected_serv, alarm)
return return
self.fail("alarm not found: %s %s" % self.fail("alarm not found: %s %s" %
(expected_serv[ZabbixProps.RESOURCE_NAME], (expected_serv[ZabbixProps.RESOURCE_NAME],
expected_serv[ZabbixProps.DESCRIPTION])) expected_serv[ZabbixProps.TRIGGER_ID]))
def _assert_expected_alarm(self, expected_alarm, alarm): def _assert_expected_alarm(self, expected_alarm, alarm):
for key, value in expected_alarm.items(): for key, value in expected_alarm.items():