virt-install: Add hidden option --test-media-detection

Can help with debugging and test cases
This commit is contained in:
Cole Robinson 2014-09-20 20:32:19 -04:00
parent 3933ff101b
commit 64106230bd
3 changed files with 19 additions and 1 deletions

View File

@ -0,0 +1 @@
linux

View File

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

View File

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