create_subtests_cfg(options.vt_type) create_guest_os_cfg(options.vt_type) if not options.vt_config: restore_image = not (options.vt_no_downloads or options.vt_keep_image) else: restore_image = False 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(options.vt_type, guest_os): os_asset = os_info['asset'] 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 "
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)
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)
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)
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)