diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 173: move the wget | tar type of deployment into a helper function, and make sure that we fail if this...

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

Commit Message

Michael-Doyle Hudson Dec. 7, 2011, 1:38 a.m. UTC
Merge authors:
  Michael Hudson-Doyle (mwhudson)
Related merge proposals:
  https://code.launchpad.net/~mwhudson/lava-dispatcher/bug-900990/+merge/84701
  proposed by: Michael Hudson-Doyle (mwhudson)
  review: Approve - Paul Larson (pwlars)
------------------------------------------------------------
revno: 173 [merge]
committer: Michael Hudson-Doyle <michael.hudson@linaro.org>
branch nick: trunk
timestamp: Wed 2011-12-07 14:36:37 +1300
message:
  move the wget | tar type of deployment into a helper function, and make sure that we fail if this command fails
modified:
  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/client/master.py'
--- lava_dispatcher/client/master.py	2011-11-29 03:28:23 +0000
+++ lava_dispatcher/client/master.py	2011-12-07 01:35:56 +0000
@@ -63,17 +63,27 @@ 
             raise RuntimeError("Failed to create tarball: %s" % tarfile)
 
 
+def _deploy_tarball_to_board(session, tarball_url, dest, timeout=-1):
+    decompression_char = ''
+    if tarball_url.endswith('.gz') or tarball_url.endswith('.tgz'):
+        decompression_char = 'z'
+    elif tarball_url.endswith('.bz2'):
+        decompression_char = 'j'
+    rc = session.run(
+        'wget -qO- %s |tar --numeric-owner -C %s -x%sf -' % (
+            tarball_url, dest, decompression_char),
+        timeout=timeout)
+    if rc != 0:
+        msg = "Deploy: failed to deploy to %s" % dest
+        raise OperationFailed(msg)
+
+
 def _deploy_linaro_rootfs(session, rootfs):
     logging.info("Deploying linaro image")
     session.run('udevadm trigger')
     session.run('mkdir -p /mnt/root')
     session.run('mount /dev/disk/by-label/testrootfs /mnt/root')
-    rc = session.run(
-        'wget -qO- %s |tar --numeric-owner -C /mnt/root -xzf -' % rootfs,
-        timeout=3600)
-    if rc != 0:
-        msg = "Deploy test rootfs partition: failed to download tarball."
-        raise OperationFailed(msg)
+    _deploy_tarball_to_board(session, rootfs, '/mnt/root', timeout=3600)
 
     session.run('echo linaro > /mnt/root/etc/hostname')
     #DO NOT REMOVE - diverting flash-kernel and linking it to /bin/true
@@ -90,11 +100,7 @@ 
     session.run('udevadm trigger')
     session.run('mkdir -p /mnt/boot')
     session.run('mount /dev/disk/by-label/testboot /mnt/boot')
-    rc = session.run(
-        'wget -qO- %s |tar --numeric-owner -C /mnt/boot -xzf -' % bootfs)
-    if rc != 0:
-        msg = "Deploy test boot partition: failed to download tarball."
-        raise OperationFailed(msg)
+    _deploy_tarball_to_board(session, bootfs, '/mnt/boot')
     session.run('umount /mnt/boot')
 
 def _deploy_linaro_android_testboot(session, boottbz2, pkgbz2=None):
@@ -106,11 +112,9 @@ 
     session.run('mkdir -p /mnt/lava/boot')
     session.run('mount /dev/disk/by-label/testboot '
                           '/mnt/lava/boot')
-    session.run('wget -qO- %s |tar --numeric-owner -C /mnt/lava -xjf -' % boottbz2)
+    _deploy_tarball_to_board(session, boottbz2, '/mnt/lava')
     if pkgbz2:
-        session.run(
-            'wget -qO- %s |tar --numeric-owner -C /mnt/lava -xjf -'
-                % pkgbz2)
+        _deploy_tarball_to_board(session, pkgbz2, '/mnt/lava')
 
     _recreate_uInitrd(session)
 
@@ -167,9 +171,7 @@ 
     session.run('mkdir -p /mnt/lava/system')
     session.run(
         'mount /dev/disk/by-label/testrootfs /mnt/lava/system')
-    session.run(
-        'wget -qO- %s |tar --numeric-owner -C /mnt/lava -xjf -' % systemtbz2,
-        timeout=600)
+    _deploy_tarball_to_board(session, systemtbz2, '/mnt/lava', timeout=600)
 
     sed_cmd = "/dev_mount sdcard \/mnt\/sdcard/c dev_mount sdcard /mnt/sdcard %s " \
         "/devices/platform/omap/omap_hsmmc.0/mmc_host/mmc0" %sdcard_part_lava