diff --git a/tests/cli-test-xml/compare/virt-install-osinfo-url-unattended.xml b/tests/cli-test-xml/compare/virt-install-osinfo-url-unattended.xml new file mode 100644 index 000000000..d345ea3fc --- /dev/null +++ b/tests/cli-test-xml/compare/virt-install-osinfo-url-unattended.xml @@ -0,0 +1,97 @@ + + foobar + 00000000-1111-2222-3333-444444444444 + + + + + + 65536 + 65536 + 2 + + hvm + /TESTSUITE_KERNEL_PATH + /TESTSUITE_INITRD_PATH + ks=file:/fedora.ks method=http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/26/Server/x86_64/os/ + + + + + + + + + + + + destroy + + + + + + /usr/bin/qemu-kvm + + + + + + + + + + + + + /dev/urandom + + + + + foobar + 00000000-1111-2222-3333-444444444444 + + + + + + 65536 + 65536 + 2 + + hvm + + + + + + + + + + + + + + + + + + /usr/bin/qemu-kvm + + + + + + + + + + + + + /dev/urandom + + + diff --git a/tests/cli-test-xml/compare/virt-install-osinfo-url.xml b/tests/cli-test-xml/compare/virt-install-osinfo-url.xml new file mode 100644 index 000000000..d30cb2cee --- /dev/null +++ b/tests/cli-test-xml/compare/virt-install-osinfo-url.xml @@ -0,0 +1,97 @@ + + foobar + 00000000-1111-2222-3333-444444444444 + + + + + + 65536 + 65536 + 2 + + hvm + /TESTSUITE_KERNEL_PATH + /TESTSUITE_INITRD_PATH + method=http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/26/Server/x86_64/os/ + + + + + + + + + + + + destroy + + + + + + /usr/bin/qemu-kvm + + + + + + + + + + + + + /dev/urandom + + + + + foobar + 00000000-1111-2222-3333-444444444444 + + + + + + 65536 + 65536 + 2 + + hvm + + + + + + + + + + + + + + + + + + /usr/bin/qemu-kvm + + + + + + + + + + + + + /dev/urandom + + + diff --git a/tests/clitest.py b/tests/clitest.py index acf731b90..70b5ba1f6 100644 --- a/tests/clitest.py +++ b/tests/clitest.py @@ -784,6 +784,8 @@ c.add_compare("--cdrom http://example.com/path/to/some.iso", "cdrom-url") c.add_compare("--pxe --print-step all", "simple-pxe") # Diskless PXE install c.add_compare("--location ftp://example.com", "fake-ftp") # fake ftp:// install using urlfetcher.py mocking c.add_compare("--location https://foobar.com", "fake-http") # fake https:// install using urlfetcher.py mocking +c.add_compare("--connect %(URI-KVM)s --os-variant fedora26,install=location", "osinfo-url") # getting URL from osinfo +c.add_compare("--connect %(URI-KVM)s --os-variant fedora26 --unattended profile=desktop,admin-password=foobar", "osinfo-url-unattended") # unattended install for fedora, using initrd injection c.add_invalid("--pxe --virt-type bogus") # Bogus virt-type c.add_invalid("--pxe --arch bogus") # Bogus arch c.add_invalid("--livecd") # LiveCD with no media @@ -792,8 +794,9 @@ c.add_invalid("--pxe --boot menu=foobar") c.add_invalid("--cdrom %(EXISTIMG1)s --extra-args console=ttyS0") # cdrom fail w/ extra-args c.add_invalid("--hvm --boot kernel=%(TREEDIR)s/pxeboot/vmlinuz,initrd=%(TREEDIR)s/pxeboot/initrd.img,kernel_args='foo bar' --initrd-inject virt-install") # initrd-inject with manual kernel/initrd c.add_invalid("--disk none --location kernel=/dev/null,initrd=/dev/null") # --location with manual kernel/initrd, but not URL -c.add_invalid("--os-variant winxp,install=location") # no URL for winxp -c.add_invalid("--os-variant fedora28,install=fribber") # unknown install= value +c.add_invalid("--os-variant winxp,install=location", grep="does not have a URL location") # no URL for winxp +c.add_invalid("--os-variant fedora28,install=fribber", grep="Unknown --os-variant install value") # unknown install= value +c.add_invalid("--arch i686 --os-variant fedora26,install=location", grep="does not have a URL location for the i686") # there's no URL for i686 c = vinst.add_category("single-disk-install", "--nographics --noautoconsole --disk %(EXISTIMG1)s") c.add_valid("--hvm --import") # FV Import install diff --git a/virt-install b/virt-install index 3b634c7e7..7db51e311 100755 --- a/virt-install +++ b/virt-install @@ -455,15 +455,17 @@ def build_installer(options, guest): options.cdrom = None options.os_variant.install = "location" + INSTALL_VALUES = ["location"] + if options.os_variant.install not in INSTALL_VALUES + [None]: + fail(_("Unknown --os-variant install value '%s'. Must be one of: %s") % + (options.os_variant.install, ", ".join(INSTALL_VALUES))) + if options.os_variant.install == "location": if not options.location: location = guest.osinfo.get_location(guest.os.arch) logging.debug( "Generated default libosinfo '--location %s'", location) options.location = location - elif options.os_variant.install: - fail(_("Unknown --os-variant install=%s") % - options.os_variant.install) if options.location: (location,