summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-03-25 20:12:51 +0200
committerLars Wirzenius <liw@liw.fi>2017-03-25 20:12:51 +0200
commit731a3ce679c011767f665b2bd96f1394393c6193 (patch)
tree21a7e628181d8f0557702430df1b3b8d39be6e7c
parent6d035574d6d5d7501168001ee9f4a5a076be12e1 (diff)
downloadvmdb2-731a3ce679c011767f665b2bd96f1394393c6193.tar.gz
Add mkfs step
-rw-r--r--vmdb/plugins/mkfs_plugin.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/vmdb/plugins/mkfs_plugin.py b/vmdb/plugins/mkfs_plugin.py
new file mode 100644
index 0000000..30d6028
--- /dev/null
+++ b/vmdb/plugins/mkfs_plugin.py
@@ -0,0 +1,44 @@
+# 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 MkfsPlugin(cliapp.Plugin):
+
+ def enable(self):
+ self.app.step_runners.add(MkfsStepRunner())
+
+
+class MkfsStepRunner(vmdb.StepRunnerInterface):
+
+ def get_required_keys(self):
+ return ['mkfs', 'device']
+
+ def run(self, step_spec, settings, state):
+ fstype = step_spec['mkfs']
+ device = step_spec['device']
+ sys.stdout.write(
+ 'Creating {} filesystem on {}\n'.format(fstype, device))
+ cliapp.runcmd(['/sbin/mkfs', '-t', fstype, device])