From patchwork Fri Jan 29 06:07:32 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 75662 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o0T681Zg002717 for ; Fri, 29 Jan 2010 06:08:01 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751859Ab0A2GH6 (ORCPT ); Fri, 29 Jan 2010 01:07:58 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751843Ab0A2GH6 (ORCPT ); Fri, 29 Jan 2010 01:07:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37303 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751811Ab0A2GH5 (ORCPT ); Fri, 29 Jan 2010 01:07:57 -0500 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o0T67shm029702 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 29 Jan 2010 01:07:54 -0500 Received: from localhost.localdomain (vpn-11-140.rdu.redhat.com [10.11.11.140]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o0T67YZg012118; Fri, 29 Jan 2010 01:07:52 -0500 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues Subject: [PATCH 6/6] KVM test: Add a get_started.py script Date: Fri, 29 Jan 2010 04:07:32 -0200 Message-Id: <1264745252-14077-6-git-send-email-lmr@redhat.com> In-Reply-To: <1264745252-14077-5-git-send-email-lmr@redhat.com> References: <1264745252-14077-1-git-send-email-lmr@redhat.com> <1264745252-14077-2-git-send-email-lmr@redhat.com> <1264745252-14077-3-git-send-email-lmr@redhat.com> <1264745252-14077-4-git-send-email-lmr@redhat.com> <1264745252-14077-5-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 29 Jan 2010 06:08:01 +0000 (UTC) diff --git a/client/tests/kvm/README b/client/tests/kvm/README index 88d2c15..628f3d9 100644 --- a/client/tests/kvm/README +++ b/client/tests/kvm/README @@ -1,3 +1,20 @@ -In order to get started, please refer to the online documentation: +For the impatient: + +Execute the get_started.py script located on this directory, +that will guide you through setting up the default kvm test +scenario: + + * Guest install with Fedora 12 + * Boot, reboot and shutdown test + +The script will help you to create all the directories, and +even get the OS iso in case you don't have it yet. + +For the not so impatient: + +You are *strongly* advised to read the online docs: http://www.linux-kvm.org/page/KVM-Autotest/Client_Install + +So you can have a better idea of how the test is organized +and how it works. diff --git a/client/tests/kvm/get_started.py b/client/tests/kvm/get_started.py new file mode 100755 index 0000000..51d98f0 --- /dev/null +++ b/client/tests/kvm/get_started.py @@ -0,0 +1,103 @@ +#!/usr/bin/python +""" +Program to help setup kvm test environment + +@copyright: Red Hat 2010 +""" + +import os, sys, optparse, logging, shutil +import common, kvm_utils +from autotest_lib.client.common_lib import logging_manager +from autotest_lib.client.bin import utils, os_dep + + +if __name__ == "__main__": + logging_manager.configure_logging(kvm_utils.KvmLoggingConfig(), + verbose=True) + logging.info("KVM test config helper") + + logging.info("1 - Verifying directories (check if the directory structure " + "expected by the default test config is there)") + base_dir = "/tmp/kvm_autotest_root" + 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) + logging.info("Do you want to setup NFS mounts for some of those " + "dirs? (y/n)") + setup_nfs = raw_input() + if setup_nfs == 'y': + logging.info("Exiting the script so you can setup the NFS mounts. " + "When you are done, re-run this script.") + sys.exit(0) + + logging.info("2 - Creating config files from samples (copy the default " + "config samples to actual config files)") + kvm_test_dir = os.path.dirname(sys.modules[__name__].__file__) + kvm_test_dir = os.path.abspath(kvm_test_dir) + config_file_list = ["address_pools.cfg", "build.cfg", "cdkeys.cfg", + "tests_base.cfg", "tests.cfg"] + for config_file in config_file_list: + src_file = os.path.join(kvm_test_dir, "%s.sample" % config_file) + dst_file = os.path.join(kvm_test_dir, config_file) + if not os.path.isfile(dst_file): + logging.debug("Creating config file %s from sample", dst_file) + shutil.copyfile(src_file, dst_file) + else: + logging.debug("Config file %s exists, not touching" % dst_file) + + logging.info("3 - Verifying iso (make sure we have the OS iso needed for " + "the default test set)") + base_iso_name = "Fedora-12-x86_64-DVD.iso" + fedora_dir = "pub/fedora/linux/releases/12/Fedora/x86_64/iso" + url = os.path.join("http://download.fedoraproject.org/", fedora_dir, + base_iso_name) + md5sum = "6dd31e292cc2eb1140544e9b1ba61c56" + iso_dir = os.path.join(base_dir, 'images', 'linux') + if not iso_dir: + os.makedirs(iso_dir) + iso_path = os.path.join(iso_dir, base_iso_name) + if not os.path.isfile(iso_path) or ( + kvm_utils.hash_file(iso_path, method="md5") != md5sum): + logging.warning("%s not found or corrupted", iso_path) + logging.warning("Would you like to download it? (y/n)") + iso_download = raw_input() + if iso_download == 'y': + kvm_utils.unmap_url_cache(iso_dir, url, md5sum) + else: + logging.warning("Missing file %s. Please download it" % iso_path) + else: + logging.debug("%s present, with proper checksum") + + logging.info("4 - Checking if qemu is installed (certify qemu and qemu-kvm " + "are in the place the default config expects)") + qemu_default_paths = ['/usr/bin/qemu-kvm', '/usr/bin/qemu-img'] + for qemu_path in qemu_default_paths: + if not os.path.isfile(qemu_path): + logging.warning("No %s found. You might need to install qemu-kvm.") + else: + logging.debug("%s present" % qemu_path) + + logging.info("5 - Checking for the KVM module (make sure kvm is loaded " + "to accelerate qemu-kvm)") + if not utils.module_is_loaded("kvm"): + logging.warning("KVM module is not loaded. You might want to load it") + else: + logging.debug("KVM module loaded") + + logging.info("6 - Verify needed packages to get started") + logging.info("Please take a look at the online documentation " + "http://www.linux-kvm.org/page/KVM-Autotest/Client_Install " + "(session 'Install Prerequisite packages')") + + client_dir = os.path.abspath(os.path.join(kvm_test_dir, "..", "..")) + autotest_bin = os.path.join(client_dir, 'bin', 'autotest') + control_file = os.path.join(kvm_test_dir, 'control') + logging.info("When you are done fixing eventual warnings found, " + "you can run the kvm test using the command line:") + logging.info("%s --verbose %s", autotest_bin, control_file)