From 82be5dccad5ccda69a049e1b5f5f66026963b04c Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Wed, 29 Jan 2020 19:17:54 -0500 Subject: [PATCH] cli: Add --disk type= support Signed-off-by: Cole Robinson --- tests/data/cli/compare/virt-install-many-devices.xml | 5 +++++ tests/test_cli.py | 1 + virtinst/cli.py | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/tests/data/cli/compare/virt-install-many-devices.xml b/tests/data/cli/compare/virt-install-many-devices.xml index 7e91dcdba..cca4794bf 100644 --- a/tests/data/cli/compare/virt-install-many-devices.xml +++ b/tests/data/cli/compare/virt-install-many-devices.xml @@ -222,6 +222,11 @@ + + + + +
diff --git a/tests/test_cli.py b/tests/test_cli.py index 83a2c59bf..87c2fd7f8 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -616,6 +616,7 @@ source.reservations.managed=no,source.reservations.source.type=unix,source.reser --disk vol=iscsi-direct/unit:0:0:1 --disk size=.0001,format=raw --disk size=.0001,pool=disk-pool +--disk path=%(EXISTIMG1)s,type=dir --network user,mac=12:34:56:78:11:22,portgroup=foo,link_state=down,rom_bar=on,rom_file=/tmp/foo --network bridge=foobar,model=virtio,driver_name=qemu,driver_queues=3,filterref=foobar,rom.bar=off,rom.file=/some/rom,source.portgroup=foo diff --git a/virtinst/cli.py b/virtinst/cli.py index 038d395ea..7c5446706 100644 --- a/virtinst/cli.py +++ b/virtinst/cli.py @@ -3087,6 +3087,7 @@ class ParserDisk(VirtCLIParser): fmt = self.optdict.pop("format", None) sparse = _on_off_convert("sparse", self.optdict.pop("sparse", "yes")) convert_perms(self.optdict.pop("perms", None)) + disktype = self.optdict.pop("type", None) if volname: if volname.count("/") != 1: @@ -3096,6 +3097,9 @@ class ParserDisk(VirtCLIParser): log.debug("Parsed --disk volume as: pool=%s vol=%s", poolname, volname) + # Set this up front, it has lots of follow on effects + if disktype: + inst.type = disktype super()._parse(inst) if (size and @@ -3165,6 +3169,8 @@ class ParserDisk(VirtCLIParser): cls.add_arg("size", None, lookup_cb=None, cb=cls.noset_cb) cls.add_arg("format", None, lookup_cb=None, cb=cls.noset_cb) cls.add_arg("sparse", None, lookup_cb=None, cb=cls.noset_cb) + cls.add_arg("type", None, lookup_cb=None, cb=cls.noset_cb) + # These are handled in _add_advertised_aliases cls.add_arg("bus", "bus", cb=cls.noset_cb) cls.add_arg("cache", "driver_cache", cb=cls.noset_cb)