summaryrefslogtreecommitdiffstats
path: root/dashboard/src/workflow
diff options
context:
space:
mode:
authorParker Berberian <pberberian@iol.unh.edu>2019-01-17 12:51:04 -0500
committerParker Berberian <pberberian@iol.unh.edu>2019-01-18 16:08:27 -0500
commit8483acb4c4e8c758855f2184483af834977b0c52 (patch)
tree403618bb77d4f19c2a7b908bb8a0872f144d530b /dashboard/src/workflow
parentbe3825307c7a44f1491e85e33fd0a0ecf1e95a1d (diff)
OverHaul the Snapshot Workflow
Makes the Snapshot workflow much prettier and more functional. Change-Id: Icdd66f64e6d336ad49ed3cf638a301d0ca92fda9 Signed-off-by: Parker Berberian <pberberian@iol.unh.edu>
Diffstat (limited to 'dashboard/src/workflow')
-rw-r--r--dashboard/src/workflow/forms.py2
-rw-r--r--dashboard/src/workflow/models.py10
-rw-r--r--dashboard/src/workflow/snapshot_workflow.py9
3 files changed, 19 insertions, 2 deletions
diff --git a/dashboard/src/workflow/forms.py b/dashboard/src/workflow/forms.py
index b8c7f66..726e7dd 100644
--- a/dashboard/src/workflow/forms.py
+++ b/dashboard/src/workflow/forms.py
@@ -461,7 +461,7 @@ class SnapshotHostSelectForm(forms.Form):
class SnapshotMetaForm(forms.Form):
name = forms.CharField()
- description = forms.CharField()
+ description = forms.CharField(widget=forms.Textarea)
class ConfirmationForm(forms.Form):
diff --git a/dashboard/src/workflow/models.py b/dashboard/src/workflow/models.py
index 495ce07..4e79546 100644
--- a/dashboard/src/workflow/models.py
+++ b/dashboard/src/workflow/models.py
@@ -11,6 +11,7 @@
from django.shortcuts import render
from django.contrib import messages
from django.http import HttpResponse
+from django.utils import timezone
import yaml
import requests
@@ -385,6 +386,8 @@ class Repository():
if not booking_id:
return "SNAP, No booking ID provided"
booking = Booking.objects.get(pk=booking_id)
+ if booking.start > timezone.now() or booking.end < timezone.now():
+ return "Booking is not active"
name = self.el.get(self.SNAPSHOT_NAME)
if not name:
return "SNAP, no name provided"
@@ -400,6 +403,13 @@ class Repository():
image.owner = owner
image.host_type = host.profile
image.save()
+ try:
+ current_image = host.config.image
+ image.os = current_image.os
+ image.save()
+ except Exception:
+ pass
+ JobFactory.makeSnapshotTask(image, booking, host)
def make_generic_resource_bundle(self):
owner = self.el[self.SESSION_USER]
diff --git a/dashboard/src/workflow/snapshot_workflow.py b/dashboard/src/workflow/snapshot_workflow.py
index 4ddc397..0d53ed4 100644
--- a/dashboard/src/workflow/snapshot_workflow.py
+++ b/dashboard/src/workflow/snapshot_workflow.py
@@ -87,7 +87,14 @@ class Image_Meta_Step(WorkflowStep):
def get_context(self):
context = super(Image_Meta_Step, self).get_context()
- context['form'] = SnapshotMetaForm()
+ name = self.repo_get(self.repo.SNAPSHOT_NAME, False)
+ desc = self.repo_get(self.repo.SNAPSHOT_DESC, False)
+ form = None
+ if name and desc:
+ form = SnapshotMetaForm(initial={"name": name, "description": desc})
+ else:
+ form = SnapshotMetaForm()
+ context['form'] = form
return context
def post_render(self, request):