summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2018-12-26 15:57:25 +0200
committerLars Wirzenius <liw@liw.fi>2018-12-26 15:57:25 +0200
commit45e2179790796aef05f13dfb1ef592a6c6b9765c (patch)
tree30e1c46c9d2edbf919b561724a00984d09b03941
parentc89bca220360f833183c1d7290ee9f4f444ca490 (diff)
downloadvmdb2-45e2179790796aef05f13dfb1ef592a6c6b9765c.tar.gz
Add: allow steps to run someting even if they're skipped
The debootstrap step now runs 'apt-get update' even if the step is otherwise skipped. This allows a chroot unpacked from an old tarball to get up-to-date Packages files.
-rw-r--r--vmdb/app.py15
-rw-r--r--vmdb/plugins/debootstrap_plugin.py4
-rw-r--r--vmdb/step_list.py3
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.