summaryrefslogtreecommitdiffstats
path: root/tools/pharos-dashboard/dashboard
diff options
context:
space:
mode:
Diffstat (limited to 'tools/pharos-dashboard/dashboard')
-rw-r--r--tools/pharos-dashboard/dashboard/admin.py3
-rw-r--r--tools/pharos-dashboard/dashboard/models.py19
-rw-r--r--tools/pharos-dashboard/dashboard/templatetags/jenkins_filters.py7
-rw-r--r--tools/pharos-dashboard/dashboard/templatetags/jira_filters.py8
-rw-r--r--tools/pharos-dashboard/dashboard/urls.py4
-rw-r--r--tools/pharos-dashboard/dashboard/views.py30
6 files changed, 49 insertions, 22 deletions
diff --git a/tools/pharos-dashboard/dashboard/admin.py b/tools/pharos-dashboard/dashboard/admin.py
index 990e63e8..71a1e7d2 100644
--- a/tools/pharos-dashboard/dashboard/admin.py
+++ b/tools/pharos-dashboard/dashboard/admin.py
@@ -1,5 +1,6 @@
from django.contrib import admin
-from dashboard.models import Resource
+from dashboard.models import *
admin.site.register(Resource)
+admin.site.register(Server)
diff --git a/tools/pharos-dashboard/dashboard/models.py b/tools/pharos-dashboard/dashboard/models.py
index 971af6a2..d645cd55 100644
--- a/tools/pharos-dashboard/dashboard/models.py
+++ b/tools/pharos-dashboard/dashboard/models.py
@@ -1,6 +1,5 @@
from django.contrib.auth.models import User
from django.db import models
-from django.utils import timezone
from jenkins.models import JenkinsSlave
@@ -17,4 +16,20 @@ class Resource(models.Model):
db_table = 'resource'
def __str__(self):
- return self.name \ No newline at end of file
+ return self.name
+
+
+class Server(models.Model):
+ id = models.AutoField(primary_key=True)
+ resource = models.ForeignKey(Resource, on_delete=models.CASCADE)
+ name = models.CharField(max_length=100, blank=True)
+ model = models.CharField(max_length=100, blank=True)
+ cpu = models.CharField(max_length=100, blank=True)
+ ram = models.CharField(max_length=100, blank=True)
+ storage = models.CharField(max_length=100, blank=True)
+
+ class Meta:
+ db_table = 'server'
+
+ def __str__(self):
+ return self.name
diff --git a/tools/pharos-dashboard/dashboard/templatetags/jenkins_filters.py b/tools/pharos-dashboard/dashboard/templatetags/jenkins_filters.py
index f7e00a87..f5038ea5 100644
--- a/tools/pharos-dashboard/dashboard/templatetags/jenkins_filters.py
+++ b/tools/pharos-dashboard/dashboard/templatetags/jenkins_filters.py
@@ -9,7 +9,7 @@ def jenkins_job_color(job_result):
return '#d9534f'
if job_result == 'UNSTABLE':
return '#EDD62B'
- return '#646F73' # job is still building
+ return '#646F73' # job is still building
@register.filter
@@ -21,7 +21,8 @@ def jenkins_status_color(slave_status):
if slave_status == 'online / idle':
return '#5bc0de'
+
@register.filter
def jenkins_job_blink(job_result):
- if job_result == '': # job is still building
- return 'class=blink_me' \ No newline at end of file
+ if job_result == '': # job is still building
+ return 'class=blink_me'
diff --git a/tools/pharos-dashboard/dashboard/templatetags/jira_filters.py b/tools/pharos-dashboard/dashboard/templatetags/jira_filters.py
new file mode 100644
index 00000000..d9c27612
--- /dev/null
+++ b/tools/pharos-dashboard/dashboard/templatetags/jira_filters.py
@@ -0,0 +1,8 @@
+from django.template.defaultfilters import register
+
+from pharos_dashboard import settings
+
+
+@register.filter
+def jira_issue_url(issue):
+ return settings.JIRA_URL + '/browse/' + str(issue)
diff --git a/tools/pharos-dashboard/dashboard/urls.py b/tools/pharos-dashboard/dashboard/urls.py
index 51d764c4..809204c1 100644
--- a/tools/pharos-dashboard/dashboard/urls.py
+++ b/tools/pharos-dashboard/dashboard/urls.py
@@ -21,8 +21,8 @@ urlpatterns = [
url(r'^ci_pods/$', CIPodsView.as_view(), name='ci_pods'),
url(r'^dev_pods/$', DevelopmentPodsView.as_view(), name='dev_pods'),
url(r'^jenkins_slaves/$', JenkinsSlavesView.as_view(), name='jenkins_slaves'),
- url(r'^resource/all/', LabOwnerView.as_view(),
- name='resources'),
+ url(r'^resource/all/$', LabOwnerView.as_view(), name='resources'),
+ url(r'^resource/(?P<resource_id>[0-9]+)/$', ResourceView.as_view(), name='resource'),
url(r'^$', DevelopmentPodsView.as_view(), name="index"),
]
diff --git a/tools/pharos-dashboard/dashboard/views.py b/tools/pharos-dashboard/dashboard/views.py
index 56b3a510..ef1845c8 100644
--- a/tools/pharos-dashboard/dashboard/views.py
+++ b/tools/pharos-dashboard/dashboard/views.py
@@ -1,12 +1,12 @@
from datetime import timedelta
-from django.contrib.auth.models import User
+from django.shortcuts import get_object_or_404
from django.utils import timezone
from django.views.generic import TemplateView
from booking.models import Booking
from dashboard.models import Resource
-from jenkins.models import JenkinsSlave, JenkinsStatistic
+from jenkins.models import JenkinsSlave
class JenkinsSlavesView(TemplateView):
@@ -51,25 +51,27 @@ class DevelopmentPodsView(TemplateView):
return context
+class ResourceView(TemplateView):
+ template_name = "dashboard/resource.html"
+
+ def get_context_data(self, **kwargs):
+ resource = get_object_or_404(Resource, id=self.kwargs['resource_id'])
+ utilization = resource.slave.get_utilization(timedelta(days=7))
+ bookings = Booking.objects.filter(resource=resource, end__gt=timezone.now())
+ context = super(ResourceView, self).get_context_data(**kwargs)
+ context.update({'title': str(resource), 'resource': resource, 'utilization': utilization, 'bookings': bookings})
+ return context
+
+
class LabOwnerView(TemplateView):
- template_name = "dashboard/lab_owner.html"
+ template_name = "dashboard/resource_all.html"
def get_context_data(self, **kwargs):
resources = Resource.objects.filter(slave__dev_pod=True)
pods = []
for resource in resources:
- utilization = {'idle': 0, 'online': 0, 'offline': 0}
- # query measurement points for the last week
- statistics = JenkinsStatistic.objects.filter(slave=resource.slave,
- timestamp__gte=timezone.now() - timedelta(
- days=7))
-
- utilization['idle'] = statistics.filter(idle=True).count()
- utilization['online'] = statistics.filter(online=True).count()
- utilization['offline'] = statistics.filter(offline=True).count()
-
+ utilization = resource.slave.get_utilization(timedelta(days=7))
bookings = Booking.objects.filter(resource=resource, end__gt=timezone.now())
-
pods.append((resource, utilization, bookings))
context = super(LabOwnerView, self).get_context_data(**kwargs)
context.update({'title': "Overview", 'pods': pods})