Exemplo n.º 1
0
    def dump_list(self, datasets):
        ret = []

        lastgroup = None
        for dataset in datasets:
            fileset = dataset.database_object
            hostgroup = fileset.hostgroup if fileset else '(nogroup)'
            if lastgroup != hostgroup:
                lastgroup = hostgroup
                if ret:
                    ret.append('')
                ret.append('; {}'.format(hostgroup))

            if fileset:
                ret.append('{dataset.identifier:54s}  {disk_usage:>8s}  '
                           'id={fileset.id}'.format(dataset=dataset,
                                                    disk_usage=human.bytes(
                                                        dataset.disk_usage),
                                                    fileset=fileset))
            else:
                ret.append('{dataset.identifier:54s}  {disk_usage:>8s}  '
                           'id=NONE'.format(dataset=dataset,
                                            disk_usage=human.bytes(
                                                dataset.disk_usage)))

        if ret:
            ret.extend(['', ''])
            self.stdout.write('\n'.join(ret))
Exemplo n.º 2
0
    def last_ok_snapshot(self, object):
        try:
            run = object.last_successful_backuprun
        except BackupRun.DoesNotExist:
            return '-'

        ret = ['<table>']
        for path, size in run.snapshot_size_listing_as_list():
            ret.append(
                '<tr><td style="padding:0;"><code>{}</code></td>'
                '<td style="padding:0;text-align:right;">{}</td></tr>'.format(
                    htmlesc(path), human.bytes(size)))
        ret.append(
            '<tr><th style="padding:0;">TOTAL</th>'
            '<th style="padding:0;text-align:right;">{}</th></tr>'.format(
                human.bytes(run.snapshot_size)))
        ret.append('</table>')
        return mark_safe(''.join(ret))
Exemplo n.º 3
0
 def disk_usage(self, object):
     return human.bytes(object.total_size_mb << 20)