summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-04-19 10:45:18 +0000
committerLars Wirzenius <liw@liw.fi>2020-04-19 10:45:18 +0000
commita39126a450974f2ad0e57010f9ac82efcb1f67d5 (patch)
treed7bab1162fd4779a1b6862a2a093c80712b94756
parente8ce540e7d29b77dffb4fb91fa8b9961368f947a (diff)
parentf4432233bd596982f2fa42c2546ba70d96510bb5 (diff)
downloadvmdb2-a39126a450974f2ad0e57010f9ac82efcb1f67d5.tar.gz
Merge branch 'spec-from-stdin' into 'master'
Add: Allow spec to be passed in via stdin See merge request larswirzenius/vmdb2!8
-rw-r--r--vmdb/app.py9
-rw-r--r--vmdb/spec.py5
-rw-r--r--vmdb2.mdwn7
3 files changed, 15 insertions, 6 deletions
diff --git a/vmdb/app.py b/vmdb/app.py
index 4da30a9..9db656b 100644
--- a/vmdb/app.py
+++ b/vmdb/app.py
@@ -68,9 +68,14 @@ class Vmdb2(cliapp.Application):
sys.exit(1)
def load_spec_file(self, filename):
- vmdb.progress('Load spec file {}'.format(filename))
spec = vmdb.Spec()
- spec.load_file(filename)
+ if filename == "-":
+ vmdb.progress('Load spec from stdin')
+ spec.load_file(sys.stdin)
+ else:
+ vmdb.progress('Load spec file {}'.format(filename))
+ with open(filename) as f:
+ spec.load_file(f)
return spec
def run_steps(self, steps, state):
diff --git a/vmdb/spec.py b/vmdb/spec.py
index 44f4e66..98f5c56 100644
--- a/vmdb/spec.py
+++ b/vmdb/spec.py
@@ -25,9 +25,8 @@ class Spec:
def __init__(self):
self._dict = None
- def load_file(self, filename):
- with open(filename) as f:
- self._dict = yaml.safe_load(f)
+ def load_file(self, f):
+ self._dict = yaml.safe_load(f)
def as_dict(self):
return dict(self._dict)
diff --git a/vmdb2.mdwn b/vmdb2.mdwn
index 9822143..4573605 100644
--- a/vmdb2.mdwn
+++ b/vmdb2.mdwn
@@ -108,7 +108,12 @@ buster onto it. It also installs a kernel, and a boot loader.
To use this, save the specification into `test.vmdb`, and run the
following command:
- sudo vmdb2 test.vmdb --output test.img --verbose
+ sudo vmdb2 --output test.img --verbose test.vmdb
+
+Alternatively the specification can be passed in via stdin by setting the
+file name to `-`, lke so:
+
+ cat test.vmdb | sudo vmdb2 --output test.img --verbose -
This will take a long time, mostly at the `debootstrap` step.