From 64106230bd09ab87b14ab56c6b40d5e52257628d Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Sat, 20 Sep 2014 20:32:19 -0400 Subject: [PATCH] virt-install: Add hidden option --test-media-detection Can help with debugging and test cases --- .../virt-install-test-url-detection.xml | 1 + tests/clitest.py | 1 + virt-install | 18 +++++++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tests/cli-test-xml/compare/virt-install-test-url-detection.xml diff --git a/tests/cli-test-xml/compare/virt-install-test-url-detection.xml b/tests/cli-test-xml/compare/virt-install-test-url-detection.xml new file mode 100644 index 00000000..9c52cb36 --- /dev/null +++ b/tests/cli-test-xml/compare/virt-install-test-url-detection.xml @@ -0,0 +1 @@ +linux \ No newline at end of file diff --git a/tests/clitest.py b/tests/clitest.py index db5b7c43..c8a65e30 100644 --- a/tests/clitest.py +++ b/tests/clitest.py @@ -512,6 +512,7 @@ c.add_valid("--disk none --boot hd --paravirt --arch i686") # 32 on 64 xen c = vinst.add_category("kvm", "--connect %(KVMURI)s --noautoconsole") c.add_compare("--os-variant fedora20 --file %(EXISTIMG1)s --location %(TREEDIR)s --extra-args console=ttyS0 --cpu host --channel none --console none --sound none --redirdev none", "kvm-f14-url") # F14 Directory tree URL install with extra-args +c.add_compare("--test-media-detection %(TREEDIR)s", "test-url-detection") c.add_compare("--os-variant fedora20 --disk %(NEWIMG1)s,size=.01 --location %(TREEDIR)s --extra-args console=ttyS0 --quiet", "quiet-url") # Quiet URL install should make no noise c.add_compare("--cdrom %(EXISTIMG2)s --file %(EXISTIMG1)s --os-variant win2k3 --wait 0 --sound --controller usb", "kvm-win2k3-cdrom") # HVM windows install with disk c.add_compare("--os-variant fedora20 --nodisks --boot hd --paravirt --cpu pentium2", "kvm-xenner") # xenner diff --git a/virt-install b/virt-install index 8d0a06d8..88befcb2 100755 --- a/virt-install +++ b/virt-install @@ -398,6 +398,14 @@ def set_install_media(guest, location, cdpath, distro_variant): fail(_("Error validating install location: %s" % str(e))) +def do_test_media_detection(conn, url): + (capsguest, capsdomain) = conn.caps.guest_lookup() + guest = conn.caps.build_virtinst_guest(conn, capsguest, capsdomain) + guest.installer = virtinst.DistroInstaller(conn) + guest.installer.location = url + print_stdout(guest.installer.detect_distro(guest), do_force=True) + + ############################# # General option validation # ############################# @@ -921,6 +929,9 @@ def parse_args(): insg.add_argument("--initrd-inject", action="append", help=_("Add given file to root of initrd from --location")) + # Takes a URL and just prints to stdout the detected distro name + insg.add_argument("--test-media-detection", help=argparse.SUPPRESS) + insg.add_argument("--os-type", dest="distro_type", help=argparse.SUPPRESS) insg.add_argument("--os-variant", dest="distro_variant", help=_("The OS variant being installed guests, " @@ -1008,7 +1019,8 @@ def main(conn=None): options = parse_args() # Default setup options - options.quiet = options.xmlstep or options.xmlonly or options.quiet + options.quiet = (options.xmlstep or options.xmlonly or + options.test_media_detection or options.quiet) cli.setupLogging("virt-install", options.debug, options.quiet) @@ -1024,6 +1036,10 @@ def main(conn=None): if conn is None: conn = cli.getConnection(options.connect) + if options.test_media_detection: + do_test_media_detection(conn, options.test_media_detection) + return 0 + if options.xmlstep not in [None, "1", "2", "3", "all"]: fail(_("--print-step must be 1, 2, 3, or all"))