Exemple #1
0
def _test(mockurl, distro=None, initrd=None,
          kernel=None, xen=False, iso=False, arch=None):
    # pylint: disable=protected-access

    conn = tests.utils.URIs.open_testdefault_cached()
    guest = virtinst.Guest(conn)
    guest.os.os_type = xen and "xen" or "hvm"
    if arch:
        guest.os.arch = arch

    url = tests.urlfetcher_mock.make_mock_input_url(mockurl)
    installer = virtinst.Installer(guest.conn, location=url)
    treemedia = installer._treemedia
    treemedia._get_fetcher(guest, None)
    if iso:
        treemedia._cached_fetcher._is_iso = True

    detected_distro = installer.detect_distro(guest)
    assert (distro or "") in (detected_distro or "")

    # Fetch regular kernel
    treecache = treemedia._cached_data
    kernels = [p[0] for p in treecache.kernel_pairs]
    initrds = [p[1] for p in treecache.kernel_pairs]
    if initrd:
        assert any([i.endswith(initrd) for i in initrds])
    if kernel:
        assert any([k.endswith(kernel) for k in kernels])
Exemple #2
0
def do_test_media_detection(conn, options):
    url = options.test_media_detection
    guest = virtinst.Guest(conn)
    if options.arch:
        guest.os.arch = options.arch
    if options.os_type:
        guest.os.os_type = options.os_type
    guest.set_capabilities_defaults()

    installer = virtinst.Installer(conn, location=url)
    print_stdout(installer.detect_distro(guest), do_force=True)
def _make_installer(location=None, conn=None):
    conn = conn or utils.URIs.open_testdriver_cached()
    cdrom = not location and "/dev/null" or None
    inst = virtinst.Installer(conn, location=location, cdrom=cdrom)
    return inst
Exemple #4
0
def build_installer(options, guest, installdata):
    cdrom = None
    location = None
    location_kernel = None
    location_initrd = None
    is_reinstall = bool(options.reinstall)
    unattended_data = None
    extra_args = options.extra_args

    install_bootdev = installdata.bootdev
    install_kernel = installdata.kernel
    install_initrd = installdata.initrd
    install_kernel_args = installdata.kernel_args
    install_os = installdata.os
    no_install = installdata.no_install
    if installdata.kernel_args:
        if installdata.kernel_args_overwrite:
            install_kernel_args = installdata.kernel_args
        else:
            extra_args = [installdata.kernel_args]

    if options.unattended:
        unattended_data = cli.parse_unattended(options.unattended)

    if install_os:
        profile = unattended_data.profile if unattended_data else None
        location = get_location_for_os(guest, install_os, profile)
    elif options.location:
        (location,
         location_kernel,
         location_initrd) = cli.parse_location(options.location)
    elif options.cdrom:
        cdrom = options.cdrom
        if options.livecd:
            no_install = True
    elif options.pxe:
        install_bootdev = "network"
    elif installdata.is_set:
        pass
    elif (options.import_install or
          options.xmlonly or
          options.boot):
        no_install = True

    installer = virtinst.Installer(guest.conn,
            cdrom=cdrom,
            location=location,
            location_kernel=location_kernel,
            location_initrd=location_initrd,
            install_bootdev=install_bootdev,
            install_kernel=install_kernel,
            install_initrd=install_initrd,
            install_kernel_args=install_kernel_args,
            no_install=no_install,
            is_reinstall=is_reinstall)

    if unattended_data:
        installer.set_unattended_data(unattended_data)
    if extra_args:
        installer.set_extra_args(extra_args)
    if options.initrd_inject:
        installer.set_initrd_injections(options.initrd_inject)
    if options.autostart:
        installer.autostart = True
    if options.cloud_init:
        cloudinit_data = cli.parse_cloud_init(options.cloud_init)
        installer.set_cloudinit_data(cloudinit_data)

    return installer