diff options
-rw-r--r-- | vmdb/app.py | 15 | ||||
-rw-r--r-- | vmdb/plugins/debootstrap_plugin.py | 4 | ||||
-rw-r--r-- | vmdb/step_list.py | 3 |
3 files changed, 20 insertions, 2 deletions
diff --git a/vmdb/app.py b/vmdb/app.py index 3a88bba..fb28145 100644 --- a/vmdb/app.py +++ b/vmdb/app.py @@ -84,15 +84,26 @@ class Vmdb2(cliapp.Application): core_meltdown = False steps_taken = [] + even_if_skipped = method_name + '_even_if_skipped' for step in steps: try: logging.info(msg, step) steps_taken.append(step) runner = self.step_runners.find(step) if runner.skip(step, self.settings, state): - logging.info('Skipping as requested') + logging.info('Skipping as requested by unless') + method_names = [even_if_skipped] else: - method = getattr(runner, method_name) + method_names = [method_name, even_if_skipped] + + methods = [ + getattr(runner, name) + for name in method_names + if hasattr(runner, name) + ] + + for method in methods: + logging.info('Calling {}'.format(method)) method(step, self.settings, state) except BaseException as e: vmdb.error(str(e)) diff --git a/vmdb/plugins/debootstrap_plugin.py b/vmdb/plugins/debootstrap_plugin.py index 91fc8d1..f52f718 100644 --- a/vmdb/plugins/debootstrap_plugin.py +++ b/vmdb/plugins/debootstrap_plugin.py @@ -42,4 +42,8 @@ class DebootstrapStepRunner(vmdb.StepRunnerInterface): if not (suite and tag and target and mirror): raise Exception('missing arg for debootstrap step') vmdb.runcmd(['debootstrap', '--variant', variant, suite, target, mirror]) + + def run_even_if_skipped(self, step, settings, state): + tag = step['target'] + target = state.tags.get_mount_point(tag) vmdb.runcmd_chroot(target, ['apt-get', 'update']) diff --git a/vmdb/step_list.py b/vmdb/step_list.py index 1f29072..b8f55f4 100644 --- a/vmdb/step_list.py +++ b/vmdb/step_list.py @@ -27,6 +27,9 @@ class StepRunnerInterface(object): # pragma: no cover def run(self, step_spec, settings, state): raise NotImplementedError() + def run_even_if_skipped(self, step_spec, settings, state): + pass + def teardown(self, step_spec, settings, state): # Default implementation does nop, so that sub-classes don't # need to have a nop teardown. |