예제 #1
0
    def get_all(self, driver_name, action):
        try:
            LOCK_BY_DRIVER.acquire(driver_name)
            driver = utils.get_drivers_by_name([driver_name])[0]
            LOG.info("run driver get_all: %s", driver_name)
            now = format_utcnow()
            events = driver.get_all(action)
            count = self.process_output_func(events)
            LOG.info("run driver get_all: %s done (%s events)", driver_name,
                     count)

            if driver.should_delete_outdated_entities():
                vertices_to_delete = \
                    self._find_vertices_to_delete(driver_name, now)
                if vertices_to_delete:
                    delete_events = self._to_events(vertices_to_delete)
                    count_deleted = self.process_output_func(delete_events)
                    LOG.info(
                        "run driver delete outdated vertices: %s done "
                        "(%s events)", driver_name, count_deleted)
                    count += count_deleted
            return count
        except Exception:
            LOG.exception("run driver get_all: %s Failed", driver_name)
        finally:
            LOCK_BY_DRIVER.release(driver_name)
        return 0
예제 #2
0
 def test_snapshot_event_transform(self):
     sample_timestamp = format_utcnow()
     for event in events:
         event[DSProps.DATASOURCE_ACTION] = DatasourceAction.SNAPSHOT
         event[DSProps.SAMPLE_DATE] = sample_timestamp
         wrapper = self.transformers[CETUS_POD_DATASOURCE].transform(event)
         vertex = wrapper.vertex
         self._validate_vertex_props(vertex, event)
         neighbors = wrapper.neighbors
         self.assertThat(neighbors, matchers.HasLength(1))
         self._validate_neighbors(neighbors, vertex.vertex_id)
예제 #3
0
 def _to_events(vertices):
     return ({
         DSProps.ENTITY_TYPE: CONSISTENCY_DATASOURCE,
         DSProps.DATASOURCE_ACTION: DatasourceAction.UPDATE,
         DSProps.SAMPLE_DATE: format_utcnow(),
         DSProps.EVENT_TYPE: GraphAction.DELETE_ENTITY,
         VProps.VITRAGE_ID: vertex[VProps.VITRAGE_ID],
         VProps.ID: vertex.get(VProps.ID, None),
         VProps.VITRAGE_TYPE: vertex[VProps.VITRAGE_TYPE],
         VProps.VITRAGE_CATEGORY: vertex[VProps.VITRAGE_CATEGORY],
         VProps.IS_REAL_VITRAGE_ID: True
     } for vertex in vertices)
예제 #4
0
 def _to_events(self, vertices, action):
     for vertex in vertices:
         event = {
             DSProps.ENTITY_TYPE: CONSISTENCY_DATASOURCE,
             DSProps.DATASOURCE_ACTION: DatasourceAction.UPDATE,
             DSProps.SAMPLE_DATE: datetime.format_utcnow(),
             DSProps.EVENT_TYPE: action,
             VProps.VITRAGE_ID: vertex[VProps.VITRAGE_ID],
             VProps.ID: vertex.get(VProps.ID, None),
             VProps.VITRAGE_TYPE: vertex[VProps.VITRAGE_TYPE],
             VProps.VITRAGE_CATEGORY: vertex[VProps.VITRAGE_CATEGORY],
             VProps.IS_REAL_VITRAGE_ID: True
         }
         yield event
예제 #5
0
 def _add_sampling_time(entity):
     entity[DSProps.SAMPLE_DATE] = datetime_utils.format_utcnow()
예제 #6
0
    def _add_default_properties(event):

        event[DSProps.DATASOURCE_ACTION] = AType.UPDATE
        event[DSProps.ENTITY_TYPE] = VITRAGE_DATASOURCE
        event[VProps.UPDATE_TIMESTAMP] = str(datetime_utils.utcnow(False))
        event[VProps.VITRAGE_SAMPLE_TIMESTAMP] = datetime_utils.format_utcnow()