]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
calamari_setup: make iceball fetch/creators return path to iceball
authorDan Mick <dan.mick@redhat.com>
Thu, 19 Mar 2015 00:03:17 +0000 (17:03 -0700)
committerDan Mick <dan.mick@redhat.com>
Thu, 19 Mar 2015 00:16:53 +0000 (17:16 -0700)
Also, widen the concept of "iceball" to include both iso and tar.gz

Signed-off-by: Dan Mick <dan.mick@redhat.com>
tasks/calamari_setup.py

index eae615cdce535d0e8e5125bd33d7b89df7a7a580..17c27e4910e09b20a9b30a61c5055ff56682e787 100644 (file)
@@ -156,21 +156,24 @@ def fix_yum_repos(remote, distro):
 
 def get_iceball_with_http(urlbase, ice_version, ice_distro, destdir):
     '''
-    Copy iceball with http to destdir
+    Copy iceball with http to destdir.  Try both .tar.gz and .iso.
     '''
-    url = '/'.join((
-        urlbase,
-        '{ver}/ICE-{ver}-{distro}.tar.gz'.format(
-            ver=ice_version, distro=ice_distro
-        )
-    ))
+    urlprefix = os.path.join(urlbase, '{ver}/ICE-{ver}-{distro}'.format(
+                             ver=ice_version, distro=ice_distro))
+    urls = [urlprefix + ext for ext in ('.tar.gz', '.iso')]
+
     # stream=True means we don't download until copyfileobj below,
     # and don't need a temp file
-    r = requests.get(url, stream=True)
-    filename = url.split('/')[-1]
-    with open(filename, 'w') as f:
-        shutil.copyfileobj(r.raw, f)
-    log.info('saved %s as %s' % (url, filename))
+    for url in urls:
+        r = requests.get(url, stream=True)
+        if not r.ok:
+            continue
+        filename = os.path.join(destdir, url.split('/')[-1])
+        with open(filename, 'w') as f:
+            shutil.copyfileobj(r.raw, f)
+        log.info('saved %s as %s' % (url, filename))
+        return filename
+    raise RuntimeError("Failed to download %s", str(urls))
 
 
 def create_iceball(ice_tool_dir, git_icetool_loc, ice_version, version, ice_distro):
@@ -203,6 +206,9 @@ def create_iceball(ice_tool_dir, git_icetool_loc, ice_version, version, ice_dist
                            (exec_ice, ice_distro))
     subprocess.check_call('rm -rf teuth-virtenv'.split(),
                           cwd=ice_tool_loc)
+    return os.path.join(
+        ice_tool_loc, 'ICE-{0}-{1}.tar.gz'.format(ice_version, ice_distro)
+    )
 
 
 @contextlib.contextmanager