summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-03-25 20:52:17 +0200
committerLars Wirzenius <liw@liw.fi>2017-03-25 20:52:17 +0200
commit7b2e0589daa6d0d7cd6c74503a9a5daa458049a6 (patch)
tree1eef77570bdbd80ab8d27ad01c8747eda1182076
parentc1ae4298b1b3438243b75f4e2099ed39d3657cf4 (diff)
downloadvmdb2-7b2e0589daa6d0d7cd6c74503a9a5daa458049a6.tar.gz
Add debootstrap plugin
-rw-r--r--vmdb/plugins/debootstrap_plugin.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/vmdb/plugins/debootstrap_plugin.py b/vmdb/plugins/debootstrap_plugin.py
new file mode 100644
index 0000000..d887b7f
--- /dev/null
+++ b/vmdb/plugins/debootstrap_plugin.py
@@ -0,0 +1,48 @@
+# Copyright 2017 Lars Wirzenius
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# =*= License: GPL-3+ =*=
+
+
+
+import logging
+import sys
+
+import cliapp
+
+import vmdb
+
+
+class DebootstrapPlugin(cliapp.Plugin):
+
+ def enable(self):
+ self.app.step_runners.add(DebootstrapStepRunner())
+
+
+class DebootstrapStepRunner(vmdb.StepRunnerInterface):
+
+ def get_required_keys(self):
+ return ['debootstrap', 'target', 'mirror']
+
+ def run(self, step_spec, settings, state):
+ suite = step_spec['debootstrap']
+ tag = step_spec['target']
+ target = state.mounts[tag]
+ mirror = step_spec['mirror']
+ if not (suite and tag and target and mirror):
+ raise Exception('missing arg for debootstrap step')
+ sys.stdout.write(
+ 'Debootstrap {} {} {}\n'.format(suite, target, mirror))
+ cliapp.runcmd(['debootstrap', suite, target, mirror], stdout=None, stderr=None)