1 ##############################################################################
2 # Copyright (c) 2018 Sawyer Bergeron, Parker Berberian, Sean Smith, and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
11 from workflow.booking_workflow import Booking_Resource_Select, Booking_Meta, OPNFV_Select
12 from workflow.resource_bundle_workflow import Define_Hardware, Define_Nets, Resource_Meta_Info, Define_Software
13 from workflow.snapshot_workflow import Select_Host_Step, Image_Meta_Step
14 from workflow.opnfv_workflow import Pick_Installer, Assign_Network_Roles, Assign_Host_Roles, OPNFV_Resource_Select, MetaInfo
15 from workflow.models import Confirmation_Step
20 logger = logging.getLogger(__name__)
23 class MetaStep(object):
29 def set_invalid(self, message, code=100):
31 self.message = message
33 def set_valid(self, message, code=200):
35 self.message = message
37 def __init__(self, *args, **kwargs):
38 self.short_title = "error"
43 self.id = uuid.uuid4()
47 'title': self.short_title,
48 'skip': self.skip_step,
50 'message': self.message,
54 return "metastep: " + str(self.short_title)
59 def __eq__(self, other):
60 return self.id.int == other.id.int
62 def __ne__(self, other):
63 return self.id.int != other.id.int
66 class Workflow(object):
67 def __init__(self, steps, repository):
68 self.repository = repository
73 class WorkflowFactory():
75 Booking_Resource_Select,
93 OPNFV_Resource_Select,
100 def conjure(self, workflow_type=None, repo=None):
108 steps = self.make_steps(workflow_types[workflow_type], repository=repo)
111 def create_workflow(self, workflow_type=None, repo=None):
112 steps = self.conjure(workflow_type, repo)
113 c_step = self.make_step(Confirmation_Step, repo)
115 return Workflow(steps, repo)
117 def make_steps(self, step_types, repository):
119 for step_type in step_types:
120 steps.append(self.make_step(step_type, repository))
124 def make_step(self, step_type, repository):
125 iden = step_type.description + step_type.title + step_type.template
126 return step_type(iden, repository)