summaryrefslogtreecommitdiffstats
path: root/tools/pharos-dashboard/dashboard/views/table_views.py
diff options
context:
space:
mode:
authormaxbr <maxbr@mi.fu-berlin.de>2016-07-29 12:43:43 +0200
committerMax Breitenfeldt <max.breitenfeldt@gmail.com>2016-07-29 11:25:20 +0000
commit35c34c690ae9616d791c39fa218fe1621fa8d8d2 (patch)
tree6168caaeb4be9144ed6bfde0150850d6559c8b6f /tools/pharos-dashboard/dashboard/views/table_views.py
parent7ae1f204de947a3c12804c04f32e20d45eb99eba (diff)
import pharos dashboard code
JIRA: RELENG-12 The last commit was missing some JS/CSS dependencies of the site. This happened because they are in folders that are named 'build' or 'dist'. This commit adds a bower.json file, that specifies dependencies. Dependencies can now be installed by running 'bower install' in the dashboard/static folder. Change-Id: I054f319c66771f767e97711cb678d79d3bd6bee4 Signed-off-by: maxbr <maxbr@mi.fu-berlin.de>
Diffstat (limited to 'tools/pharos-dashboard/dashboard/views/table_views.py')
-rw-r--r--tools/pharos-dashboard/dashboard/views/table_views.py62
1 files changed, 62 insertions, 0 deletions
diff --git a/tools/pharos-dashboard/dashboard/views/table_views.py b/tools/pharos-dashboard/dashboard/views/table_views.py
new file mode 100644
index 00000000..4404234e
--- /dev/null
+++ b/tools/pharos-dashboard/dashboard/views/table_views.py
@@ -0,0 +1,62 @@
+import dashboard.jenkins.jenkins_util as jenkins_util
+
+import dashboard.jenkins.jenkins_adapter as jenkins
+from dashboard.models import Resource, Booking
+from django.utils import timezone
+from django.views.generic import TemplateView
+
+
+class JenkinsSlavesView(TemplateView):
+ template_name = "tables/jenkins_slaves.html"
+
+ def get_context_data(self, **kwargs):
+ slaves = jenkins.get_all_slaves()
+ for slave in slaves:
+ jenkins_util.parse_slave_data(slave, slave)
+
+ context = super(JenkinsSlavesView, self).get_context_data(**kwargs)
+ context.update({'title': "Jenkins Slaves", 'slaves': slaves})
+ return context
+
+
+class CIPodsView(TemplateView):
+ template_name = "tables/ci_pods.html"
+
+ def get_context_data(self, **kwargs):
+ resources = Resource.objects.filter().values() # get resources as a set of dicts
+ ci_pods = []
+ for resource in resources:
+ if not jenkins.is_ci_slave(resource['slavename']):
+ continue
+ ci_slave = jenkins.get_slave(resource['slavename'])
+ jenkins_util.parse_slave_data(resource, ci_slave)
+ ci_pods.append(resource)
+
+ context = super(CIPodsView, self).get_context_data(**kwargs)
+ context.update({'title': "CI Pods", 'ci_pods': ci_pods})
+ return context
+
+
+class DevelopmentPodsView(TemplateView):
+ template_name = "tables/dev_pods.html"
+
+ def get_context_data(self, **kwargs):
+ resources = Resource.objects.filter().values() # get resources as a set of dicts
+ dev_pods = []
+
+ current_bookings = Booking.objects.filter(start_date_time__lte=timezone.now())
+ current_bookings = current_bookings.filter(end_date_time__gt=timezone.now())
+
+ for resource in resources:
+ if not jenkins.is_dev_pod(resource['slavename']):
+ continue
+ dev_pod = jenkins.get_slave(resource['slavename'])
+ jenkins_util.parse_slave_data(resource, dev_pod)
+ for booking in current_bookings:
+ if booking.resource.slavename == resource['slavename']:
+ resource['current_booking'] = booking
+ dev_pods.append(resource)
+
+ context = super(DevelopmentPodsView, self).get_context_data(**kwargs)
+ context.update({'title': "Development Pods", 'dev_pods': dev_pods})
+ return context