diff --git a/accountstats/templates/accountstats/account.html b/accountstats/templates/accountstats/account.html index 2939acf..df2e345 100644 --- a/accountstats/templates/accountstats/account.html +++ b/accountstats/templates/accountstats/account.html @@ -2,7 +2,7 @@ {% load humanize %} {% load i18n %} -{% block title %}{% translate "Account use of" %} {{ account }}{% endblock title %} +{% block title %}{% translate "Account use of" %} {{ account | anonymize }}{% endblock title %} {% block content %} {% include "notes_header.html" %} @@ -10,7 +10,7 @@

{% translate "Create a new note" %}

{% endif %} -

{% translate "Account use of" %} {{ account }}

+

{% translate "Account use of" %} {{ account | anonymize}}

@@ -222,6 +222,13 @@

{% translate "Jobs running with this account" %}

{ data: 'username', orderable: false, searchable: false, + render: function(date, type, row, meta){ + if(document.getElementById("demo")){ + return '[redacted]'; + } else { + return row.username; + } + } }, { data: 'id_job', render: function ( data, type, row ) { @@ -235,7 +242,15 @@

{% translate "Jobs running with this account" %}

return '' + data + ''; } }, - { data: 'job_name' }, + { data: 'job_name', + render: function(date, type, row, meta){ + if(document.getElementById("demo")){ + return '[redacted]'; + } else { + return row.job_name; + } + } + }, { data: 'time_submit', render: parse_time, }, diff --git a/accountstats/views.py b/accountstats/views.py index af83c01..0399274 100644 --- a/accountstats/views.py +++ b/accountstats/views.py @@ -6,6 +6,7 @@ from django.utils.translation import gettext as _ from userportal.common import account_or_staff, Prometheus, parse_start_end from userportal.common import compute_allocations_by_user, compute_allocations_by_slurm_account +from userportal.common import anonymize as a from notes.models import Note @@ -78,7 +79,7 @@ def graph(request, query, stacked=True, unit=None): 'x': x, 'y': y, 'type': 'scatter', - 'name': user, + 'name': a(user), 'hovertemplate': '%{y:.1f}', } if stacked: @@ -157,7 +158,7 @@ def graph_lustre_ost(request, account): for line in stats: fs = line['metric']['fs'] - user = line['metric']['user'] + user = a(line['metric']['user']) x = list(map(lambda x: x.strftime('%Y-%m-%d %H:%M:%S'), line['x'])) if i == 'read': y = line['y'] diff --git a/cloudstats/templates/cloudstats/index.html b/cloudstats/templates/cloudstats/index.html index b179ff4..fd36b4e 100644 --- a/cloudstats/templates/cloudstats/index.html +++ b/cloudstats/templates/cloudstats/index.html @@ -36,7 +36,7 @@

{% translate "Memory used" %}

{% for project in all_projects %} - {{project.name}} + {{project.name | anonymize }} {{project.cores}} {% endfor %} diff --git a/cloudstats/templates/cloudstats/instance.html b/cloudstats/templates/cloudstats/instance.html index 68dde45..3c597fe 100644 --- a/cloudstats/templates/cloudstats/instance.html +++ b/cloudstats/templates/cloudstats/instance.html @@ -2,10 +2,10 @@ {% load humanize %} {% load i18n %} -{% block title %}{% translate "Your instance use" %}{% endblock title %} +{% block title %}{% translate "Your instance " %}{{instance_name | anonymize }}{% endblock title %} {% block content %} -

{% translate "Your instance use" %}

+

{% translate "Your instance " %}{{instance_name | anonymize }}

{% include "nav_last_month.html" %} diff --git a/cloudstats/templates/cloudstats/project.html b/cloudstats/templates/cloudstats/project.html index a3267e3..d4ec3cc 100644 --- a/cloudstats/templates/cloudstats/project.html +++ b/cloudstats/templates/cloudstats/project.html @@ -19,7 +19,7 @@

{% translate "Your instances" %}

{% for instance in instances %} - {{ instance.instance_name }} + {{ instance.instance_name | anonymize }} {{ instance.instance_type }} {{ instance.uuid }} diff --git a/cloudstats/views.py b/cloudstats/views.py index 3a6f75b..dfeb86b 100644 --- a/cloudstats/views.py +++ b/cloudstats/views.py @@ -1,6 +1,7 @@ from django.shortcuts import render from django.http import JsonResponse from userportal.common import openstackproject_or_staff, cloud_projects_by_user, request_to_username, staff, Prometheus, query_time +from userportal.common import anonymize as a from django.conf import settings from datetime import datetime, timedelta from django.contrib.auth.decorators import login_required @@ -21,7 +22,11 @@ def index(request): filter=prom.get_filter(), ) for project in prom.query_last(query_projects): - context['all_projects'].append({'name': project['metric']['project_name'], 'cores': int(project['value'][1])}) + context['all_projects'].append({ + 'id': project['metric']['project_name'], + 'name': project['metric']['project_name'], + 'cores': + int(project['value'][1])}) return render(request, 'cloudstats/index.html', context) @@ -46,6 +51,12 @@ def project(request, project): @openstackproject_or_staff def instance(request, project, uuid): context = {} + query_instances = 'libvirtd_domain_domain_state{{project_name="{project}", uuid="{uuid}", {filter}}}'.format( + project=project, + uuid=uuid, + filter=prom.get_filter()) + stats_instances = prom.query_prometheus_multiple(query_instances, datetime.now() - timedelta(days=7), datetime.now()) + context['instance_name'] = stats_instances[0]['metric']['instance_name'] return render(request, 'cloudstats/instance.html', context) @@ -70,9 +81,9 @@ def project_graph_cpu(request, project): x = list(map(lambda x: x.strftime('%Y-%m-%d %H:%M:%S'), line['x'])) y = line['y'] if instance_counter[line['metric']['instance_name']] > 1: - name = '{0} {1}'.format(line['metric']['instance_name'], line['metric']['uuid']) + name = '{0} {1}'.format(a(line['metric']['instance_name']), line['metric']['uuid']) else: - name = line['metric']['instance_name'] + name = a(line['metric']['instance_name']) data.append({ 'x': x, 'y': y, @@ -121,7 +132,7 @@ def projects_graph_cpu(request): 'y': line['y'], 'type': 'scatter', 'stackgroup': 'one', - 'name': line['metric']['project_name'], + 'name': a(line['metric']['project_name']), 'hovertemplate': '%{y:.1f}', }) @@ -214,9 +225,9 @@ def project_graph_memory(request, project): x = list(map(lambda x: x.strftime('%Y-%m-%d %H:%M:%S'), line['x'])) y = line['y'] if instance_counter[line['metric']['instance_name']] > 1: - name = '{0} {1}'.format(line['metric']['instance_name'], line['metric']['uuid']) + name = '{0} {1}'.format(a(line['metric']['instance_name']), line['metric']['uuid']) else: - name = line['metric']['instance_name'] + name = a(line['metric']['instance_name']) data.append({ 'x': x, 'y': y, @@ -313,7 +324,7 @@ def projects_graph_mem(request): 'y': line['y'], 'type': 'scatter', 'stackgroup': 'one', - 'name': line['metric']['project_name'], + 'name': a(line['metric']['project_name']), 'hovertemplate': '%{y:.1f}', }) @@ -365,9 +376,9 @@ def project_graph_disk_bandwidth(request, project): else: y = [-x for x in line['y']] if instance_counter[line['metric']['instance_name']] > 1: - name = '{0} {1}'.format(line['metric']['instance_name'], line['metric']['uuid']) + name = '{0} {1}'.format(a(line['metric']['instance_name']), line['metric']['uuid']) else: - name = line['metric']['instance_name'] + name = a(line['metric']['instance_name']) data.append({ 'x': x, 'y': y, @@ -451,9 +462,9 @@ def project_graph_disk_iops(request, project): else: y = [-x for x in line['y']] if instance_counter[line['metric']['instance_name']] > 1: - name = '{0} {1}'.format(line['metric']['instance_name'], line['metric']['uuid']) + name = '{0} {1}'.format(a(line['metric']['instance_name']), line['metric']['uuid']) else: - name = line['metric']['instance_name'] + name = a(line['metric']['instance_name']) data.append({ 'x': x, 'y': y, @@ -534,9 +545,9 @@ def project_graph_network_bandwidth(request, project): else: y = [-x for x in line['y']] if instance_counter[line['metric']['instance_name']] > 1: - name = '{0} {1}'.format(line['metric']['instance_name'], line['metric']['uuid']) + name = '{0} {1}'.format(a(line['metric']['instance_name']), line['metric']['uuid']) else: - name = line['metric']['instance_name'] + name = a(line['metric']['instance_name']) data.append({ 'x': x, 'y': y, diff --git a/jobstats/templates/jobstats/job.html b/jobstats/templates/jobstats/job.html index 41cb421..b82c639 100644 --- a/jobstats/templates/jobstats/job.html +++ b/jobstats/templates/jobstats/job.html @@ -39,8 +39,7 @@

{% translate "Jobs" %}

{% else %} - -

{% translate "Details on job" %} {{job.job_name}} ({{job_id}})

+

{% translate "Details on job" %} {{job.job_name | anonymize}} ({{job_id}})

{{job.status}}

{% if job.time_start != 0 and job.time_end == 0 %} @@ -125,9 +124,10 @@

{% translate "Scheduler info" %}

{% if 'accountstats' in settings.INSTALLED_APPS %} - {{job.account}} + {{job.account | anonymize}} + {% else %} - {{job.account}} + {{job.account | anonymize}} {% endif %} {{job.time_submit_dt | naturaltime}} diff --git a/jobstats/templates/jobstats/user.html b/jobstats/templates/jobstats/user.html index 34e036c..b44f3d6 100644 --- a/jobstats/templates/jobstats/user.html +++ b/jobstats/templates/jobstats/user.html @@ -199,7 +199,14 @@

{% translate "Your jobs" %}

return '' + data + ''; } }, - { data: 'job_name' }, + { data: 'job_name', + render: function(date, type, row, meta){ + if(document.getElementById("demo")){ + return '[redacted]'; + } else { + return row.job_name; + } + } }, { data: 'time_submit', render: parse_time, }, diff --git a/jobstats/views.py b/jobstats/views.py index fac89ae..0b20e7c 100644 --- a/jobstats/views.py +++ b/jobstats/views.py @@ -429,6 +429,10 @@ def job(request, username, job_id): for exe in stats_exe: name = exe['metric']['exe'] value = statistics.mean(exe['y']) + if settings.DEMO: + if not name.startswith('/cvmfs'): + # skip non-cvmfs applications in demo mode + name = '[redacted]' context['applications'].append({'name': name, 'value': value}) except ValueError: pass diff --git a/templates/base.html b/templates/base.html index 61f1a3c..541e668 100644 --- a/templates/base.html +++ b/templates/base.html @@ -39,6 +39,9 @@ + {% if settings.DEMO %} +
+ {% endif %}