示例#1
0
    def _validate_host_neighbor(self, neighbor, event):

        host_vertex = neighbor.vertex

        observed_key = host_vertex.vertex_id

        expected_key = tbase.build_key(
            (EntityCategory.RESOURCE, NOVA_HOST_DATASOURCE,
             event[ZabbixProps.RESOURCE_NAME]))
        expected_uuid = \
            TransformerBase.uuid_from_deprecated_vitrage_id(expected_key)

        self.assertEqual(expected_uuid, observed_key)
        self.assertEqual(expected_uuid,
                         host_vertex.properties.get(VProps.VITRAGE_ID))

        self.assertFalse(host_vertex[VProps.VITRAGE_IS_DELETED])
        self.assertTrue(host_vertex[VProps.VITRAGE_IS_PLACEHOLDER])

        self.assertEqual(EntityCategory.RESOURCE,
                         host_vertex[VProps.VITRAGE_CATEGORY])
        self.assertEqual(event[ZabbixProps.RESOURCE_NAME],
                         host_vertex[VProps.ID])
        self.assertEqual(NOVA_HOST_DATASOURCE,
                         host_vertex[VProps.VITRAGE_TYPE])

        edge = neighbor.edge
        self.assertEqual(EdgeLabel.ON, edge.label)

        alarm_key = ZabbixTransformer(self.transformers, self.conf).\
            _create_entity_key(event)
        alarm_uuid = TransformerBase.uuid_from_deprecated_vitrage_id(alarm_key)
        self.assertEqual(alarm_uuid, edge.source_id)
        self.assertEqual(host_vertex.vertex_id, edge.target_id)
示例#2
0
    def _validate_host_neighbor(self, neighbor, event):

        host_vertex = neighbor.vertex

        key_fields = host_vertex.vertex_id.split(TransformerBase.KEY_SEPARATOR)

        self.assertEqual(EntityCategory.RESOURCE, key_fields[0])
        self.assertEqual(NOVA_HOST_DATASOURCE, key_fields[1])
        self.assertEqual(event[ZabbixProps.RESOURCE_NAME], key_fields[2])

        self.assertFalse(host_vertex[VProps.IS_DELETED])
        self.assertTrue(host_vertex[VProps.IS_PLACEHOLDER])

        self.assertEqual(EntityCategory.RESOURCE, host_vertex[VProps.CATEGORY])
        self.assertEqual(event[ZabbixProps.RESOURCE_NAME],
                         host_vertex[VProps.ID])
        self.assertEqual(NOVA_HOST_DATASOURCE, host_vertex[VProps.TYPE])

        edge = neighbor.edge
        self.assertEqual(EdgeLabel.ON, edge.label)

        alarm_key = ZabbixTransformer(self.transformers, self.conf).\
            _create_entity_key(event)
        self.assertEqual(alarm_key, edge.source_id)
        self.assertEqual(host_vertex.vertex_id, edge.target_id)
示例#3
0
    def test_extract_key(self):
        LOG.debug('Test get key from nova instance transformer')

        # Test setup
        spec_list = mock_sync.simple_zabbix_alarm_generators(host_num=1,
                                                             events_num=1)
        zabbix_alarms = mock_sync.generate_sequential_events_list(spec_list)
        transformer = ZabbixTransformer(self.transformers, self.conf)
        event = zabbix_alarms[0]
        self.enrich_event(event)

        # Test action
        observed_key = transformer._create_entity_key(event)

        # Test assertions
        observed_key_fields = observed_key.split(TransformerBase.KEY_SEPARATOR)

        self.assertEqual(EntityCategory.ALARM, observed_key_fields[0])
        self.assertEqual(event[DSProps.ENTITY_TYPE], observed_key_fields[1])
        self.assertEqual(event[ZabbixProps.RESOURCE_NAME],
                         observed_key_fields[2])
        self.assertEqual(event[ZabbixProps.TRIGGER_ID], observed_key_fields[3])
    def test_extract_key(self):
        LOG.debug('Test get key from nova instance transformer')

        # Test setup
        spec_list = mock_sync.simple_zabbix_alarm_generators(host_num=1,
                                                             events_num=1)
        zabbix_alarms = mock_sync.generate_sequential_events_list(spec_list)
        transformer = ZabbixTransformer(self.transformers, self.conf)
        event = zabbix_alarms[0]
        self.enrich_event(event)

        # Test action
        observed_key = transformer._create_entity_key(event)

        # Test assertions
        observed_key_fields = observed_key.split(
            TransformerBase.KEY_SEPARATOR)

        self.assertEqual(EntityCategory.ALARM, observed_key_fields[0])
        self.assertEqual(event[DSProps.ENTITY_TYPE], observed_key_fields[1])
        self.assertEqual(event[ZabbixProps.RESOURCE_NAME],
                         observed_key_fields[2])
        self.assertEqual(event[ZabbixProps.TRIGGER_ID],
                         observed_key_fields[3])
示例#5
0
    def test_zabbix_alarm_transform(self):
        LOG.debug('Zabbix alarm transformer test: transform entity event')

        # Test setup
        spec_list = mock_sync.simple_zabbix_alarm_generators(host_num=4,
                                                             events_num=10)
        zabbix_alarms = mock_sync.generate_sequential_events_list(spec_list)

        for alarm in zabbix_alarms:
            # Test action
            self.enrich_event(alarm, format_timestamp=False)
            wrapper = ZabbixTransformer(self.transformers, self.conf)\
                .transform(alarm)
            self._validate_vertex(wrapper.vertex, alarm)

            neighbors = wrapper.neighbors
            self.assertEqual(1, len(neighbors))
            neighbor = neighbors[0]

            # Right now we are support only host as a resource
            if neighbor.vertex[VProps.TYPE] == NOVA_HOST_DATASOURCE:
                self._validate_host_neighbor(neighbors[0], alarm)

            self._validate_action(alarm, wrapper)