Ejemplo n.º 1
0
 def get_report_log_entries(self):
     entries = []
     for measurement in list_measurements():
         try:
             entry = yield self.get_report_log(measurement['id'])
             entry['completed'] = measurement['completed']
             entries.append(entry)
         except NoReportLog:
             continue
     defer.returnValue(entries)
Ejemplo n.º 2
0
 def get_report_log_entries(self):
     entries = []
     for measurement in list_measurements():
         try:
             entry = yield self.get_report_log(measurement['id'])
             entry['completed'] = measurement['completed']
             entries.append(entry)
         except NoReportLog:
             continue
     defer.returnValue(entries)
Ejemplo n.º 3
0
 def task(self):
     measurement_path = FilePath(config.measurements_directory)
     for measurement in list_measurements():
         if measurement['keep'] is True:
             continue
         delta = datetime.utcnow() - \
                 datetime.strptime(measurement['test_start_time'],
                                   SHORT_DATE)
         if delta.days >= 7:
             log.debug("Deleting old report {0}".format(measurement["id"]))
             measurement_path.child(measurement['id']).remove()
Ejemplo n.º 4
0
 def task(self):
     measurement_path = FilePath(config.measurements_directory)
     for measurement in list_measurements():
         if measurement['keep'] is True:
             continue
         delta = datetime.utcnow() - \
                 datetime.strptime(measurement['test_start_time'],
                                   SHORT_DATE)
         if delta.days >= 7:
             log.debug("Deleting old report {0}".format(measurement["id"]))
             measurement_path.child(measurement['id']).remove()
Ejemplo n.º 5
0
 def api_measurement_list(self, request):
     measurements = list_measurements(order='desc')
     for measurement in measurements:
         if measurement['running'] == False:
             continue
         try:
             net_test = self.director.activeMeasurements[measurement['id']]
             measurement['progress'] = net_test.completionPercentage * 100
         except KeyError:
             log.err("Did not find measurement with ID %s" % measurement['id'])
     return self.render_json({"measurements": measurements}, request)
Ejemplo n.º 6
0
 def api_measurement_list(self, request):
     measurements = list_measurements(order='desc')
     for measurement in measurements:
         if measurement['running'] == False:
             continue
         try:
             net_test = self.director.activeMeasurements[measurement['id']]
             measurement['progress'] = net_test.completionPercentage * 100
         except KeyError:
             log.err("Did not find measurement with ID %s" % measurement['id'])
     return self.render_json({"measurements": measurements}, request)
Ejemplo n.º 7
0
    def task(self):
        if config.basic.measurement_quota is None:
            return
        maximum_bytes = human_size_to_bytes(config.basic.measurement_quota)
        used_bytes = directory_usage(config.measurements_directory)
        warning_path = os.path.join(config.running_path, 'quota_warning')

        if (float(used_bytes) / float(maximum_bytes)) >= self._warn_when:
            log.warn("You are about to reach the maximum allowed quota. Be careful")
            with open(warning_path, "w") as out_file:
                out_file.write("{0} {1}".format(used_bytes,
                                                maximum_bytes))
        else:
            try:
                os.remove(warning_path)
            except OSError as ose:
                if ose.errno != errno.ENOENT:
                    raise

        if float(used_bytes) < float(maximum_bytes):
            # We are within the allow quota exit.
            return

        # We should begin to delete old reports
        amount_to_delete = float(used_bytes) - float(maximum_bytes)
        amount_deleted = 0
        measurement_path = FilePath(config.measurements_directory)

        kept_measurements = []
        stale_measurements = []
        remaining_measurements = []
        measurements_by_date = sorted(list_measurements(compute_size=True),
                                      key=lambda k: k['test_start_time'])
        for measurement in measurements_by_date:
            if measurement['keep'] is True:
                kept_measurements.append(measurement)
            elif measurement['stale'] is True:
                stale_measurements.append(measurement)
            else:
                remaining_measurements.append(measurement)

        # This is the order in which we should begin deleting measurements.
        ordered_measurements = (stale_measurements +
                                remaining_measurements +
                                kept_measurements)
        while amount_deleted < amount_to_delete:
            measurement = ordered_measurements.pop(0)
            log.warn("Deleting report {0}".format(measurement["id"]))
            measurement_path.child(measurement['id']).remove()
            amount_deleted += measurement['size']
Ejemplo n.º 8
0
 def api_measurement_list(self, request):
     measurements = list_measurements(order='desc')
     return self.render_json({"measurements": measurements}, request)
Ejemplo n.º 9
0
 def api_measurement_list(self, request):
     measurements = list_measurements(order='desc')
     return self.render_json({"measurements": measurements}, request)