From 256ca7f3fb55cedc88d87f244d1bc6b3c10f6d0f Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Sun, 2 Sep 2018 16:27:34 -0400 Subject: [PATCH] virt-install: Simplify install method validation a bit And drop the --pxe --nonetwork collision check, it's near pointless --- tests/clitest.py | 1 - virt-install | 16 ++++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/clitest.py b/tests/clitest.py index 279cb8936..041097d40 100644 --- a/tests/clitest.py +++ b/tests/clitest.py @@ -800,7 +800,6 @@ c.add_valid("--network bridge:mybr0,model=e1000") # --network bridge: c.add_valid("--network network:default --mac RANDOM") # VirtualNetwork with a random macaddr c.add_valid("--vnc --keymap=local") # --keymap local c.add_valid("--panic 0x505") # ISA panic with iobase specified -c.add_invalid("--nonetworks") # no networks c.add_invalid("--graphics vnc --vnclisten 1.2.3.4") # mixing old and new c.add_invalid("--network=FOO") # Nonexistent network c.add_invalid("--mac 1234") # Invalid mac diff --git a/virt-install b/virt-install index 38a5fb2c8..179d7f9b5 100755 --- a/virt-install +++ b/virt-install @@ -26,9 +26,13 @@ from virtinst.cli import fail, print_stdout, print_stderr install_methods = "--location URL, --cdrom CD/ISO, --pxe, --import, --boot hd|cdrom|..." +def all_install_options(options): + return [options.pxe, options.cdrom, options.location, + options.import_install] + + def install_specified(options): - return bool(options.location or options.cdrom or - options.pxe or options.import_install) + return any([bool(o) for o in all_install_options(options)]) def cdrom_specified(guest, disk=None): @@ -216,9 +220,6 @@ def convert_old_networks(options): fail(_("Cannot use --nonetworks with --network")) options.network = ["none"] - if options.pxe and options.network and "none" in options.network: - fail(_("Can't use --pxe without any network")) - macs = virtinst.util.listify(options.mac) networks = virtinst.util.listify(options.network) bridges = virtinst.util.listify(options.bridge) @@ -433,12 +434,11 @@ def check_option_collisions(options, guest): fail(_("--noreboot and --transient can not be specified together")) # Install collisions - if sum([bool(l) for l in [options.pxe, options.location, - options.cdrom, options.import_install]]) > 1: + if sum([bool(l) for l in all_install_options(options)]) > 1: fail(_("Only one install method can be used (%(methods)s)") % {"methods": install_methods}) - if (guest.os.is_container() and install_specified(options)): + if guest.os.is_container() and install_specified(options): fail(_("Install methods (%s) cannot be specified for " "container guests") % install_methods)