aboutsummaryrefslogtreecommitdiffstats
path: root/src/dashboard
diff options
context:
space:
mode:
authorJustin Choquette <jchoquette@iol.unh.edu>2023-08-08 11:33:57 -0400
committerJustin Choquette <jchoquette@iol.unh.edu>2023-08-18 11:59:01 -0400
commitecadb07367d31c0929212618e120130f54af78da (patch)
treef626ef347f6fa7cb7f9ee962539a5f769bc3d471 /src/dashboard
parenta6168306c08e8d5b207b9acc48869180d194ff01 (diff)
MVP
Change-Id: Ib590302f49e7e66f8d04841fb6cb97baf623f51a Signed-off-by: Justin Choquette <jchoquette@iol.unh.edu>
Diffstat (limited to 'src/dashboard')
-rw-r--r--src/dashboard/tasks.py3
-rw-r--r--src/dashboard/views.py28
2 files changed, 16 insertions, 15 deletions
diff --git a/src/dashboard/tasks.py b/src/dashboard/tasks.py
index ac4b006..281db92 100644
--- a/src/dashboard/tasks.py
+++ b/src/dashboard/tasks.py
@@ -17,9 +17,7 @@ from api.views import liblaas_end_booking
# todo - make a task to check for expired bookings
@shared_task
def end_expired_bookings():
- print("Celery task for end_expired_bookings() has been triggered")
cleanup_set = Booking.objects.filter(end__lte=timezone.now(), ).filter(complete=False)
- print("Newly expired bookings: ", cleanup_set)
for booking in cleanup_set:
booking.complete = True
if (booking.aggregateId):
@@ -28,4 +26,3 @@ def end_expired_bookings():
else:
print("booking " + str(booking.id) + " has no agg id")
booking.save()
- print("Finished end_expired_bookings()")
diff --git a/src/dashboard/views.py b/src/dashboard/views.py
index f250a3c..909b695 100644
--- a/src/dashboard/views.py
+++ b/src/dashboard/views.py
@@ -8,7 +8,7 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-
+import json
from django.shortcuts import get_object_or_404
from django.views.generic import TemplateView
from django.shortcuts import render
@@ -21,7 +21,7 @@ from api.utils import get_ipa_migration_form, ipa_query_user
from api.views import ipa_conflict_account
from booking.models import Booking
from dashboard.forms import *
-
+from api.views import list_flavors, list_hosts
from laas_dashboard import settings
@@ -40,14 +40,18 @@ def lab_detail_view(request, lab_name):
user = request.user
lab = get_object_or_404(Lab, name=lab_name)
-
- # images = Image.objects.filter(from_lab=lab).filter(public=True)
- images = []
- # if user:
- # images = images | Image.objects.filter(from_lab=lab).filter(owner=user)
-
- # hosts = ResourceQuery.filter(lab=lab)
- hosts = []
+ flavors_list = json.loads(list_flavors(request).content)
+ host_list = json.loads(list_hosts(request).content)
+ flavor_map = {}
+ for flavor in flavors_list:
+ flavor_map[flavor['flavor_id']] = flavor['name']
+
+
+ # Apparently Django Templating lacks many features that regular Jinja offers, so I need to get creative
+ for host in host_list:
+ id = host["flavor"]
+ name = flavor_map[id]
+ host["flavor"] = {"id": id, "name": name}
return render(
request,
@@ -56,8 +60,8 @@ def lab_detail_view(request, lab_name):
'title': "Lab Overview",
'lab': lab,
# 'hostprofiles': ResourceProfile.objects.filter(labs=lab),
- 'images': images,
- 'hosts': hosts
+ 'flavors': flavors_list,
+ 'hosts': host_list
}
)