diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 225: allow deployment from an image file as well as a rootfs/hwpack combination

Message ID 20120208164410.26000.93492.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Michael-Doyle Hudson Feb. 8, 2012, 4:44 p.m. UTC
Merge authors:
  Michael Hudson-Doyle (mwhudson)
Related merge proposals:
  https://code.launchpad.net/~mwhudson/lava-dispatcher/deploy-from-image-bug-922320/+merge/90816
  proposed by: Michael Hudson-Doyle (mwhudson)
  review: Approve - Paul Larson (pwlars)
------------------------------------------------------------
revno: 225 [merge]
committer: Michael Hudson-Doyle <michael.hudson@linaro.org>
branch nick: trunk
timestamp: Wed 2012-02-08 08:42:05 -0800
message:
  allow deployment from an image file as well as a rootfs/hwpack combination
modified:
  lava_dispatcher/actions/deploy.py
  lava_dispatcher/client/master.py


--
lp:lava-dispatcher
https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk

You are subscribed to branch lp:lava-dispatcher.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'lava_dispatcher/actions/deploy.py'
--- lava_dispatcher/actions/deploy.py	2011-12-19 01:40:25 +0000
+++ lava_dispatcher/actions/deploy.py	2012-01-31 01:20:47 +0000
@@ -21,6 +21,6 @@ 
 
 
 class cmd_deploy_linaro_image(BaseAction):
-    def run(self, hwpack, rootfs, kernel_matrix=None, use_cache=True, rootfstype='ext3'):
+    def run(self, hwpack=None, rootfs=None, image=None, kernel_matrix=None, use_cache=True, rootfstype='ext3'):
         self.client.deploy_linaro(
-            hwpack, rootfs, kernel_matrix=None, use_cache=True, rootfstype=rootfstype)
+            hwpack=hwpack, rootfs=rootfs, image=image, kernel_matrix=kernel_matrix, use_cache=use_cache, rootfstype=rootfstype)

=== modified file 'lava_dispatcher/client/master.py'
--- lava_dispatcher/client/master.py	2012-02-07 19:16:17 +0000
+++ lava_dispatcher/client/master.py	2012-02-08 16:42:05 +0000
@@ -261,12 +261,31 @@ 
     def master_str(self):
         return self.device_option("MASTER_STR")
 
-    def deploy_linaro(self, hwpack, rootfs, kernel_matrix=None, use_cache=True, rootfstype='ext3'):
+    def deploy_linaro(self, hwpack=None, rootfs=None, image=None,
+                      kernel_matrix=None, use_cache=True, rootfstype='ext3'):
         LAVA_IMAGE_TMPDIR = self.context.lava_image_tmpdir
         LAVA_IMAGE_URL = self.context.lava_image_url
         try:
-            boot_tgz, root_tgz = self._generate_tarballs(
-                hwpack, rootfs, kernel_matrix, use_cache)
+            if image is None:
+                if hwpack is None or rootfs is None:
+                    raise CriticalError(
+                        "must specify both hwpack and rootfs when not specifying image")
+                else:
+                    image_file = generate_image(self, hwpack, rootfs, kernel_matrix, use_cache)
+            else:
+                if hwpack is not None or rootfs is not None or kernel_matrix is not None:
+                    raise CriticalError(
+                        "cannot specify hwpack or rootfs when specifying image")
+                tarball_dir = mkdtemp(dir=LAVA_IMAGE_TMPDIR)
+                os.chmod(tarball_dir, 0755)
+                if use_cache:
+                    lava_cachedir = self.context.lava_cachedir
+                    image_file = download_with_cache(image, tarball_dir, lava_cachedir)
+                else:
+                    image_file = download(image, tarball_dir)
+            boot_tgz, root_tgz = self._generate_tarballs(image_file)
+        except CriticalError:
+            raise
         except:
             logging.error("Deployment tarballs preparation failed")
             tb = traceback.format_exc()
@@ -428,13 +447,12 @@ 
         session.run('umount /dev/disk/by-label/testboot')
         session.run('mkfs.vfat /dev/disk/by-label/testboot -n testboot')
 
-    def _generate_tarballs(self, hwpack_url, rootfs_url, kernel_matrix, use_cache=True):
+    def _generate_tarballs(self, image_file):
         """Generate tarballs from a hwpack and rootfs url
 
         :param hwpack_url: url of the Linaro hwpack to download
         :param rootfs_url: url of the Linaro image to download
         """
-        image_file = generate_image(self, hwpack_url, rootfs_url, kernel_matrix, use_cache)
         tarball_dir = os.path.dirname(image_file)
         boot_tgz = os.path.join(tarball_dir, "boot.tgz")
         root_tgz = os.path.join(tarball_dir, "root.tgz")