def _create_neighbors(self, event):

        event_type = event[EVALUATOR_EVENT_TYPE]

        timestamp = transformer_base.convert_timestamp_format(
            '%Y-%m-%d %H:%M:%S.%f', event[VProps.UPDATE_TIMESTAMP])

        if event_type in [ADD_EDGE, REMOVE_EDGE]:

            relation_edge = graph_utils.create_edge(
                source_id=event[TFields.SOURCE],
                target_id=event[TFields.TARGET],
                relationship_type=event[EProps.RELATIONSHIP_TYPE],
                update_timestamp=timestamp)

            return [Neighbor(None, relation_edge)]

        if event_type == ADD_VERTEX:

            relation_edge = graph_utils.create_edge(
                source_id=self._create_entity_key(event),
                target_id=event[TFields.TARGET],
                relationship_type=EdgeLabels.ON,
                update_timestamp=timestamp)

            neighbor_props = {
                VProps.IS_PLACEHOLDER: True,
                VProps.UPDATE_TIMESTAMP: timestamp,
                VProps.SAMPLE_TIMESTAMP: event[VProps.SAMPLE_TIMESTAMP]
            }
            neighbor = Vertex(event[TFields.TARGET], neighbor_props)
            return [Neighbor(neighbor, relation_edge)]

        return []
    def _create_vertex(self, event):

        event_type = event[EVALUATOR_EVENT_TYPE]

        update_timestamp = transformer_base.convert_timestamp_format(
            '%Y-%m-%d %H:%M:%S.%f', event[VProps.UPDATE_TIMESTAMP])

        if event_type == UPDATE_VERTEX:
            properties = {
                VProps.VITRAGE_STATE: event[VProps.VITRAGE_STATE],
                VProps.UPDATE_TIMESTAMP: update_timestamp,
                VProps.SAMPLE_TIMESTAMP: event[VProps.SAMPLE_TIMESTAMP],
                VProps.IS_PLACEHOLDER: False
            }
            return Vertex(event[VProps.VITRAGE_ID], properties)

        if event_type in [ADD_VERTEX, REMOVE_VERTEX]:

            metadata = {
                VProps.NAME: event[TFields.ALARM_NAME],
                VProps.SEVERITY: event[TFields.SEVERITY],
                VProps.STATE: event[VProps.STATE]
            }
            return graph_utils.create_vertex(
                self._create_entity_key(event),
                entity_category=EntityCategory.ALARM,
                entity_type=VITRAGE_TYPE,
                sample_timestamp=event[VProps.SAMPLE_TIMESTAMP],
                update_timestamp=update_timestamp,
                metadata=metadata)

        return None
    def _create_vitrage_neighbors(self, event):
        event_type = event[EVALUATOR_EVENT_TYPE]

        timestamp = transformer_base.convert_timestamp_format(
            '%Y-%m-%d %H:%M:%S.%f',
            event[VProps.UPDATE_TIMESTAMP]
        )

        if event_type in [ADD_EDGE, REMOVE_EDGE]:

            relation_edge = graph_utils.create_edge(
                source_id=event[TFields.SOURCE],
                target_id=event[TFields.TARGET],
                relationship_type=event[EProps.RELATIONSHIP_TYPE],
                update_timestamp=timestamp)

            return [Neighbor(None, relation_edge)]

        if event_type == ADD_VERTEX:

            relation_edge = graph_utils.create_edge(
                source_id=self._create_entity_key(event),
                target_id=event[TFields.TARGET],
                relationship_type=EdgeLabel.ON,
                update_timestamp=timestamp)

            neighbor_props = {
                VProps.IS_PLACEHOLDER: True,
                VProps.UPDATE_TIMESTAMP: timestamp,
                VProps.SAMPLE_TIMESTAMP: event[VProps.SAMPLE_TIMESTAMP]
            }
            neighbor = Vertex(event[TFields.TARGET], neighbor_props)
            return [Neighbor(neighbor, relation_edge)]

        return []
Exemple #4
0
    def _create_vitrage_neighbors(self, event):
        event_type = event[EVALUATOR_EVENT_TYPE]

        timestamp = transformer_base.convert_timestamp_format(
            '%Y-%m-%d %H:%M:%S.%f', event[VProps.UPDATE_TIMESTAMP])

        if event_type in [ADD_EDGE, REMOVE_EDGE]:

            relation_edge = graph_utils.create_edge(
                source_id=event[TFields.SOURCE],
                target_id=event[TFields.TARGET],
                relationship_type=event[EProps.RELATIONSHIP_TYPE],
                update_timestamp=timestamp)

            return [Neighbor(None, relation_edge)]

        if event_type == ADD_VERTEX:
            result = []

            relation_edge = graph_utils.create_edge(
                source_id=TransformerBase.uuid_from_deprecated_vitrage_id(
                    self._create_entity_key(event)),
                target_id=event[TFields.TARGET],
                relationship_type=EdgeLabel.ON,
                update_timestamp=timestamp)

            neighbor_props = {
                VProps.VITRAGE_IS_PLACEHOLDER:
                True,
                VProps.UPDATE_TIMESTAMP:
                timestamp,
                VProps.VITRAGE_SAMPLE_TIMESTAMP:
                event[VProps.VITRAGE_SAMPLE_TIMESTAMP],
                VProps.IS_REAL_VITRAGE_ID:
                True,
                VProps.VITRAGE_TYPE:
                event.get(VProps.VITRAGE_RESOURCE_TYPE),
                VProps.VITRAGE_CATEGORY:
                EntityCategory.RESOURCE,
            }
            result.append(
                Neighbor(Vertex(event[TFields.TARGET], neighbor_props),
                         relation_edge))
            if event.get(TFields.CAUSING_ALARM):
                relation_edge = graph_utils.create_edge(
                    source_id=event[TFields.CAUSING_ALARM],
                    target_id=TransformerBase.uuid_from_deprecated_vitrage_id(
                        self._create_entity_key(event)),
                    relationship_type=EdgeLabel.CAUSES,
                    update_timestamp=timestamp)
                result.append(
                    Neighbor(
                        Vertex(
                            event[TFields.CAUSING_ALARM], {
                                VProps.UPDATE_TIMESTAMP: timestamp,
                                VProps.VITRAGE_IS_PLACEHOLDER: True,
                            }), relation_edge))
            return result

        return []
Exemple #5
0
    def _create_vertex(self, event):

        event_type = event[EVALUATOR_EVENT_TYPE]

        update_timestamp = transformer_base.convert_timestamp_format(
            '%Y-%m-%d %H:%M:%S.%f', event[VProps.UPDATE_TIMESTAMP])

        if event_type == UPDATE_VERTEX:
            properties = {
                VProps.UPDATE_TIMESTAMP: update_timestamp,
                VProps.VITRAGE_IS_PLACEHOLDER: False,
                VProps.RESOURCE_ID: event.get(TFields.TARGET)
            }
            if VProps.IS_REAL_VITRAGE_ID in event:
                properties[VProps.IS_REAL_VITRAGE_ID] = \
                    event.get(VProps.IS_REAL_VITRAGE_ID)
            if VProps.VITRAGE_STATE in event:
                properties[VProps.VITRAGE_STATE] = \
                    event.get(VProps.VITRAGE_STATE)
            if VProps.IS_MARKED_DOWN in event:
                properties[VProps.IS_MARKED_DOWN] = \
                    event.get(VProps.IS_MARKED_DOWN)

            return Vertex(event[VProps.VITRAGE_ID], properties)

        if event_type in [ADD_VERTEX, REMOVE_VERTEX]:

            metadata = {
                VProps.NAME: event[TFields.ALARM_NAME],
                VProps.SEVERITY: event[TFields.SEVERITY],
                VProps.STATE: event[VProps.STATE],
                VProps.RESOURCE_ID: event.get(TFields.TARGET)
            }
            return graph_utils.create_vertex(
                self._create_entity_key(event),
                vitrage_category=EntityCategory.ALARM,
                vitrage_type=VITRAGE_DATASOURCE,
                vitrage_sample_timestamp=event[
                    VProps.VITRAGE_SAMPLE_TIMESTAMP],
                update_timestamp=update_timestamp,
                metadata=metadata)

        return None
    def _create_vertex(self, event):

        event_type = event[EVALUATOR_EVENT_TYPE]

        update_timestamp = transformer_base.convert_timestamp_format(
            '%Y-%m-%d %H:%M:%S.%f',
            event[VProps.UPDATE_TIMESTAMP]
        )

        if event_type == UPDATE_VERTEX:
            properties = {
                VProps.UPDATE_TIMESTAMP: update_timestamp,
                VProps.SAMPLE_TIMESTAMP: event[VProps.SAMPLE_TIMESTAMP],
                VProps.IS_PLACEHOLDER: False,
                VProps.RESOURCE_ID: event.get(TFields.TARGET)
            }
            if VProps.VITRAGE_STATE in event:
                properties[VProps.VITRAGE_STATE] = \
                    event.get(VProps.VITRAGE_STATE)
            if VProps.IS_MARKED_DOWN in event:
                properties[VProps.IS_MARKED_DOWN] = \
                    event.get(VProps.IS_MARKED_DOWN)

            return Vertex(event[VProps.VITRAGE_ID], properties)

        if event_type in [ADD_VERTEX, REMOVE_VERTEX]:

            metadata = {
                VProps.NAME: event[TFields.ALARM_NAME],
                VProps.SEVERITY: event[TFields.SEVERITY],
                VProps.STATE: event[VProps.STATE],
                VProps.RESOURCE_ID: event.get(TFields.TARGET)
            }
            return graph_utils.create_vertex(
                self._create_entity_key(event),
                entity_category=EntityCategory.ALARM,
                entity_type=VITRAGE_TYPE,
                sample_timestamp=event[VProps.SAMPLE_TIMESTAMP],
                update_timestamp=update_timestamp,
                metadata=metadata)

        return None