Esempio n. 1
0
    def get_graphs(self, request):
        logging.debug('Got %s', request)
        project_id = request.project_id
        revision, project_cfg = config.get_project_config(
            project_id, 'project.cfg', project_config_pb2.ProjectCfg)

        if revision is None:
            logging.warning('Project %s does not have project.cfg', project_id)
            return TimeSeriesPacket()

        graph_list = []
        if not _has_access(project_cfg.access):
            logging.warning('Access to %s is denied for user %s', project_id,
                            auth.get_current_identity())
            return TimeSeriesPacket()

        namespace_manager.set_namespace('projects.%s' % project_id)
        for graph in TimeSeriesModel.query():
            field_list = [
                Field(key=field.field_key, value=field.value)
                for field in graph.fields
            ]
            point_list = [
                Point(time=point.time, value=point.value)
                for point in graph.points
            ]
            graph_list.append(
                TimeSeries(points=point_list,
                           fields=field_list,
                           metric=graph.metric))

        return TimeSeriesPacket(timeseries=graph_list,
                                project_name=project_cfg.name)
Esempio n. 2
0
  def get_graphs(self, request):
    logging.debug('Got %s', request)
    project_id = request.project_id
    revision, project_cfg = config.get_project_config(
        project_id, 'project.cfg', project_config_pb2.ProjectCfg)

    if revision is None:
      logging.warning('Project %s does not have project.cfg', project_id)
      return TimeSeriesPacket()

    graph_list = []
    if not _has_access(project_cfg.access):
      logging.warning('Access to %s is denied for user %s',
                  project_id, auth.get_current_identity())
      return TimeSeriesPacket()

    namespace_manager.set_namespace('projects.%s' % project_id)
    for graph in TimeSeriesModel.query():
      field_list = [Field(key=field.field_key, value=field.value)
                    for field in graph.fields]
      point_list = [Point(time=point.time, value=point.value)
                    for point in graph.points]
      graph_list.append(TimeSeries(points=point_list,
                                   fields=field_list,
                                   metric=graph.metric))

    return TimeSeriesPacket(timeseries=graph_list,
                            project_name=project_cfg.name)
Esempio n. 3
0
 def test_get_project_config(self):
   revision, cfg = config.get_project_config(
       'foo', 'bar.cfg', test_config_pb2.Config)
   self.assertEqual(revision, 'deadbeef')
   self.assertEqual(cfg.param, 'value')
Esempio n. 4
0
 def test_get_project_config(self):
   revision, cfg = config.get_project_config(
       'foo', 'bar.cfg', test_config_pb2.Config)
   self.assertEqual(revision, 'deadbeef')
   self.assertEqual(cfg.param, 'value')