Commit 533af7d9 authored by Nikos Skalkotos's avatar Nikos Skalkotos

Add --install-virtio option in snf-mkimage

If this is enabled, the program will try to install the specified VirtIO
drivers to the image.
parent 8a996315
......@@ -104,13 +104,16 @@ def parse_options(input_args):
"input media", default=[], action="append",
metavar="SYSPREP")
parser.add_option("--install-virtio", dest="virtio", type="string",
help="install VirtIO drivers hosted under DIR "
"(Windows only)", metavar="DIR")
parser.add_option("--print-sysprep-params", dest="print_sysprep_params",
default=False, action="store_true",
help="print the defined system preparation parameters "
"for this input media")
parser.add_option("--sysprep-param", dest="sysprep_params", default=[],
help="Add KEY=VALUE system preparation parameter",
help="add KEY=VALUE system preparation parameter",
action="append")
parser.add_option("--no-sysprep", dest="sysprep", default=True,
......@@ -125,7 +128,7 @@ def parse_options(input_args):
action="store_true")
parser.add_option("--allow-unsupported", dest="allow_unsupported",
help="Proceed with the image creation even if the media "
help="proceed with the image creation even if the media "
"is not supported", default=False, action="store_true")
parser.add_option("--tmpdir", dest="tmp", type="string", default=None,
......@@ -174,6 +177,10 @@ def parse_options(input_args):
raise FatalError("Sysprep parameter option: `%s' is not in "
"KEY=VALUE format." % p)
sysprep_params[key] = value
if options.virtio is not None:
sysprep_params['virtio'] = options.virtio
options.sysprep_params = sysprep_params
return options
......@@ -289,6 +296,10 @@ def image_creator():
if options.outfile is None and not options.upload:
return 0
if options.virtio is not None and \
hasattr(image.os, 'install_virtio_drivers'):
image.os.install_virtio_drivers()
if options.sysprep:
image.os.do_sysprep()
......
......@@ -205,6 +205,9 @@ class OSBase(object):
if 'sysprep_params' in kargs:
for key, val in kargs['sysprep_params'].items():
if key not in self.sysprep_params:
self.out.warn("Ignoring invalid `%s' parameter." % key)
continue
param = self.sysprep_params[key]
if not param.set_value(val):
raise FatalError("Invalid value for sysprep parameter: "
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment