Beispiel #1
0
def domain_report(request, domain_name):
    requester = report_auth(request)
    if requester and (domain_name in requester['domains'] or '*' in requester['domains']):
        data = []
        domain_tag = get_object_or_404(Tag, name='domain:%s' % domain_name)
        users, total_files, total_bytecount = tasks.get_domain_content(domain_tag)
        for item in users:
            value = float(item['bytecount'])
            max_value = float(total_bytecount)
            percent = (value / max_value) * 100
            data.append({
                'username': item['username'],
                'number_of_files': item['number_of_files'],
                'storage_used (B)': item['bytecount'],
                'percent': '{0:0.2g}%'.format(int(round(percent)))
            })
        return dicts_to_csv_response(data, header=['username', 'number_of_files', 'storage_used (B)', 'percent'])
    return HttpResponseForbidden()
Beispiel #2
0
def cluster_report(request, cluster_name):
    requester = report_auth(request)
    if requester and cluster_name in requester['clusters']:
        data = []
        acc = get_object_or_404(ACCluster, name=cluster_name)
        domains, total_bytecount = tasks.get_cluster_content(acc)
        for item in domains:
            value = float(item['domain_bytes'])
            max_value = float(total_bytecount)
            percent = (value / max_value) * 100
            data.append({
                'domain': item['domain'],
                'number_of_files': item['number_of_files'],
                'storage_used (B)': item['domain_bytes'],
                'percent': '{0:0.2g}%'.format(int(round(percent)))
            })
        return dicts_to_csv_response(data, header=['domain', 'number_of_files', 'storage_used (B)', 'percent'])
    return HttpResponseForbidden()