Pharos Dashboard: Add manual resource management 39/34339/2
authormaxbr <maxbr@mi.fu-berlin.de>
Fri, 5 May 2017 08:02:56 +0000 (10:02 +0200)
committermaxbr <maxbr@mi.fu-berlin.de>
Fri, 5 May 2017 08:28:14 +0000 (10:28 +0200)
Dev Pods are now managed by checking the "Dev pod" box in the Admin
Panel. This commit also fixes a dead image URL and the oauth process for the
dashboard URL.

Change-Id: Ic94160eb3a4504a369606261440df0e5354ac027
Signed-off-by: maxbr <maxbr@mi.fu-berlin.de>
tools/pharos-dashboard/config.env.sample
tools/pharos-dashboard/docker-compose.yml
tools/pharos-dashboard/rabbitmq/init.sh
tools/pharos-dashboard/src/dashboard/admin.py
tools/pharos-dashboard/src/dashboard/migrations/0002_auto_20170505_0815.py [new file with mode: 0644]
tools/pharos-dashboard/src/dashboard/models.py
tools/pharos-dashboard/src/dashboard/views.py
tools/pharos-dashboard/src/notification/tasks.py
tools/pharos-dashboard/src/pharos_dashboard/settings.py
tools/pharos-dashboard/src/templates/base.html

index 892faac..060841c 100644 (file)
@@ -1,3 +1,5 @@
+DASHBOARD_URL=http://labs.opnfv.org
+
 # SECURITY WARNING: don't run with debug turned on in production!
 DEBUG=False
 
index d2d672a..2f02011 100644 (file)
@@ -27,7 +27,7 @@ services:
         restart: always
         build: ./web/
         container_name: dg01
-        command: bash -c "python manage.py makemigrations && python manage.py migrate && python manage.py collectstatic --no-input && gunicorn pharos_dashboard.wsgi -b 0.0.0.0:8000"
+        command: bash -c "python manage.py migrate && python manage.py collectstatic --no-input && gunicorn pharos_dashboard.wsgi -b 0.0.0.0:8000"
         depends_on:
             - postgres
         links:
@@ -67,4 +67,3 @@ services:
             - rabbitmq
         volumes:
             - ./:/pharos_dashboard
-     
index f8ac089..9d04dd1 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 # Create Rabbitmq user
-( sleep 20 ; \
+( sleep 10 ; \
 rabbitmqctl add_user $RABBITMQ_USER $RABBITMQ_PASSWORD 2>/dev/null ; \
 rabbitmqctl set_user_tags $RABBITMQ_USER administrator ; \
 rabbitmqctl set_permissions -p / $RABBITMQ_USER  ".*" ".*" ".*" ; \
index 56ac169..0bfdef8 100644 (file)
@@ -12,6 +12,9 @@ from django.contrib import admin
 
 from dashboard.models import *
 
+admin.site.site_header = "Pharos Dashboard Administration"
+admin.site.site_title = "Pharos Dashboard"
+
 admin.site.register(Resource)
 admin.site.register(Server)
 admin.site.register(ResourceStatus)
diff --git a/tools/pharos-dashboard/src/dashboard/migrations/0002_auto_20170505_0815.py b/tools/pharos-dashboard/src/dashboard/migrations/0002_auto_20170505_0815.py
new file mode 100644 (file)
index 0000000..4285b88
--- /dev/null
@@ -0,0 +1,42 @@
+##############################################################################
+# Copyright (c) 2016 Max Breitenfeldt and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10 on 2017-05-05 08:15
+from __future__ import unicode_literals
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('dashboard', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='resource',
+            name='dev_pod',
+            field=models.BooleanField(default=False),
+        ),
+        migrations.AlterField(
+            model_name='resource',
+            name='owner',
+            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='user_lab_owner', to=settings.AUTH_USER_MODEL),
+        ),
+        migrations.AlterField(
+            model_name='resource',
+            name='slave',
+            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='jenkins.JenkinsSlave'),
+        ),
+    ]
index 4f3ac95..3de7db3 100644 (file)
@@ -22,9 +22,10 @@ class Resource(models.Model):
     name = models.CharField(max_length=100, unique=True)
     description = models.CharField(max_length=300, blank=True, null=True)
     url = models.CharField(max_length=100, blank=True, null=True)
-    owner = models.ForeignKey(User, related_name='user_lab_owner', null=True)
+    owner = models.ForeignKey(User, related_name='user_lab_owner', null=True, blank=True)
     vpn_users = models.ManyToManyField(User, related_name='user_vpn_users', blank=True)
-    slave = models.ForeignKey(JenkinsSlave, on_delete=models.DO_NOTHING, null=True)
+    slave = models.ForeignKey(JenkinsSlave, on_delete=models.DO_NOTHING, null=True, blank=True)
+    dev_pod = models.BooleanField(default=False)
 
     def get_booking_utilization(self, weeks):
         """
index 1848844..62a9f83 100644 (file)
@@ -45,7 +45,7 @@ class DevelopmentPodsView(TemplateView):
     template_name = "dashboard/dev_pods.html"
 
     def get_context_data(self, **kwargs):
-        resources = Resource.objects.filter(slave__dev_pod=True, slave__active=True)
+        resources = Resource.objects.filter(dev_pod=True)
 
         bookings = Booking.objects.filter(start__lte=timezone.now())
         bookings = bookings.filter(end__gt=timezone.now())
@@ -76,11 +76,9 @@ class ResourceView(TemplateView):
 
     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})
+        context.update({'title': str(resource), 'resource': resource, 'bookings': bookings})
         return context
 
 
index e2b34ca..7f73762 100644 (file)
@@ -27,7 +27,7 @@ from dashboard_notification.notification import Notification, Message
 
 @shared_task
 def send_booking_notifications():
-    with Notification(dashboard_url=settings.RABBITMQ_URL) as messaging:
+    with Notification(dashboard_url=settings.RABBITMQ_URL, user=settings.RABBITMQ_USER, password=settings.RABBITMQ_PASSWORD) as messaging:
         now = timezone.now()
         notifications = BookingNotification.objects.filter(submitted=False,
                                                            submit_time__gt=now - timedelta(minutes=1),
index 084f878..546b174 100644 (file)
@@ -5,7 +5,7 @@ from datetime import timedelta
 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
 
 # SECURITY WARNING: don't run with debug turned on in production!
-DEBUG = False
+DEBUG = True
 
 # Application definition
 
@@ -157,13 +157,16 @@ OAUTH_REQUEST_TOKEN_URL = JIRA_URL + '/plugins/servlet/oauth/request-token'
 OAUTH_ACCESS_TOKEN_URL = JIRA_URL + '/plugins/servlet/oauth/access-token'
 OAUTH_AUTHORIZE_URL = JIRA_URL + '/plugins/servlet/oauth/authorize'
 
-OAUTH_CALLBACK_URL = JIRA_URL + '/accounts/authenticated'
+OAUTH_CALLBACK_URL = os.environ['DASHBOARD_URL'] + '/accounts/authenticated'
 
 # Celery Settings
 CELERY_TIMEZONE = 'UTC'
 
 RABBITMQ_URL = 'rabbitmq'
-BROKER_URL = 'amqp://guest:guest@rabbitmq:5672//'
+RABBITMQ_USER = os.environ['RABBITMQ_USER']
+RABBITMQ_PASSWORD = os.environ['RABBITMQ_PASSWORD']
+
+BROKER_URL = 'amqp://' + RABBITMQ_USER + ':' + RABBITMQ_PASSWORD + '@rabbitmq:5672//'
 
 CELERYBEAT_SCHEDULE = {
     'sync-jenkins': {
index 2ce22a3..4d8530a 100644 (file)
@@ -15,7 +15,7 @@
                     <span class="icon-bar"></span>
                 </button>
                 <a href="https://www.opnfv.org/" class="navbar-left"><img
-                        src="https://www.opnfv.org/sites/all/themes/opnfv/logo.png"></a>
+                        src="http://artifacts.opnfv.org/apex/review/14099/installation-instructions/_static/opnfv-logo.png"></a>
                 <a class="navbar-brand" href={% url 'dashboard:index' %}>Pharos Dashboard</a>
             </div>
             <!-- /.navbar-header -->
         <!-- /#page-wrapper -->
     </div>
     <!-- /#wrapper -->
-{% endblock basecontent %}
\ No newline at end of file
+{% endblock basecontent %}