summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-03-25 19:47:31 +0200
committerLars Wirzenius <liw@liw.fi>2017-03-25 19:47:31 +0200
commitd9362bb5c2b1460318f33a7b6257f233fbf443cc (patch)
tree9ec2b91839a057d6055e1a71b95250080b8c7d99
parent7c25c0a015334118c323627045bde7726b3efc6d (diff)
downloadvmdb2-d9362bb5c2b1460318f33a7b6257f233fbf443cc.tar.gz
Add a state parameter to the right places
-rw-r--r--vmdb/app.py16
-rw-r--r--vmdb/plugins/echo_plugin.py4
-rw-r--r--vmdb/plugins/error_plugin.py4
-rw-r--r--vmdb/step_list.py4
4 files changed, 15 insertions, 13 deletions
diff --git a/vmdb/app.py b/vmdb/app.py
index 45ebe13..ee1c45e 100644
--- a/vmdb/app.py
+++ b/vmdb/app.py
@@ -41,10 +41,12 @@ class Vmdb2(cliapp.Application):
def process_args(self, args):
spec = self.load_spec_file(args[0])
+ state = None
+
steps = spec['steps']
- steps_taken, core_meltdown = self.run_steps(steps)
- self.run_teardowns(steps_taken)
-
+ steps_taken, core_meltdown = self.run_steps(steps, state)
+ self.run_teardowns(steps_taken, state)
+
if core_meltdown:
logging.error('An error step was used, exiting with error')
sys.exit(1)
@@ -55,7 +57,7 @@ class Vmdb2(cliapp.Application):
with open(filename) as f:
return yaml.safe_load(f)
- def run_steps(self, steps):
+ def run_steps(self, steps, state):
core_meltdown = False
steps_taken = []
@@ -64,7 +66,7 @@ class Vmdb2(cliapp.Application):
steps_taken.append(step)
expanded_step = self.expand_step_spec(step)
runner = self.step_runners.find(step)
- runner.run(expanded_step, self.settings)
+ runner.run(expanded_step, self.settings, state)
except Exception as e:
logging.error('ERROR: %s', str(e))
sys.stderr.write('ERROR: {}\n'.format(str(e)))
@@ -72,11 +74,11 @@ class Vmdb2(cliapp.Application):
return steps_taken, core_meltdown
- def run_teardowns(self, steps_taken):
+ def run_teardowns(self, steps_taken, state):
for step in reversed(steps_taken):
expanded_step = self.expand_step_spec(step)
runner = self.step_runners.find(step)
- runner.teardown(expanded_step, self.settings)
+ runner.teardown(expanded_step, self.settings, state)
def expand_step_spec(self, step):
expanded = {}
diff --git a/vmdb/plugins/echo_plugin.py b/vmdb/plugins/echo_plugin.py
index 195bbeb..376df1b 100644
--- a/vmdb/plugins/echo_plugin.py
+++ b/vmdb/plugins/echo_plugin.py
@@ -36,11 +36,11 @@ class EchoStepRunner(vmdb.StepRunnerInterface):
def get_required_keys(self):
return ['echo']
- def run(self, step_spec, settings):
+ def run(self, step_spec, settings, state):
text = step_spec['echo']
sys.stdout.write('{}\n'.format(text))
- def teardown(self, step_spec, settings):
+ def teardown(self, step_spec, settings, state):
if 'teardown' in step_spec:
text = step_spec['teardown']
sys.stdout.write('{}\n'.format(text))
diff --git a/vmdb/plugins/error_plugin.py b/vmdb/plugins/error_plugin.py
index 6686cbc..92f1b36 100644
--- a/vmdb/plugins/error_plugin.py
+++ b/vmdb/plugins/error_plugin.py
@@ -36,11 +36,11 @@ class ErrorStepRunner(vmdb.StepRunnerInterface):
def get_required_keys(self):
return ['error', 'teardown']
- def run(self, step_spec, settings):
+ def run(self, step_spec, settings, state):
sys.stdout.write('ERROR: {}\n'.format(step_spec['error']))
logging.error('%s', step_spec['error'])
raise vmdb.StepError('an error occurred')
- def teardown(self, step_spec, settings):
+ def teardown(self, step_spec, settings, state):
sys.stdout.write('ERROR: {}\n'.format(step_spec['teardown']))
logging.error('error cleanup: %s', step_spec['teardown'])
diff --git a/vmdb/step_list.py b/vmdb/step_list.py
index 3420f76..a9ee1c3 100644
--- a/vmdb/step_list.py
+++ b/vmdb/step_list.py
@@ -24,10 +24,10 @@ class StepRunnerInterface(object): # pragma: no cover
def get_required_keys(self):
raise NotImplementedError()
- def run(self, step_spec, settings):
+ def run(self, step_spec, settings, state):
raise NotImplementedError()
- def teardown(self, step_spec, settings):
+ def teardown(self, step_spec, settings, state):
# Default implementation does nop, so that sub-classes don't
# need to have a nop teardown.
pass