Exemplo n.º 1
0
def create_scsi_disk(scsi_option, scsi_size="2048"):
    """
    Get the scsi device created by scsi_debug kernel module

    :param scsi_option. The scsi_debug kernel module options.
    :return: scsi device if it is created successfully.
    """
    try:
        utils_misc.find_command("lsscsi")
    except ValueError:
        raise error.TestNAError("Missing command 'lsscsi'.")

    try:
        # Load scsi_debug kernel module.
        # Unload it first if it's already loaded.
        if utils.module_is_loaded("scsi_debug"):
            utils.unload_module("scsi_debug")
        utils.load_module("scsi_debug dev_size_mb=%s %s" %
                          (scsi_size, scsi_option))
        # Get the scsi device name
        scsi_disk = utils.run("lsscsi|grep scsi_debug|"
                              "awk '{print $6}'").stdout.strip()
        logging.info("scsi disk: %s" % scsi_disk)
        return scsi_disk
    except Exception, e:
        logging.error(str(e))
        return None
Exemplo n.º 2
0
def create_scsi_disk(scsi_option, scsi_size="2048"):
    """
    Get the scsi device created by scsi_debug kernel module

    :param scsi_option. The scsi_debug kernel module options.
    :return: scsi device if it is created successfully.
    """
    try:
        utils_misc.find_command("lsscsi")
    except ValueError:
        raise error.TestNAError("Missing command 'lsscsi'.")

    try:
        # Load scsi_debug kernel module.
        # Unload it first if it's already loaded.
        if utils.module_is_loaded("scsi_debug"):
            utils.unload_module("scsi_debug")
        utils.load_module("scsi_debug dev_size_mb=%s %s"
                          % (scsi_size, scsi_option))
        # Get the scsi device name
        scsi_disk = utils.run("lsscsi|grep scsi_debug|"
                              "awk '{print $6}'").stdout.strip()
        logging.info("scsi disk: %s" % scsi_disk)
        return scsi_disk
    except Exception, e:
        logging.error(str(e))
        return None
Exemplo n.º 3
0
def run(test, params, env):
    """
    load/unload kernel modules several times.

    This tests the kernel pre-installed kernel modules
    """
    installer_object = base_installer.NoopInstaller('noop',
                                                    'module_probe',
                                                    test, params)
    logging.debug('installer object: %r', installer_object)
    submodules = []
    modules_str = " "
    for module in installer_object.module_list:
        if " %s " % module in modules_str:
            continue
        tmp_list = [module]
        if utils.module_is_loaded(module):
            tmp_list += utils.get_submodules(module)
        modules_str += "%s " % " ".join(tmp_list)
        if len(tmp_list) > 1:
            for _ in submodules:
                if _[0] in tmp_list:
                    submodules.remove(_)
                    break
        submodules.append(tmp_list)

    installer_object.module_list = []
    for submodule_list in submodules:
        installer_object.module_list += submodule_list

    load_count = int(params.get("load_count", 100))
    try:
        # unload the modules before starting:
        installer_object.unload_modules()
        for _ in range(load_count):
            try:
                installer_object.load_modules()
            except base_installer.NoModuleError, e:
                logging.error(e)
                break
            except Exception, e:
                raise error.TestFail("Failed to load modules [%r]: %s" %
                                     (installer_object.module_list, e))
Exemplo n.º 4
0
            asset.download_asset(os_asset, interactive=interactive,
                                 restore_image=restore_image)

    check_modules = []
    if options.vt_type == "qemu":
        check_modules = arch.get_kvm_module_list()
    elif options.vt_type == "openvswitch":
        check_modules = ["openvswitch"]

    if check_modules:
        logging.info("")
        step += 1
        logging.info("%d - Checking for modules %s", step,
                     ", ".join(check_modules))
        for module in check_modules:
            if not utils.module_is_loaded(module):
                logging.warning("Module %s is not loaded. You might want to "
                                "load it", module)
            else:
                logging.debug("Module %s loaded", module)

    online_docs_url = 'http://virt-test.readthedocs.org/'
    logging.info("")
    step += 1
    logging.info("%d - If you wish, you may take a look at the online docs for "
                 "more info", step)
    logging.info("")
    logging.info(online_docs_url)


def setup(options):
Exemplo n.º 5
0
def bootstrap(test_name, test_dir, base_dir, default_userspace_paths,
              check_modules, online_docs_url, restore_image=False,
              download_image=True, interactive=True, selinux=False,
              verbose=False, update_providers=False,
              guest_os=defaults.DEFAULT_GUEST_OS):
    """
    Common virt test assistant module.

    :param test_name: Test name, such as "qemu".
    :param test_dir: Path with the test directory.
    :param base_dir: Base directory used to hold images and isos.
    :param default_userspace_paths: Important programs for a successful test
            execution.
    :param check_modules: Whether we want to verify if a given list of modules
            is loaded in the system.
    :param online_docs_url: URL to an online documentation system, such as a
            wiki page.
    :param restore_image: Whether to restore the image from the pristine.
    :param interactive: Whether to ask for confirmation.
    :param verbose: Verbose output.
    :param selinux: Whether setup SELinux contexts for shared/data.
    :param update_providers: Whether to update test providers if they are already
            downloaded.
    :param guest_os: Specify the guest image used for bootstrapping. By default
            the JeOS image is used.

    :raise error.CmdError: If JeOS image failed to uncompress
    :raise ValueError: If 7za was not found
    """
    if interactive:
        logging_manager.configure_logging(utils_misc.VirtLoggingConfig(),
                                          verbose=verbose)
    logging.info("%s test config helper", test_name)
    step = 0

    logging.info("")
    step += 1
    logging.info("%d - Updating all test providers", step)
    asset.download_all_test_providers(update_providers)

    logging.info("")
    step += 1
    logging.info("%d - Checking the mandatory programs and headers", step)
    verify_mandatory_programs(test_name)

    logging.info("")
    step += 1
    logging.info("%d - Checking the recommended programs", step)
    verify_recommended_programs(test_name)

    logging.info("")
    step += 1
    logging.info("%d - Verifying directories", step)
    shared_dir = os.path.dirname(data_dir.get_data_dir())
    sub_dir_list = ["images", "isos", "steps_data", "gpg"]
    for sub_dir in sub_dir_list:
        sub_dir_path = os.path.join(base_dir, sub_dir)
        if not os.path.isdir(sub_dir_path):
            logging.debug("Creating %s", sub_dir_path)
            os.makedirs(sub_dir_path)
        else:
            logging.debug("Dir %s exists, not creating",
                          sub_dir_path)

    datadir = data_dir.get_data_dir()
    if test_name == 'libvirt':
        create_config_files(test_dir, shared_dir, interactive, step)
        create_subtests_cfg(test_name)
        create_guest_os_cfg(test_name)
        # Don't bother checking if changes can't be made
        if os.getuid() == 0:
            verify_selinux(datadir,
                           os.path.join(datadir, 'images'),
                           os.path.join(datadir, 'isos'),
                           data_dir.get_tmp_dir(),
                           interactive, selinux)

    # lvsb test doesn't use any shared configs
    elif test_name == 'lvsb':
        create_subtests_cfg(test_name)
        if os.getuid() == 0:
            # Don't bother checking if changes can't be made
            verify_selinux(datadir,
                           os.path.join(datadir, 'images'),
                           os.path.join(datadir, 'isos'),
                           data_dir.get_tmp_dir(),
                           interactive, selinux)
    else:  # Some other test
        create_config_files(test_dir, shared_dir, interactive, step)
        create_subtests_cfg(test_name)
        create_guest_os_cfg(test_name)

    if download_image or restore_image:
        logging.info("")
        step += 2
        logging.info("%s - Verifying (and possibly downloading) guest image",
                     step)
        for os_info in get_guest_os_info_list(test_name, guest_os):
            os_asset = os_info['asset']
            asset.download_asset(os_asset, interactive=interactive,
                                 restore_image=restore_image)

    if check_modules:
        logging.info("")
        step += 1
        logging.info("%d - Checking for modules %s", step,
                     ", ".join(check_modules))
        for module in check_modules:
            if not utils.module_is_loaded(module):
                logging.warning("Module %s is not loaded. You might want to "
                                "load it", module)
            else:
                logging.debug("Module %s loaded", module)

    if online_docs_url:
        logging.info("")
        step += 1
        logging.info("%d - If you wish, take a look at the online docs for "
                     "more info", step)
        logging.info("")
        logging.info(online_docs_url)
Exemplo n.º 6
0
def delete_scsi_disk():
    """
    Delete scsi device by removing scsi_debug kernel module.
    """
    if utils.module_is_loaded("scsi_debug"):
        utils.unload_module("scsi_debug")
Exemplo n.º 7
0
def bootstrap(test_name,
              test_dir,
              base_dir,
              default_userspace_paths,
              check_modules,
              online_docs_url,
              restore_image=False,
              download_image=True,
              interactive=True,
              verbose=False):
    """
    Common virt test assistant module.

    @param test_name: Test name, such as "qemu".
    @param test_dir: Path with the test directory.
    @param base_dir: Base directory used to hold images and isos.
    @param default_userspace_paths: Important programs for a successful test
            execution.
    @param check_modules: Whether we want to verify if a given list of modules
            is loaded in the system.
    @param online_docs_url: URL to an online documentation system, such as a
            wiki page.
    @param restore_image: Whether to restore the image from the pristine.
    @param interactive: Whether to ask for confirmation.

    @raise error.CmdError: If JeOS image failed to uncompress
    @raise ValueError: If 7za was not found
    """
    if interactive:
        logging_manager.configure_logging(utils_misc.VirtLoggingConfig(),
                                          verbose=verbose)
    logging.info("%s test config helper", test_name)
    step = 0

    logging.info("")
    step += 1
    logging.info("%d - Checking the mandatory programs and headers", step)
    verify_mandatory_programs(test_name)

    logging.info("")
    step += 1
    logging.info("%d - Checking the recommended programs", step)
    verify_recommended_programs(test_name)

    logging.info("")
    step += 1
    logging.info("%d - Verifying directories", step)
    shared_dir = os.path.dirname(data_dir.get_data_dir())
    sub_dir_list = ["images", "isos", "steps_data"]
    for sub_dir in sub_dir_list:
        sub_dir_path = os.path.join(base_dir, sub_dir)
        if not os.path.isdir(sub_dir_path):
            logging.debug("Creating %s", sub_dir_path)
            os.makedirs(sub_dir_path)
        else:
            logging.debug("Dir %s exists, not creating", sub_dir_path)

    create_config_files(test_dir, shared_dir, interactive, step)
    create_subtests_cfg(test_name)
    create_guest_os_cfg(test_name)

    if download_image or restore_image:
        logging.info("")
        step += 2
        logging.info("%s - Verifying (and possibly downloading) guest image",
                     step)
        asset.download_asset('jeos-17-64',
                             interactive=interactive,
                             restore_image=restore_image)

    if check_modules:
        logging.info("")
        step += 1
        logging.info("%d - Checking for modules %s", step,
                     ", ".join(check_modules))
        for module in check_modules:
            if not utils.module_is_loaded(module):
                logging.warning(
                    "Module %s is not loaded. You might want to "
                    "load it", module)
            else:
                logging.debug("Module %s loaded", module)

    if online_docs_url:
        logging.info("")
        step += 1
        logging.info(
            "%d - If you wish, take a look at the online docs for "
            "more info", step)
        logging.info("")
        logging.info(online_docs_url)
Exemplo n.º 8
0
def bootstrap(test_name,
              test_dir,
              base_dir,
              default_userspace_paths,
              check_modules,
              online_docs_url,
              restore_image=False,
              interactive=True,
              selinux=False,
              verbose=False,
              update_providers=False,
              guest_os=defaults.DEFAULT_GUEST_OS,
              force_update=False):
    """
    Common virt test assistant module.

    :param test_name: Test name, such as "qemu".
    :param test_dir: Path with the test directory.
    :param base_dir: Base directory used to hold images and isos.
    :param default_userspace_paths: Important programs for a successful test
            execution.
    :param check_modules: Whether we want to verify if a given list of modules
            is loaded in the system.
    :param online_docs_url: URL to an online documentation system, such as a
            wiki page.
    :param restore_image: Whether to restore the image from the pristine.
    :param interactive: Whether to ask for confirmation.
    :param verbose: Verbose output.
    :param selinux: Whether setup SELinux contexts for shared/data.
    :param update_providers: Whether to update test providers if they are already
            downloaded.
    :param guest_os: Specify the guest image used for bootstrapping. By default
            the JeOS image is used.

    :raise error.CmdError: If JeOS image failed to uncompress
    :raise ValueError: If 7za was not found
    """
    if interactive:
        logging_manager.configure_logging(utils_misc.VirtLoggingConfig(),
                                          verbose=verbose)
    logging.info("%s test config helper", test_name)
    step = 0

    logging.info("")
    step += 1
    logging.info("%d - Updating all test providers", step)
    asset.download_all_test_providers(update_providers)

    logging.info("")
    step += 1
    logging.info("%d - Checking the mandatory programs and headers", step)
    verify_mandatory_programs(test_name, guest_os)

    logging.info("")
    step += 1
    logging.info("%d - Checking the recommended programs", step)
    verify_recommended_programs(test_name)

    logging.info("")
    step += 1
    logging.info("%d - Verifying directories", step)
    shared_dir = os.path.dirname(data_dir.get_data_dir())
    sub_dir_list = ["images", "isos", "steps_data", "gpg"]
    for sub_dir in sub_dir_list:
        sub_dir_path = os.path.join(base_dir, sub_dir)
        if not os.path.isdir(sub_dir_path):
            logging.debug("Creating %s", sub_dir_path)
            os.makedirs(sub_dir_path)
        else:
            logging.debug("Dir %s exists, not creating", sub_dir_path)

    datadir = data_dir.get_data_dir()
    if test_name == 'libvirt':
        create_config_files(test_dir, shared_dir, interactive, step,
                            force_update)
        create_subtests_cfg(test_name)
        create_guest_os_cfg(test_name)
        # Don't bother checking if changes can't be made
        if os.getuid() == 0:
            verify_selinux(datadir, os.path.join(datadir, 'images'),
                           os.path.join(datadir, 'isos'),
                           data_dir.get_tmp_dir(), interactive, selinux)

    # lvsb test doesn't use any shared configs
    elif test_name == 'lvsb':
        create_subtests_cfg(test_name)
        if os.getuid() == 0:
            # Don't bother checking if changes can't be made
            verify_selinux(datadir, os.path.join(datadir, 'images'),
                           os.path.join(datadir, 'isos'),
                           data_dir.get_tmp_dir(), interactive, selinux)
    else:  # Some other test
        create_config_files(test_dir, shared_dir, interactive, step,
                            force_update)
        create_subtests_cfg(test_name)
        create_guest_os_cfg(test_name)

    if restore_image:
        logging.info("")
        step += 1
        logging.info("%s - Verifying (and possibly downloading) guest image",
                     step)
        for os_info in get_guest_os_info_list(test_name, guest_os):
            os_asset = os_info['asset']
            asset.download_asset(os_asset,
                                 interactive=interactive,
                                 restore_image=restore_image)

    if check_modules:
        logging.info("")
        step += 1
        logging.info("%d - Checking for modules %s", step,
                     ", ".join(check_modules))
        for module in check_modules:
            if not utils.module_is_loaded(module):
                logging.warning(
                    "Module %s is not loaded. You might want to "
                    "load it", module)
            else:
                logging.debug("Module %s loaded", module)

    if online_docs_url:
        logging.info("")
        step += 1
        logging.info(
            "%d - If you wish, take a look at the online docs for "
            "more info", step)
        logging.info("")
        logging.info(online_docs_url)
Exemplo n.º 9
0
def bootstrap(test_name, test_dir, base_dir, default_userspace_paths,
              check_modules, online_docs_url, restore_image=False,
              download_image=True, interactive=True, verbose=False):
    """
    Common virt test assistant module.

    :param test_name: Test name, such as "qemu".
    :param test_dir: Path with the test directory.
    :param base_dir: Base directory used to hold images and isos.
    :param default_userspace_paths: Important programs for a successful test
            execution.
    :param check_modules: Whether we want to verify if a given list of modules
            is loaded in the system.
    :param online_docs_url: URL to an online documentation system, such as a
            wiki page.
    :param restore_image: Whether to restore the image from the pristine.
    :param interactive: Whether to ask for confirmation.

    :raise error.CmdError: If JeOS image failed to uncompress
    :raise ValueError: If 7za was not found
    """
    if interactive:
        logging_manager.configure_logging(utils_misc.VirtLoggingConfig(),
                                          verbose=verbose)
    logging.info("%s test config helper", test_name)
    step = 0

    logging.info("")
    step += 1
    logging.info("%d - Checking the mandatory programs and headers", step)
    verify_mandatory_programs(test_name)

    logging.info("")
    step += 1
    logging.info("%d - Checking the recommended programs", step)
    verify_recommended_programs(test_name)

    logging.info("")
    step += 1
    logging.info("%d - Verifying directories", step)
    shared_dir = os.path.dirname(data_dir.get_data_dir())
    sub_dir_list = ["images", "isos", "steps_data", "gpg"]
    for sub_dir in sub_dir_list:
        sub_dir_path = os.path.join(base_dir, sub_dir)
        if not os.path.isdir(sub_dir_path):
            logging.debug("Creating %s", sub_dir_path)
            os.makedirs(sub_dir_path)
        else:
            logging.debug("Dir %s exists, not creating",
                          sub_dir_path)

    # lvsb test doesn't use any shared configs
    if test_name == 'lvsb':
        create_subtests_cfg(test_name)
    else:
        create_config_files(test_dir, shared_dir, interactive, step)
        create_subtests_cfg(test_name)
        create_guest_os_cfg(test_name)

    if download_image or restore_image:
        logging.info("")
        step += 2
        logging.info("%s - Verifying (and possibly downloading) guest image",
                     step)
        asset.download_asset('jeos-19-64', interactive=interactive,
                             restore_image=restore_image)

    if check_modules:
        logging.info("")
        step += 1
        logging.info("%d - Checking for modules %s", step,
                     ", ".join(check_modules))
        for module in check_modules:
            if not utils.module_is_loaded(module):
                logging.warning("Module %s is not loaded. You might want to "
                                "load it", module)
            else:
                logging.debug("Module %s loaded", module)

    if online_docs_url:
        logging.info("")
        step += 1
        logging.info("%d - If you wish, take a look at the online docs for "
                     "more info", step)
        logging.info("")
        logging.info(online_docs_url)
Exemplo n.º 10
0
def bootstrap(test_name, test_dir, base_dir, default_userspace_paths,
              check_modules, online_docs_url, restore_image=False,
              interactive=True, verbose=False):
    """
    Common virt test assistant module.

    @param test_name: Test name, such as "kvm".
    @param test_dir: Path with the test directory.
    @param base_dir: Base directory used to hold images and isos.
    @param default_userspace_paths: Important programs for a successful test
            execution.
    @param check_modules: Whether we want to verify if a given list of modules
            is loaded in the system.
    @param online_docs_url: URL to an online documentation system, such as a
            wiki page.
    @param restore_image: Whether to restore the image from the pristine.
    @param interactive: Whether to ask for confirmation.

    @raise error.CmdError: If JeOS image failed to uncompress
    @raise ValueError: If 7za was not found
    """
    if interactive:
        logging_manager.configure_logging(utils_misc.VirtLoggingConfig(),
                                          verbose=verbose)
    logging.info("%s test config helper", test_name)
    step = 0

    logging.info("")
    step += 1
    logging.info("%d - Checking the mandatory programs and headers", step)
    verify_mandatory_programs(test_name)

    logging.info("")
    step += 1
    logging.info("%d - Checking the recommended programs", step)
    verify_recommended_programs(test_name)

    logging.info("")
    step += 1
    logging.info("%d - Verifying directories", step)
    shared_dir = os.path.dirname(data_dir.get_data_dir())
    shared_dir = os.path.join(shared_dir, "cfg")
    sub_dir_list = ["images", "isos", "steps_data"]
    for sub_dir in sub_dir_list:
        sub_dir_path = os.path.join(base_dir, sub_dir)
        if not os.path.isdir(sub_dir_path):
            logging.debug("Creating %s", sub_dir_path)
            os.makedirs(sub_dir_path)
        else:
            logging.debug("Dir %s exists, not creating" %
                          sub_dir_path)

    create_config_files(test_dir, shared_dir, interactive, step)

    logging.info("")
    step += 2
    logging.info("%s - Verifying (and possibly downloading) guest image", step)

    sha1_file = "SHA1SUM"
    guest_tarball = "jeos-17-64.qcow2.7z"
    base_location = "http://lmr.fedorapeople.org/jeos/"
    url = os.path.join(base_location, guest_tarball)
    tarball_sha1_url = os.path.join(base_location, sha1_file)
    destination = os.path.join(base_dir, 'images')
    uncompressed_file_path = os.path.join(base_dir, 'images',
                                          'jeos-17-64.qcow2')
    uncompressed_file_exists = os.path.isfile(uncompressed_file_path)

    if (interactive and not
        os.path.isfile(os.path.join(destination, guest_tarball))):
        answer = utils.ask("Minimal basic guest image (JeOS) not present. "
                           "Do you want to download it (~ 180MB)?")
    else:
        answer = "y"

    if answer == "y":
        had_to_download = download_file(url, destination, tarball_sha1_url,
                                        title="Downloading JeOS x86_64",
                                        interactive=interactive)
        restore_image = (restore_image or had_to_download or not
                         uncompressed_file_exists)
        tarball_path = os.path.join(destination, guest_tarball)
        if os.path.isfile(tarball_path) and restore_image:
            os.chdir(destination)
            utils.run("7za -y e %s" % tarball_path)

    if check_modules:
        logging.info("")
        step += 1
        logging.info("%d - Checking for modules %s", step,
                     ", ".join(check_modules))
        for module in check_modules:
            if not utils.module_is_loaded(module):
                logging.warning("Module %s is not loaded. You might want to "
                                "load it", module)
            else:
                logging.debug("Module %s loaded", module)

    if online_docs_url:
        logging.info("")
        step += 1
        logging.info("%d - If you wish, take a look at the online docs for "
                     "more info", step)
        logging.info("")
        logging.info(online_docs_url)
Exemplo n.º 11
0
def bootstrap(test_name,
              test_dir,
              base_dir,
              default_userspace_paths,
              check_modules,
              online_docs_url,
              restore_image=False,
              interactive=True,
              verbose=False):
    """
    Common virt test assistant module.

    @param test_name: Test name, such as "kvm".
    @param test_dir: Path with the test directory.
    @param base_dir: Base directory used to hold images and isos.
    @param default_userspace_paths: Important programs for a successful test
            execution.
    @param check_modules: Whether we want to verify if a given list of modules
            is loaded in the system.
    @param online_docs_url: URL to an online documentation system, such as a
            wiki page.
    @param restore_image: Whether to restore the image from the pristine.
    @param interactive: Whether to ask for confirmation.

    @raise error.CmdError: If JeOS image failed to uncompress
    @raise ValueError: If 7za was not found
    """
    if interactive:
        logging_manager.configure_logging(utils_misc.VirtLoggingConfig(),
                                          verbose=verbose)
    logging.info("%s test config helper", test_name)
    step = 0

    logging.info("")
    step += 1
    logging.info("%d - Checking the mandatory programs and headers", step)
    verify_mandatory_programs(test_name)

    logging.info("")
    step += 1
    logging.info("%d - Checking the recommended programs", step)
    verify_recommended_programs(test_name)

    logging.info("")
    step += 1
    logging.info("%d - Verifying directories", step)
    shared_dir = os.path.dirname(data_dir.get_data_dir())
    shared_dir = os.path.join(shared_dir, "cfg")
    sub_dir_list = ["images", "isos", "steps_data"]
    for sub_dir in sub_dir_list:
        sub_dir_path = os.path.join(base_dir, sub_dir)
        if not os.path.isdir(sub_dir_path):
            logging.debug("Creating %s", sub_dir_path)
            os.makedirs(sub_dir_path)
        else:
            logging.debug("Dir %s exists, not creating" % sub_dir_path)

    create_config_files(test_dir, shared_dir, interactive, step)

    logging.info("")
    step += 2
    logging.info("%s - Verifying (and possibly downloading) guest image", step)

    sha1_file = "SHA1SUM"
    guest_tarball = "jeos-17-64.qcow2.7z"
    base_location = "http://lmr.fedorapeople.org/jeos/"
    url = os.path.join(base_location, guest_tarball)
    tarball_sha1_url = os.path.join(base_location, sha1_file)
    destination = os.path.join(base_dir, 'images')
    uncompressed_file_path = os.path.join(base_dir, 'images',
                                          'jeos-17-64.qcow2')
    uncompressed_file_exists = os.path.isfile(uncompressed_file_path)

    if (interactive
            and not os.path.isfile(os.path.join(destination, guest_tarball))):
        answer = utils.ask("Minimal basic guest image (JeOS) not present. "
                           "Do you want to download it (~ 180MB)?")
    else:
        answer = "y"

    if answer == "y":
        had_to_download = download_file(url,
                                        destination,
                                        tarball_sha1_url,
                                        title="Downloading JeOS x86_64",
                                        interactive=interactive)
        restore_image = (restore_image or had_to_download
                         or not uncompressed_file_exists)
        tarball_path = os.path.join(destination, guest_tarball)
        if os.path.isfile(tarball_path) and restore_image:
            os.chdir(destination)
            utils.run("7za -y e %s" % tarball_path)

    if check_modules:
        logging.info("")
        step += 1
        logging.info("%d - Checking for modules %s", step,
                     ", ".join(check_modules))
        for module in check_modules:
            if not utils.module_is_loaded(module):
                logging.warning(
                    "Module %s is not loaded. You might want to "
                    "load it", module)
            else:
                logging.debug("Module %s loaded", module)

    if online_docs_url:
        logging.info("")
        step += 1
        logging.info(
            "%d - If you wish, take a look at the online docs for "
            "more info", step)
        logging.info("")
        logging.info(online_docs_url)
Exemplo n.º 12
0
def delete_scsi_disk():
    """
    Delete scsi device by removing scsi_debug kernel module.
    """
    if utils.module_is_loaded("scsi_debug"):
        utils.unload_module("scsi_debug")