1 from django.utils import timezone
2 from django.views.generic import TemplateView
4 from booking.models import Booking
5 from dashboard.models import Resource
6 from jenkins import adapter as jenkins
9 class JenkinsSlavesView(TemplateView):
10 template_name = "dashboard/jenkins_slaves.html"
12 def get_context_data(self, **kwargs):
13 slaves = jenkins.get_all_slaves()
15 jenkins.parse_slave_data(slave, slave)
17 context = super(JenkinsSlavesView, self).get_context_data(**kwargs)
18 context.update({'title': "Jenkins Slaves", 'slaves': slaves})
22 class CIPodsView(TemplateView):
23 template_name = "dashboard/ci_pods.html"
25 def get_context_data(self, **kwargs):
26 resources = Resource.objects.filter().values() # get resources as a set of dicts
28 for resource in resources:
29 if not jenkins.is_ci_slave(resource['slavename']):
31 ci_slave = jenkins.get_slave(resource['slavename'])
32 jenkins.parse_slave_data(resource, ci_slave)
33 ci_pods.append(resource)
35 context = super(CIPodsView, self).get_context_data(**kwargs)
36 context.update({'title': "CI Pods", 'ci_pods': ci_pods})
40 class DevelopmentPodsView(TemplateView):
41 template_name = "dashboard/dev_pods.html"
43 def get_context_data(self, **kwargs):
44 resources = Resource.objects.filter().values() # get resources as a set of dicts
47 current_bookings = Booking.objects.filter(start__lte=timezone.now())
48 current_bookings = current_bookings.filter(end__gt=timezone.now())
50 for resource in resources:
51 if not jenkins.is_dev_pod(resource['slavename']):
53 dev_pod = jenkins.get_slave(resource['slavename'])
54 jenkins.parse_slave_data(resource, dev_pod)
55 for booking in current_bookings:
56 if booking.resource.slavename == resource['slavename']:
57 resource['current_booking'] = booking
58 dev_pods.append(resource)
60 context = super(DevelopmentPodsView, self).get_context_data(**kwargs)
61 context.update({'title': "Development Pods", 'dev_pods': dev_pods})