aboutsummaryrefslogtreecommitdiffstats
path: root/src/workflow
diff options
context:
space:
mode:
Diffstat (limited to 'src/workflow')
-rw-r--r--src/workflow/forms.py16
-rw-r--r--src/workflow/models.py14
-rw-r--r--src/workflow/resource_bundle_workflow.py35
-rw-r--r--src/workflow/workflow_manager.py2
4 files changed, 44 insertions, 23 deletions
diff --git a/src/workflow/forms.py b/src/workflow/forms.py
index 9b56f93..62abad6 100644
--- a/src/workflow/forms.py
+++ b/src/workflow/forms.py
@@ -222,7 +222,7 @@ class ResourceSelectorForm(SearchableSelectAbstractForm):
class BookingMetaForm(forms.Form):
-
+ # Django Form class for Book a Pod
length = forms.IntegerField(
widget=NumberInput(
attrs={
@@ -380,7 +380,7 @@ class PodDefinitionForm(forms.Form):
class ResourceMetaForm(forms.Form):
bundle_name = forms.CharField(label="POD Name")
- bundle_description = forms.CharField(label="POD Description", widget=forms.Textarea)
+ bundle_description = forms.CharField(label="POD Description", widget=forms.Textarea, max_length=1000)
class GenericHostMetaForm(forms.Form):
@@ -400,8 +400,12 @@ class NetworkConfigurationForm(forms.Form):
class HostSoftwareDefinitionForm(forms.Form):
-
- host_name = forms.CharField(max_length=200, disabled=False, required=True)
+ # Django Form class for Design a Pod
+ host_name = forms.CharField(
+ max_length=200,
+ disabled=False,
+ required=True
+ )
headnode = forms.BooleanField(required=False, widget=forms.HiddenInput)
def __init__(self, *args, **kwargs):
@@ -441,8 +445,8 @@ class ConfirmationForm(forms.Form):
confirm = forms.ChoiceField(
choices=(
- (True, "Confirm"),
- (False, "Cancel")
+ (False, "Cancel"),
+ (True, "Confirm")
)
)
diff --git a/src/workflow/models.py b/src/workflow/models.py
index 91a216c..e065202 100644
--- a/src/workflow/models.py
+++ b/src/workflow/models.py
@@ -326,11 +326,15 @@ class Confirmation_Step(WorkflowStep):
def get_context(self):
context = super(Confirmation_Step, self).get_context()
context['form'] = ConfirmationForm()
- context['confirmation_info'] = yaml.dump(
- self.repo_get(self.repo.CONFIRMATION),
- default_flow_style=False
- ).strip()
-
+ # Summary of submitted form data shown on the 'confirm' step of the workflow
+ confirm_details = "\nPod:\n Name: '{name}'\n Description: '{desc}'\nLab: '{lab}'".format(
+ name=self.repo_get(self.repo.CONFIRMATION)['resource']['name'],
+ desc=self.repo_get(self.repo.CONFIRMATION)['resource']['description'],
+ lab=self.repo_get(self.repo.CONFIRMATION)['template']['lab'])
+ confirm_details += "\nResources:"
+ for i, device in enumerate(self.repo_get(self.repo.RESOURCE_TEMPLATE_MODELS)['resources']):
+ confirm_details += "\n " + str(device) + ": " + str(self.repo_get(self.repo.CONFIRMATION)['template']['resources'][i]['profile'])
+ context['confirmation_info'] = confirm_details
if self.valid == WorkflowStepStatus.VALID:
context["confirm_succeeded"] = "true"
diff --git a/src/workflow/resource_bundle_workflow.py b/src/workflow/resource_bundle_workflow.py
index a461e9a..4e288b5 100644
--- a/src/workflow/resource_bundle_workflow.py
+++ b/src/workflow/resource_bundle_workflow.py
@@ -14,6 +14,7 @@ from django.core.exceptions import ValidationError
from typing import List
+import re
import json
from xml.dom import minidom
import traceback
@@ -172,7 +173,8 @@ class Define_Hardware(WorkflowStep):
except Exception as e:
print("Caught exception: " + str(e))
traceback.print_exc()
- self.set_invalid(str(e))
+ self.form = None
+ self.set_invalid("Please select a lab.")
class Define_Software(WorkflowStep):
@@ -208,12 +210,15 @@ class Define_Software(WorkflowStep):
hosts_initial = []
configs = self.repo_get(self.repo.RESOURCE_TEMPLATE_MODELS, {}).get("resources")
if configs:
- for config in configs:
+ for i in range(len(configs)):
+ default_name = 'laas-node'
+ if i > 0:
+ default_name = default_name + "-" + str(i + 1)
hosts_initial.append({
- 'host_id': config.id,
- 'host_name': config.name,
- 'headnode': config.is_head_node,
- 'image': config.image
+ 'host_id': configs[i].id,
+ 'host_name': default_name,
+ 'headnode': False,
+ 'image': configs[i].image
})
else:
for host in hostlist:
@@ -248,9 +253,6 @@ class Define_Software(WorkflowStep):
def post(self, post_data, user):
hosts = self.get_host_list()
-
- # TODO: fix headnode in form, currently doesn't return a selected one
- # models['headnode_index'] = post_data.get("headnode", 1)
formset = self.create_hostformset(hosts, data=post_data)
has_headnode = False
if formset.is_valid():
@@ -264,6 +266,17 @@ class Define_Software(WorkflowStep):
host.is_head_node = headnode
host.name = hostname
host.image = image
+ # RFC921: They must start with a letter, end with a letter or digit and have only letters or digits or hyphen as interior characters
+ if bool(re.match("^[A-Za-z0-9-]*$", hostname)) is False:
+ self.set_invalid("Device names must only contain alphanumeric characters and dashes.")
+ return
+ if not hostname[0].isalpha() or not hostname[-1].isalnum():
+ self.set_invalid("Device names must start with a letter and end with a letter or digit.")
+ return
+ for j in range(i):
+ if j != i and hostname == hosts[j].name:
+ self.set_invalid("Devices must have unique names. Please try again.")
+ return
host.save()
if not has_headnode and len(hosts) > 0:
@@ -272,7 +285,7 @@ class Define_Software(WorkflowStep):
self.set_valid("Completed")
else:
- self.set_invalid("Please complete all fields")
+ self.set_invalid("Please complete all fields.")
class Define_Nets(WorkflowStep):
@@ -598,4 +611,4 @@ class Resource_Meta_Info(WorkflowStep):
self.repo_put(self.repo.CONFIRMATION, confirm)
self.set_valid("Step Completed")
else:
- self.set_invalid("Please correct the fields highlighted in red to continue")
+ self.set_invalid("Please complete all fields.")
diff --git a/src/workflow/workflow_manager.py b/src/workflow/workflow_manager.py
index a48efe5..40be9d6 100644
--- a/src/workflow/workflow_manager.py
+++ b/src/workflow/workflow_manager.py
@@ -48,7 +48,7 @@ class SessionManager():
def add_workflow(self, workflow_type=None, **kwargs):
repo = Repository()
- if(len(self.workflows) >= 1):
+ if (len(self.workflows) >= 1):
defaults = self.workflows[-1].repository.get_child_defaults()
repo.set_defaults(defaults)
repo.el[repo.HAS_RESULT] = False