From patchwork Tue May 4 15:52:07 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: 96814 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 o44FqGJi011391 for ; Tue, 4 May 2010 15:52:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754279Ab0EDPwN (ORCPT ); Tue, 4 May 2010 11:52:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53189 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752856Ab0EDPwN (ORCPT ); Tue, 4 May 2010 11:52:13 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o44FqBBn001775 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 4 May 2010 11:52:11 -0400 Received: from localhost.localdomain (vpn-240-160.phx2.redhat.com [10.3.240.160]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o44Fq9va030051; Tue, 4 May 2010 11:52:09 -0400 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues Subject: [PATCH] KVM testing: New winutils.iso SHA1, refactoring some code Date: Tue, 4 May 2010 12:52:07 -0300 Message-Id: <1272988327-10871-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 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]); Tue, 04 May 2010 15:52:17 +0000 (UTC) diff --git a/client/tests/kvm/get_started.py b/client/tests/kvm/get_started.py index 3a6f20f..870485b 100755 --- a/client/tests/kvm/get_started.py +++ b/client/tests/kvm/get_started.py @@ -11,6 +11,34 @@ from autotest_lib.client.common_lib import logging_manager from autotest_lib.client.bin import utils, os_dep +def check_iso(url, destination, hash): + """ + Verifies if ISO that can be found on url is on destination with right hash. + + This function will verify the SHA1 hash of the ISO image. If the file + turns out to be missing or corrupted, let the user know we can download it. + + @param url: URL where the ISO file can be found. + @param destination: Directory in local disk where we'd like the iso to be. + @param hash: SHA1 hash for the ISO image. + """ + logging.info("Verifying iso %s", os.path.basename(url)) + if not destination: + os.makedirs(destination) + iso_path = os.path.join(destination, os.path.basename(url)) + if not os.path.isfile(iso_path) or ( + utils.hash_file(iso_path, method="sha1") != hash): + 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': + utils.unmap_url_cache(destination, url, hash, method="sha1") + else: + logging.warning("Missing file %s. Please download it", iso_path) + else: + logging.debug("%s present, with proper checksum", iso_path) + + if __name__ == "__main__": logging_manager.configure_logging(kvm_utils.KvmLoggingConfig(), verbose=True) @@ -51,28 +79,27 @@ if __name__ == "__main__": 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 " + 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" + + 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, 'isos', '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 ( - 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': - 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", iso_path) + iso_name) + hash = "97a018ba32d43d0e76d032834fe7562bffe8ceb3" + destination = os.path.join(base_dir, 'isos', 'linux') + check_iso(url, destination, hash) + + logging.info("4 - Verifying winutils.iso (make sure we have the utility " + "ISO needed for Windows testing)") + + logging.info("In order to run the KVM autotests in Windows guests, we " + "provide you an ISO that this script can download") + + url = "http://people.redhat.com/mrodrigu/kvm/winutils.iso" + hash = "301da394fe840172188a32f8ba01524993baa0cb" + destination = os.path.join(base_dir, 'isos', 'windows') + check_iso(url, destination, hash) logging.info("4 - Checking if qemu is installed (certify qemu and qemu-kvm " "are in the place the default config expects)")