Blob Blame History Raw
diff -rup virtinst-0.300.2.orig/virtinst/DistroManager.py virtinst-0.300.2.new/virtinst/DistroManager.py
--- virtinst-0.300.2.orig/virtinst/DistroManager.py	2008-01-10 20:33:34.000000000 -0500
+++ virtinst-0.300.2.new/virtinst/DistroManager.py	2008-01-15 16:14:59.000000000 -0500
@@ -54,6 +54,27 @@ def _fetcherForURI(uri, scratchdir=None)
         else:
             return MountedImageFetcher(uri, scratchdir)
 
+# Used as a workaround for Satellite issue 
+def _checkRHDistro(fetcher, baseuri, type, progresscb, distro=None, scratchdir=None):
+    # Check for fedora distro
+    store = FedoraImageStore(baseuri, type, scratchdir)
+    if store.isValidStore(fetcher, progresscb):
+        return store
+    # Check for CentOS?
+    if fetcher.hasFile("centosdocs-man.css", progresscb):
+        logging.debug("Detected a CentOS distro")
+        return CentOSImageStore(baseuri, type, scratchdir)
+    # Check for RHEL-5
+    if fetcher.hasFile("RPM-GPG-KEY-redhat-release", progresscb):
+        logging.debug("Detected a RHEL-5 distro")
+        return RHELImageStore(baseuri, type, scratchdir)
+    # Check for RHEL-4
+    if fetcher.hasFile("autorun", progresscb) and \
+       fetcher.hasFile("RPM-GPG-KEY", progresscb):
+        logging.debug("Detected a RHEL-4 distro")
+        return RHELImageStore(baseuri, type, scratchdir)
+    return False
+
 def _storeForDistro(fetcher, baseuri, type, progresscb, distro=None, scratchdir=None):
     stores = []
     if distro == "fedora" or distro is None:
@@ -84,14 +105,21 @@ def _storeForDistro(fetcher, baseuri, ty
 def acquireKernel(baseuri, progresscb, scratchdir="/var/tmp", type=None, distro=None):
     fetcher = _fetcherForURI(baseuri, scratchdir)
     
+    store = None
     try:
         fetcher.prepareLocation(progresscb)
     except ValueError, e:
-        raise ValueError, _("Invalid install location: ") + str(e)
+        logging.debug("Tree URL could not be opened. Checking ahead for valid RH distro.")
+        store = _checkRHDistro(fetcher=fetcher, baseuri=baseuri, type=type,
+                               progresscb=progresscb, distro=distro,
+                               scratchdir=scratchdir)
+        if not store:
+            raise ValueError, _("Invalid install location: ") + str(e)
 
     try:
-        store = _storeForDistro(fetcher=fetcher, baseuri=baseuri, type=type, \
-                                progresscb=progresscb, distro=distro, scratchdir=scratchdir)
+        if store is None:
+            store = _storeForDistro(fetcher=fetcher, baseuri=baseuri, type=type, \
+                                        progresscb=progresscb, distro=distro, scratchdir=scratchdir)
         return store.acquireKernel(fetcher, progresscb)
     finally:
         fetcher.cleanupLocation()
@@ -100,14 +128,21 @@ def acquireKernel(baseuri, progresscb, s
 def acquireBootDisk(baseuri, progresscb, scratchdir="/var/tmp", type=None, distro=None):
     fetcher = _fetcherForURI(baseuri, scratchdir)
 
+    store = None
     try:
         fetcher.prepareLocation(progresscb)
     except ValueError, e:
-        raise ValueError, _("Invalid install location: ") + str(e)
+        logging.debug("Tree URL could not be opened. Checking ahead for valid RH distro.")
+        store = _checkRHDistro(fetcher=fetcher, baseuri=baseuri, type=type,
+                               progresscb=progresscb, distro=distro,
+                               scratchdir=scratchdir)
+        if not store:
+            raise ValueError, _("Invalid install location: ") + str(e)
 
     try:
-        store = _storeForDistro(fetcher=fetcher, baseuri=baseuri, type=type, \
-                                progresscb=progresscb, distro=distro, scratchdir=scratchdir)
+        if store is None:
+            store = _storeForDistro(fetcher=fetcher, baseuri=baseuri, type=type, \
+                                        progresscb=progresscb, distro=distro, scratchdir=scratchdir)
         return store.acquireBootDisk(fetcher, progresscb)
     finally:
         fetcher.cleanupLocation()