virt-install: Simplify install method validation a bit

And drop the --pxe --nonetwork collision check, it's near pointless
This commit is contained in:
Cole Robinson 2018-09-02 16:27:34 -04:00
parent 0ed8946a5a
commit 256ca7f3fb
2 changed files with 8 additions and 9 deletions

View File

@ -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

View File

@ -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)