From 4df434cdfb42b7afac3f8a4781c4aa0a3005d092 Mon Sep 17 00:00:00 2001 From: Sawyer Bergeron Date: Fri, 14 Dec 2018 16:05:47 -0500 Subject: Implement Segmented Workflows A major source of bugs has been how we've approached inlining workflows. We no longer inline them as of this commit, and instead use a stack structure. This commits the result of workflows to the database before other workflows try to read them, so we don't have to maintain a code path for when something is or isn't committed to db. This patchset allows for workflows to pass limited information to preset selections Change-Id: I3d040c7f3024c7420017ae4ec66a23219303dcb6 Signed-off-by: Sawyer Bergeron --- dashboard/src/workflow/workflow_factory.py | 39 +++++++++++++++--------------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'dashboard/src/workflow/workflow_factory.py') diff --git a/dashboard/src/workflow/workflow_factory.py b/dashboard/src/workflow/workflow_factory.py index 9a42d86..1f4a28a 100644 --- a/dashboard/src/workflow/workflow_factory.py +++ b/dashboard/src/workflow/workflow_factory.py @@ -12,6 +12,7 @@ from workflow.booking_workflow import Booking_Resource_Select, SWConfig_Select, from workflow.resource_bundle_workflow import Define_Hardware, Define_Nets, Resource_Meta_Info from workflow.sw_bundle_workflow import Config_Software, Define_Software, SWConf_Resource_Select from workflow.snapshot_workflow import Select_Host_Step, Image_Meta_Step +from workflow.models import Repository, Confirmation_Step import uuid @@ -34,23 +35,6 @@ class ConfigMetaWorkflow(object): workflow_type = 2 color = "#00ffcc" - -class MetaRelation(object): - def __init__(self, *args, **kwargs): - self.color = "#cccccc" - self.parent = 0 - self.children = [] - self.depth = -1 - - def to_json(self): - return { - 'color': self.color, - 'parent': self.parent, - 'children': self.children, - 'depth': self.depth, - } - - class MetaStep(object): UNTOUCHED = 0 @@ -92,12 +76,18 @@ class MetaStep(object): def __ne__(self, other): return self.id.int != other.id.int +class Workflow(object): + def __init__(self, steps, metasteps, repository): + self.repository = repository + self.steps = steps + self.metasteps = metasteps + self.active_index = 0 class WorkflowFactory(): booking_steps = [ Booking_Resource_Select, SWConfig_Select, - Booking_Meta + Booking_Meta, ] resource_steps = [ @@ -114,7 +104,7 @@ class WorkflowFactory(): snapshot_steps = [ Select_Host_Step, - Image_Meta_Step + Image_Meta_Step, ] def conjure(self, workflow_type=None, repo=None): @@ -129,8 +119,17 @@ class WorkflowFactory(): meta_steps = self.metaize(steps=steps, wf_type=workflow_type) return steps, meta_steps + def create_workflow(self, workflow_type=None, repo=None): + steps, meta_steps = self.conjure(workflow_type, repo) + c_step = self.make_step(Confirmation_Step, repo) + metaconfirm = MetaStep() + metaconfirm.short_title = "confirm" + metaconfirm.index = len(steps) + steps.append(c_step) + meta_steps.append(metaconfirm) + return Workflow(steps, meta_steps, repo) + def make_steps(self, step_types, repository): - repository.el['steps'] += len(step_types) steps = [] for step_type in step_types: steps.append(self.make_step(step_type, repository)) -- cgit 1.2.3-korg