summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-03-25 21:13:04 +0200
committerLars Wirzenius <liw@liw.fi>2017-03-25 21:13:04 +0200
commit4ea9d96771a42e0784cdc5767a720156a7bda796 (patch)
tree693bc2309a39e47b17968394742dc8df67f5782b
parent7b2e0589daa6d0d7cd6c74503a9a5daa458049a6 (diff)
downloadvmdb2-4ea9d96771a42e0784cdc5767a720156a7bda796.tar.gz
Add kernel plugin
-rw-r--r--vmdb/plugins/kernel_plugin.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/vmdb/plugins/kernel_plugin.py b/vmdb/plugins/kernel_plugin.py
new file mode 100644
index 0000000..0e3c3e5
--- /dev/null
+++ b/vmdb/plugins/kernel_plugin.py
@@ -0,0 +1,49 @@
+# 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 KernelPlugin(cliapp.Plugin):
+
+ def enable(self):
+ self.app.step_runners.add(KernelStepRunner())
+
+
+class KernelStepRunner(vmdb.StepRunnerInterface):
+
+ def get_required_keys(self):
+ return ['kernel']
+
+ def run(self, step_spec, settings, state):
+ package = step_spec['kernel']
+ fstag = step_spec['fstag']
+ mount_point = state.mounts[fstag]
+ sys.stdout.write(
+ 'Install {} to filesystem at {} ({})\n'.format(
+ package, mount_point, fstag))
+ cliapp.runcmd(
+ ['chroot', mount_point, 'apt', '-y', 'install', package],
+ stdout=None, stderr=None)
+