Permalink
Browse files

Add an option to force the download of ISOs.

This option can be used in situations where the size of
the ISOs match, but something else is wrong with the ISO
that prevents it from working properly.  In this case, the
user can specify --force-download, and we will re-download
the file regardless.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
  • Loading branch information...
1 parent b27ae6a commit f41b1e354a4bebc0e8be3c40529f0dc1100fad4c Chris Lalancette committed Nov 4, 2010
Showing with 37 additions and 34 deletions.
  1. +2 −2 oz/Fedora.py
  2. +2 −2 oz/FedoraCore.py
  3. +6 −6 oz/Guest.py
  4. +2 −2 oz/OpenSUSE.py
  5. +2 −2 oz/RHEL_2_1.py
  6. +2 −2 oz/RHEL_3.py
  7. +2 −2 oz/RHEL_4.py
  8. +2 −2 oz/RHEL_5.py
  9. +4 −4 oz/RHL.py
  10. +6 −6 oz/Ubuntu.py
  11. +2 −2 oz/Windows.py
  12. +5 −2 ozinstall
View
@@ -64,9 +64,9 @@ def generate_new_iso(self):
"-o", self.output_iso,
self.iso_contents])
- def generate_install_media(self):
+ def generate_install_media(self, force_download):
self.log.info("Generating install media")
- self.get_original_iso(self.url + "/images/boot.iso")
+ self.get_original_iso(self.url + "/images/boot.iso", force_download)
self.copy_iso()
self.modify_iso()
self.generate_new_iso()
View
@@ -57,8 +57,8 @@ def generate_new_iso(self):
"-boot-info-table", "-v", "-v",
"-o", self.output_iso, self.iso_contents])
- def generate_install_media(self):
- self.get_original_iso(self.url + "/images/boot.iso")
+ def generate_install_media(self, force_download):
+ self.get_original_iso(self.url + "/images/boot.iso", force_download)
self.copy_iso()
self.modify_iso()
self.generate_new_iso()
View
@@ -333,7 +333,7 @@ def wait_for_install_finish(self, count):
self.capture_screenshot(self.libvirt_dom.XMLDesc(0), screenshot)
raise Exception, "Timed out waiting for install to finish"
- def get_original_media(self, url, output):
+ def get_original_media(self, url, output, force_download):
original_available = False
# note that all redirects should already have been resolved by
@@ -343,7 +343,7 @@ def get_original_media(self, url, output):
if conn.getcode() != 200:
raise Exception, "Could not access install url: " + conn.getcode()
- if os.access(output, os.F_OK):
+ if not force_download and os.access(output, os.F_OK):
try:
for header in conn.headers.headers:
if re.match("Content-Length:", header):
@@ -516,8 +516,8 @@ def __init__(self, distro, update, arch, nicmodel, clockoffset, mousetype,
self.output_iso = "/var/lib/libvirt/images/" + self.name + "-oz.iso"
self.iso_contents = "/var/lib/oz/isocontent/" + self.name
- def get_original_iso(self, isourl):
- return self.get_original_media(isourl, self.orig_iso)
+ def get_original_iso(self, isourl, force_download):
+ return self.get_original_media(isourl, self.orig_iso, force_download)
def copy_iso(self):
self.log.info("Copying ISO contents for modification")
@@ -566,8 +566,8 @@ def __init__(self, distro, update, arch, nicmodel, clockoffset, mousetype,
self.output_floppy = "/var/lib/libvirt/images/" + self.name + "-oz.img"
self.floppy_contents = "/var/lib/oz/floppycontent/" + self.name
- def get_original_floppy(self, floppyurl):
- return self.get_original_media(floppyurl, self.orig_floppy)
+ def get_original_floppy(self, floppyurl, force_download):
+ return self.get_original_media(floppyurl, self.orig_floppy, force_download)
def copy_floppy(self):
self.log.info("Copying floppy contents for modification")
View
@@ -43,9 +43,9 @@ def generate_new_iso(self):
"-o", self.output_iso,
self.iso_contents])
- def generate_install_media(self):
+ def generate_install_media(self, force_download):
self.log.info("Generating install media")
- self.get_original_iso(self.isourl)
+ self.get_original_iso(self.isourl, force_download)
self.copy_iso()
self.modify_iso()
self.generate_new_iso()
View
@@ -75,8 +75,8 @@ def modify_floppy(self):
self.output_floppy,
self.floppy_contents + "/SYSLINUX.CFG", "::SYSLINUX.CFG"])
- def generate_install_media(self):
- self.get_original_floppy(self.url + "/images/bootnet.img")
+ def generate_install_media(self, force_download):
+ self.get_original_floppy(self.url + "/images/bootnet.img", force_download)
self.copy_floppy()
self.modify_floppy()
View
@@ -57,8 +57,8 @@ def generate_new_iso(self):
"-boot-info-table", "-v", "-v",
"-o", self.output_iso, self.iso_contents])
- def generate_install_media(self):
- self.get_original_iso(self.url + "/images/boot.iso")
+ def generate_install_media(self, force_download):
+ self.get_original_iso(self.url + "/images/boot.iso", force_download)
self.copy_iso()
self.modify_iso()
self.generate_new_iso()
View
@@ -57,8 +57,8 @@ def generate_new_iso(self):
"-boot-info-table", "-v", "-v",
"-o", self.output_iso, self.iso_contents])
- def generate_install_media(self):
- self.get_original_iso(self.url + "/images/boot.iso")
+ def generate_install_media(self, force_download):
+ self.get_original_iso(self.url + "/images/boot.iso", force_download)
self.copy_iso()
self.modify_iso()
self.generate_new_iso()
View
@@ -57,8 +57,8 @@ def generate_new_iso(self):
"-boot-info-table", "-v", "-v",
"-o", self.output_iso, self.iso_contents])
- def generate_install_media(self):
- self.get_original_iso(self.url + "/images/boot.iso")
+ def generate_install_media(self, force_download):
+ self.get_original_iso(self.url + "/images/boot.iso", force_download)
self.copy_iso()
self.modify_iso()
self.generate_new_iso()
View
@@ -70,8 +70,8 @@ def generate_new_iso(self):
"-boot-info-table", "-v", "-v",
"-o", self.output_iso, self.iso_contents])
- def generate_install_media(self):
- self.get_original_iso(self.url + "/images/boot.iso")
+ def generate_install_media(self, force_download):
+ self.get_original_iso(self.url + "/images/boot.iso", force_download)
self.copy_iso()
self.modify_iso()
self.generate_new_iso()
@@ -131,8 +131,8 @@ def modify_floppy(self):
self.output_floppy,
self.floppy_contents + "/SYSLINUX.CFG", "::SYSLINUX.CFG"])
- def generate_install_media(self):
- self.get_original_floppy(self.url + "/images/bootnet.img")
+ def generate_install_media(self, force_download):
+ self.get_original_floppy(self.url + "/images/bootnet.img", force_download)
self.copy_floppy()
self.modify_floppy()
self.cleanup_floppy()
View
@@ -42,8 +42,8 @@ def generate_new_iso(self):
"-boot-info-table", "-v", "-v",
"-o", output, inputdir])
- def generate_install_media(self):
- self.get_original_iso(self.isourl)
+ def generate_install_media(self, force_download):
+ self.get_original_iso(self.isourl, force_download)
self.copy_iso()
self.modify_iso()
self.generate_new_iso()
@@ -103,8 +103,8 @@ def generate_new_iso(self):
"-boot-info-table", "-v", "-v",
"-o", output, inputdir])
- def generate_install_media(self):
- self.get_original_iso(self.isourl)
+ def generate_install_media(self, force_download):
+ self.get_original_iso(self.isourl, force_download)
self.copy_iso()
self.modify_iso()
self.generate_new_iso()
@@ -155,8 +155,8 @@ def generate_new_iso(self):
"-boot-info-table", "-v", "-v",
"-o", output, inputdir])
- def generate_install_media(self):
- self.get_original_iso(self.isourl)
+ def generate_install_media(self, force_download):
+ self.get_original_iso(self.isourl, force_download)
self.copy_iso()
self.modify_iso()
self.generate_new_iso()
View
@@ -127,8 +127,8 @@ def modify_iso(self):
f.writelines(lines)
f.close()
- def generate_install_media(self):
- self.get_original_iso(self.url)
+ def generate_install_media(self, force_download):
+ self.get_original_iso(self.url, force_download)
self.copy_iso()
self.modify_iso()
self.generate_new_iso()
View
@@ -59,13 +59,14 @@ def usage():
sys.exit(1)
try:
- opts, args = getopt.gnu_getopt(sys.argv[1:], 'd:h', ['debug', 'help'])
+ opts, args = getopt.gnu_getopt(sys.argv[1:], 'd:fh', ['debug', 'force-download', 'help'])
except getopt.GetoptError, err:
print str(err)
usage()
loglevel = logging.ERROR
logformat = "%(message)s"
+force_download=False
for o, a in opts:
if o in ("-h", "--help"):
usage()
@@ -83,6 +84,8 @@ for o, a in opts:
logformat = logging.BASIC_FORMAT
else:
usage()
+ elif o in ("-f", "--force-download"):
+ force_download = True
else:
assert False, "unhandled option"
@@ -123,7 +126,7 @@ else:
usage()
guest.cleanup_old_guest()
-guest.generate_install_media()
+guest.generate_install_media(force_download)
try:
guest.generate_diskimage()
try:

0 comments on commit f41b1e3

Please sign in to comment.