[PATCH] KVM testing: New winutils.iso SHA1, refactoring some code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Make it possible to download the winutils.iso file right
from its repository, making very convenient for users
to perform windows testing.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@xxxxxxxxxx>
---
 client/tests/kvm/get_started.py |   65 +++++++++++++++++++++++++++-----------
 1 files changed, 46 insertions(+), 19 deletions(-)

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)")
-- 
1.7.0.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux