[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 99: add and use client APIs run_cmd_master and run_cmd_tester

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

Commit Message

Michael-Doyle Hudson Sept. 5, 2011, 10:18 p.m.
Merge authors:
  Michael Hudson-Doyle (mwhudson)
Related merge proposals:
  https://code.launchpad.net/~mwhudson/lava-dispatcher/better-run_cmd-api/+merge/73745
  proposed by: Michael Hudson-Doyle (mwhudson)
------------------------------------------------------------
revno: 99 [merge]
committer: Michael-Doyle Hudson <michael.hudson@linaro.org>
branch nick: trunk
timestamp: Tue 2011-09-06 10:16:16 +1200
message:
  add and use client APIs run_cmd_master and run_cmd_tester
modified:
  lava_dispatcher/actions/android_basic.py
  lava_dispatcher/actions/android_deploy.py
  lava_dispatcher/actions/deploy.py
  lava_dispatcher/actions/launch_control.py
  lava_dispatcher/actions/lava-test.py
  lava_dispatcher/android_client.py
  lava_dispatcher/client.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

Patch

=== modified file 'lava_dispatcher/actions/android_basic.py'
--- lava_dispatcher/actions/android_basic.py	2011-06-27 04:55:08 +0000
+++ lava_dispatcher/actions/android_basic.py	2011-09-02 03:00:59 +0000
@@ -21,7 +21,6 @@ 
 
 from lava_dispatcher.actions import BaseAndroidAction
 from lava_dispatcher.client import OperationFailed
-from lava_dispatcher.android_config import TESTER_STR
 import time
 import pexpect
 import sys

=== modified file 'lava_dispatcher/actions/android_deploy.py'
--- lava_dispatcher/actions/android_deploy.py	2011-08-18 14:51:08 +0000
+++ lava_dispatcher/actions/android_deploy.py	2011-09-05 21:52:35 +0000
@@ -20,7 +20,7 @@ 
 # along with this program; if not, see <http://www.gnu.org/licenses>.
 
 from lava_dispatcher.actions import BaseAction
-from lava_dispatcher.config import LAVA_IMAGE_TMPDIR, LAVA_IMAGE_URL, MASTER_STR
+from lava_dispatcher.config import LAVA_IMAGE_TMPDIR, LAVA_IMAGE_URL
 import os
 import sys
 import shutil
@@ -101,156 +101,89 @@ 
 
     def deploy_linaro_android_testboot(self, boottbz2):
         client = self.client
-        client.run_shell_command(
-            'mkfs.vfat /dev/disk/by-label/testboot -n testboot',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'udevadm trigger',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'mkdir -p /mnt/lava/boot',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'mount /dev/disk/by-label/testboot /mnt/lava/boot',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'wget -qO- %s |tar --numeric-owner -C /mnt/lava -xjf -' % boottbz2,
-            response = MASTER_STR)
+        client.run_cmd_master('mkfs.vfat /dev/disk/by-label/testboot '
+                              '-n testboot')
+        client.run_cmd_master('udevadm trigger')
+        client.run_cmd_master('mkdir -p /mnt/lava/boot')
+        client.run_cmd_master('mount /dev/disk/by-label/testboot '
+                              '/mnt/lava/boot')
+        client.run_cmd_master('wget -qO- %s |tar --numeric-owner -C /mnt/lava -xjf -' % boottbz2)
 
         self.recreate_uInitrd()
 
-        client.run_shell_command(
-            'umount /mnt/lava/boot',
-            response = MASTER_STR)
+        client.run_cmd_master('umount /mnt/lava/boot')
 
     def recreate_uInitrd(self):
         client = self.client
-        client.run_shell_command(
-            'mkdir -p ~/tmp/',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'mv /mnt/lava/boot/uInitrd ~/tmp',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'cd ~/tmp/',
-            response = MASTER_STR)
-
-        client.run_shell_command(
-            'dd if=uInitrd of=uInitrd.data ibs=64 skip=1',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'mv uInitrd.data ramdisk.cpio.gz',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'gzip -d ramdisk.cpio.gz; cpio -i -F ramdisk.cpio',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'sed -i "/mount ext4 \/dev\/block\/mmcblk0p3/d" init.rc',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'sed -i "/mount ext4 \/dev\/block\/mmcblk0p5/d" init.rc',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'sed -i "s/mmcblk0p2/mmcblk0p5/g" init.rc',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'sed -i "/export PATH/a \ \ \ \ export PS1 root@linaro: " init.rc',
-            response = MASTER_STR)
-
-        client.run_shell_command(
+        client.run_cmd_master('mkdir -p ~/tmp/')
+        client.run_cmd_master('mv /mnt/lava/boot/uInitrd ~/tmp')
+        client.run_cmd_master('cd ~/tmp/')
+
+        client.run_cmd_master('dd if=uInitrd of=uInitrd.data ibs=64 skip=1')
+        client.run_cmd_master('mv uInitrd.data ramdisk.cpio.gz')
+        client.run_cmd_master(
+            'gzip -d ramdisk.cpio.gz; cpio -i -F ramdisk.cpio')
+        client.run_cmd_master(
+            'sed -i "/mount ext4 \/dev\/block\/mmcblk0p3/d" init.rc')
+        client.run_cmd_master(
+            'sed -i "/mount ext4 \/dev\/block\/mmcblk0p5/d" init.rc')
+        client.run_cmd_master('sed -i "s/mmcblk0p2/mmcblk0p5/g" init.rc')
+        client.run_cmd_master(
+            'sed -i "/export PATH/a \ \ \ \ export PS1 root@linaro: " init.rc')
+
+        client.run_cmd_master(
             'cpio -i -t -F ramdisk.cpio | cpio -o -H newc | \
-                gzip > ramdisk_new.cpio.gz',
-            response = MASTER_STR)
+                gzip > ramdisk_new.cpio.gz')
 
-        client.run_shell_command(
+        client.run_cmd_master(
             'mkimage -A arm -O linux -T ramdisk -n "Android Ramdisk Image" \
-                -d ramdisk_new.cpio.gz uInitrd',
-            response = MASTER_STR)
+                -d ramdisk_new.cpio.gz uInitrd')
 
-        client.run_shell_command(
-            'cd -',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'mv ~/tmp/uInitrd /mnt/lava/boot/uInitrd',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'rm -rf ~/tmp',
-            response = MASTER_STR)
+        client.run_cmd_master('cd -')
+        client.run_cmd_master('mv ~/tmp/uInitrd /mnt/lava/boot/uInitrd')
+        client.run_cmd_master('rm -rf ~/tmp')
 
     def deploy_linaro_android_testrootfs(self, systemtbz2):
         client = self.client
-        client.run_shell_command(
-            'mkfs.ext4 -q /dev/disk/by-label/testrootfs -L testrootfs',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'udevadm trigger',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'mkdir -p /mnt/lava/system',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'mount /dev/disk/by-label/testrootfs /mnt/lava/system',
-            response = MASTER_STR)
-        client.run_shell_command(
+        client.run_cmd_master(
+            'mkfs.ext4 -q /dev/disk/by-label/testrootfs -L testrootfs')
+        client.run_cmd_master('udevadm trigger')
+        client.run_cmd_master('mkdir -p /mnt/lava/system')
+        client.run_cmd_master(
+            'mount /dev/disk/by-label/testrootfs /mnt/lava/system')
+        client.run_cmd_master(
             'wget -qO- %s |tar --numeric-owner -C /mnt/lava -xjf -' % systemtbz2,
-            response = MASTER_STR, timeout = 600)
+            600)
 
         sed_cmd = "/dev_mount sdcard \/mnt\/sdcard/c dev_mount sdcard /mnt/sdcard 6 " \
             "/devices/platform/omap/omap_hsmmc.0/mmc_host/mmc0"
-        client.run_shell_command(
-            'sed -i "%s" /mnt/lava/system/etc/vold.fstab' % sed_cmd,
-            response = MASTER_STR)
-        client.run_shell_command(
-            'umount /mnt/lava/system',
-            response = MASTER_STR)
+        client.run_cmd_master(
+            'sed -i "%s" /mnt/lava/system/etc/vold.fstab' % sed_cmd)
+        client.run_cmd_master('umount /mnt/lava/system')
 
     def purge_linaro_android_sdcard(self):
         client = self.client
-        client.run_shell_command(
-            'mkfs.vfat /dev/disk/by-label/sdcard -n sdcard',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'udevadm trigger',
-            response = MASTER_STR)
+        client.run_cmd_master('mkfs.vfat /dev/disk/by-label/sdcard -n sdcard')
+        client.run_cmd_master('udevadm trigger')
 
     def deploy_linaro_android_system(self, systemtbz2):
         client = self.client
-        client.run_shell_command(
-            'mkfs.ext4 -q /dev/disk/by-label/system -L system',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'udevadm trigger',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'mkdir -p /mnt/lava/system',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'mount /dev/disk/by-label/system /mnt/lava/system',
-            response = MASTER_STR)
-        client.run_shell_command(
+        client.run_cmd_master('mkfs.ext4 -q /dev/disk/by-label/system -L system')
+        client.run_cmd_master('udevadm trigger')
+        client.run_cmd_master('mkdir -p /mnt/lava/system')
+        client.run_cmd_master('mount /dev/disk/by-label/system /mnt/lava/system')
+        client.run_cmd_master(
             'wget -qO- %s |tar --numeric-owner -C /mnt/lava -xjf -' % systemtbz2,
-            response = MASTER_STR, timeout = 600)
-        client.run_shell_command(
-            'umount /mnt/lava/system',
-            response = MASTER_STR)
+            600)
+        client.run_cmd_master('umount /mnt/lava/system')
 
     def deploy_linaro_android_data(self, datatbz2):
         client = self.client
-        client.run_shell_command(
-            'mkfs.ext4 -q /dev/disk/by-label/data -L data',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'udevadm trigger',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'mkdir -p /mnt/lava/data',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'mount /dev/disk/by-label/data /mnt/lava/data',
-            response = MASTER_STR)
-        client.run_shell_command(
+        client.run_cmd_master('mkfs.ext4 -q /dev/disk/by-label/data -L data')
+        client.run_cmd_master('udevadm trigger')
+        client.run_cmd_master('mkdir -p /mnt/lava/data')
+        client.run_cmd_master('mount /dev/disk/by-label/data /mnt/lava/data')
+        client.run_cmd_master(
             'wget -qO- %s |tar --numeric-owner -C /mnt/lava -xjf -' % datatbz2,
-            response = MASTER_STR, timeout = 600)
-        client.run_shell_command(
-            'umount /mnt/lava/data',
-            response = MASTER_STR)
+            600)
+        client.run_cmd_master('umount /mnt/lava/data')

=== modified file 'lava_dispatcher/actions/deploy.py'
--- lava_dispatcher/actions/deploy.py	2011-08-18 14:50:41 +0000
+++ lava_dispatcher/actions/deploy.py	2011-09-02 03:38:30 +0000
@@ -27,7 +27,7 @@ 
 from tempfile import mkdtemp
 
 from lava_dispatcher.actions import BaseAction
-from lava_dispatcher.config import LAVA_IMAGE_TMPDIR, LAVA_IMAGE_URL, MASTER_STR
+from lava_dispatcher.config import LAVA_IMAGE_TMPDIR, LAVA_IMAGE_URL
 from lava_dispatcher.utils import download, download_with_cache
 from lava_dispatcher.client import CriticalError
 
@@ -127,8 +127,8 @@ 
         image_file = os.path.join(tarball_dir, "lava.img")
         board = client.board
         cmd = ("sudo linaro-media-create --hwpack-force-yes --dev %s "
-               "--image_file %s --binary %s --hwpack %s --image_size 3G" % (
-                board.type, image_file, rootfs_path, hwpack_path))
+               "--image_file %s --binary %s --hwpack %s --image_size 3G" %
+               (board.type, image_file, rootfs_path, hwpack_path))
         rc, output = getstatusoutput(cmd)
         if rc:
             shutil.rmtree(tarball_dir)
@@ -152,61 +152,34 @@ 
     def deploy_linaro_rootfs(self, rootfs):
         client = self.client
         print "Deploying linaro image"
-        client.run_shell_command(
-            'umount /dev/disk/by-label/testrootfs',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'mkfs.ext3 -q /dev/disk/by-label/testrootfs -L testrootfs',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'udevadm trigger',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'mkdir -p /mnt/root',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'mount /dev/disk/by-label/testrootfs /mnt/root',
-            response = MASTER_STR)
-        client.run_shell_command(
+        client.run_cmd_master('umount /dev/disk/by-label/testrootfs')
+        client.run_cmd_master(
+            'mkfs.ext3 -q /dev/disk/by-label/testrootfs -L testrootfs')
+        client.run_cmd_master('udevadm trigger')
+        client.run_cmd_master('mkdir -p /mnt/root')
+        client.run_cmd_master('mount /dev/disk/by-label/testrootfs /mnt/root')
+        client.run_cmd_master(
             'wget -qO- %s |tar --numeric-owner -C /mnt/root -xzf -' % rootfs,
-            response = MASTER_STR, timeout = 3600)
-        client.run_shell_command(
-            'echo linaro > /mnt/root/etc/hostname',
-            response = MASTER_STR)
+            timeout = 3600)
+        client.run_cmd_master('echo linaro > /mnt/root/etc/hostname')
         #DO NOT REMOVE - diverting flash-kernel and linking it to /bin/true
         #prevents a serious problem where packages getting installed that
         #call flash-kernel can update the kernel on the master image
-        client.run_shell_command(
-            'chroot /mnt/root dpkg-divert --local /usr/sbin/flash-kernel',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'chroot /mnt/root ln -sf /bin/true /usr/sbin/flash-kernel',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'umount /mnt/root',
-            response = MASTER_STR)
+        client.run_cmd_master(
+            'chroot /mnt/root dpkg-divert --local /usr/sbin/flash-kernel')
+        client.run_cmd_master(
+            'chroot /mnt/root ln -sf /bin/true /usr/sbin/flash-kernel')
+        client.run_cmd_master('umount /mnt/root')
 
     def deploy_linaro_bootfs(self, bootfs):
         client = self.client
-        client.run_shell_command(
-            'umount /dev/disk/by-label/testboot',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'mkfs.vfat /dev/disk/by-label/testboot -n testboot',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'udevadm trigger',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'mkdir -p /mnt/boot',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'mount /dev/disk/by-label/testboot /mnt/boot',
-            response = MASTER_STR)
-        client.run_shell_command(
-            'wget -qO- %s |tar --numeric-owner -C /mnt/boot -xzf -' % bootfs,
-            response = MASTER_STR)
-        client.run_shell_command(
-            'umount /mnt/boot',
-            response = MASTER_STR)
+        client.run_cmd_master('umount /dev/disk/by-label/testboot')
+        client.run_cmd_master(
+            'mkfs.vfat /dev/disk/by-label/testboot -n testboot')
+        client.run_cmd_master('udevadm trigger')
+        client.run_cmd_master('mkdir -p /mnt/boot')
+        client.run_cmd_master('mount /dev/disk/by-label/testboot /mnt/boot')
+        client.run_cmd_master(
+            'wget -qO- %s |tar --numeric-owner -C /mnt/boot -xzf -' % bootfs)
+        client.run_cmd_master('umount /mnt/boot')
 

=== modified file 'lava_dispatcher/actions/launch_control.py'
--- lava_dispatcher/actions/launch_control.py	2011-09-01 15:52:58 +0000
+++ lava_dispatcher/actions/launch_control.py	2011-09-02 03:24:06 +0000
@@ -22,11 +22,10 @@ 
 
 import json
 import os
-import pexpect
 import shutil
 import tarfile
 from lava_dispatcher.actions import BaseAction
-from lava_dispatcher.config import LAVA_RESULT_DIR, MASTER_STR
+from lava_dispatcher.config import LAVA_RESULT_DIR
 from lava_dispatcher.config import LAVA_IMAGE_TMPDIR
 from lava_dispatcher.client import NetworkError
 from lava_dispatcher.utils import download
@@ -77,29 +76,25 @@ 
         except:
             client.boot_master_image()
 
-        client.run_shell_command(
-            'mkdir -p /mnt/root', response = MASTER_STR)
-        client.run_shell_command(
-            'mount /dev/disk/by-label/%s /mnt/root' % result_disk,
-            response = MASTER_STR)
-        client.run_shell_command(
-            'mkdir -p /tmp/%s' % LAVA_RESULT_DIR, response = MASTER_STR)
-        client.run_shell_command(
+        client.run_cmd_master('mkdir -p /mnt/root')
+        client.run_cmd_master(
+            'mount /dev/disk/by-label/%s /mnt/root' % result_disk)
+        client.run_cmd_master('mkdir -p /tmp/%s' % LAVA_RESULT_DIR)
+        client.run_cmd_master(
             'cp /mnt/root/%s/*.bundle /tmp/%s' % (LAVA_RESULT_DIR,
-                LAVA_RESULT_DIR), response = MASTER_STR)
-        client.run_shell_command('umount /mnt/root', response = MASTER_STR)
+                LAVA_RESULT_DIR))
+        client.run_cmd_master('umount /mnt/root')
 
         #Create tarball of all results
-        client.run_shell_command('cd /tmp', response=MASTER_STR)
-        client.run_shell_command('tar czf /tmp/lava_results.tgz -C /tmp/%s .'
-                % LAVA_RESULT_DIR, response=MASTER_STR)
+        client.run_cmd_master('cd /tmp')
+        client.run_cmd_master(
+            'tar czf /tmp/lava_results.tgz -C /tmp/%s .' % LAVA_RESULT_DIR)
 
         master_ip = client.get_master_ip()
         if master_ip == None:
             raise NetworkError("Getting master image IP address failed")
         # Set 80 as server port
-        client.run_shell_command('python -m SimpleHTTPServer 80 &> /dev/null &',
-                response=MASTER_STR)
+        client.run_cmd_master('python -m SimpleHTTPServer 80 &> /dev/null &')
         time.sleep(3)
 
         result_tarball = "http://%s/lava_results.tgz" % master_ip
@@ -117,7 +112,7 @@ 
                 if time.time() >= now+timeout:
                     raise
 
-        client.run_shell_command('kill %1', response=MASTER_STR)
+        client.run_cmd_master('kill %1')
 
         tar = tarfile.open(result_path)
         for tarinfo in tar:

=== modified file 'lava_dispatcher/actions/lava-test.py'
--- lava_dispatcher/actions/lava-test.py	2011-08-19 01:32:22 +0000
+++ lava_dispatcher/actions/lava-test.py	2011-09-02 03:24:06 +0000
@@ -25,7 +25,7 @@ 
 import traceback
 from lava_dispatcher.actions import BaseAction
 from lava_dispatcher.client import OperationFailed
-from lava_dispatcher.config import LAVA_RESULT_DIR, MASTER_STR, TESTER_STR
+from lava_dispatcher.config import LAVA_RESULT_DIR, MASTER_STR
 
 def _setup_testrootfs(client):
     #Make sure in master image
@@ -35,54 +35,36 @@ 
     except:
         client.boot_master_image()
 
-    client.run_shell_command(
-        'mkdir -p /mnt/root',
-        response=MASTER_STR)
-    client.run_shell_command(
-        'mount /dev/disk/by-label/testrootfs /mnt/root',
-        response=MASTER_STR)
-    client.run_shell_command(
-        'cp -f /mnt/root/etc/resolv.conf /mnt/root/etc/resolv.conf.bak',
-        response=MASTER_STR)
-    client.run_shell_command(
-        'cp -L /etc/resolv.conf /mnt/root/etc',
-        response=MASTER_STR)
+    client.run_cmd_master('mkdir -p /mnt/root')
+    client.run_cmd_master('mount /dev/disk/by-label/testrootfs /mnt/root')
+    client.run_cmd_master(
+        'cp -f /mnt/root/etc/resolv.conf /mnt/root/etc/resolv.conf.bak')
+    client.run_cmd_master('cp -L /etc/resolv.conf /mnt/root/etc')
     #eliminate warning: Can not write log, openpty() failed
     #                   (/dev/pts not mounted?), does not work
-    client.run_shell_command(
-        'mount --rbind /dev /mnt/root/dev',
-        response=MASTER_STR)
+    client.run_cmd_master('mount --rbind /dev /mnt/root/dev')
 
 def _teardown_testrootfs(client):
-    client.run_shell_command(
-        'cp -f /mnt/root/etc/resolv.conf.bak /mnt/root/etc/resolv.conf',
-        response=MASTER_STR)
+    client.run_cmd_master(
+        'cp -f /mnt/root/etc/resolv.conf.bak /mnt/root/etc/resolv.conf')
     cmd = ('cat /proc/mounts | awk \'{print $2}\' | grep "^/mnt/root/dev"'
         '| sort -r | xargs umount')
-    client.run_shell_command(
-        cmd,
-        response=MASTER_STR)
-    client.run_shell_command(
-        'umount /mnt/root',
-        response=MASTER_STR)
+    client.run_cmd_master(
+        cmd)
+    client.run_cmd_master(
+        'umount /mnt/root')
 
 def _install_lava_test(client):
     #install bazaar in tester image
-    client.run_shell_command(
-        'chroot /mnt/root apt-get update',
-        response=MASTER_STR)
+    client.run_cmd_master(
+        'chroot /mnt/root apt-get update')
     #Install necessary packages for build lava-test
     cmd = ('chroot /mnt/root apt-get -y install bzr usbutils python-apt '
         'python-setuptools python-simplejson lsb-release')
-    client.run_shell_command(
-        cmd,
-        response=MASTER_STR, timeout=2400)
-    client.run_shell_command(
-        'chroot /mnt/root bzr branch lp:lava-test',
-        response=MASTER_STR)
-    client.run_shell_command(
-        'chroot /mnt/root sh -c "cd lava-test && python setup.py install"',
-        response=MASTER_STR)
+    client.run_cmd_master(cmd, timeout=2400)
+    client.run_cmd_master('chroot /mnt/root bzr branch lp:lava-test')
+    client.run_cmd_master(
+        'chroot /mnt/root sh -c "cd lava-test && python setup.py install"')
 
     #Test if lava-test installed
     try:
@@ -101,14 +83,13 @@ 
         #Make sure in test image now
         client = self.client
         client.in_test_shell()
-        client.run_shell_command('mkdir -p %s' % LAVA_RESULT_DIR,
-            response=TESTER_STR)
+        client.run_cmd_tester('mkdir -p %s' % LAVA_RESULT_DIR)
         client.export_display()
         bundle_name = test_name + "-" + datetime.now().strftime("%H%M%S")
-        client.run_shell_command(
+        client.run_cmd_tester(
             'lava-test run %s -o %s/%s.bundle' % (
                 test_name, LAVA_RESULT_DIR, bundle_name),
-            response=TESTER_STR, timeout=timeout)
+            timeout=timeout)
 
 
 class cmd_lava_test_install(BaseAction):
@@ -123,19 +104,18 @@ 
 
         if install_python:
             for module in install_python:
-                client.run_shell_command("chroot /mnt/root apt-get -y install python-pip", response=MASTER_STR)
-                client.run_shell_command("chroot /mnt/root pip install -e " + module, response=MASTER_STR)
+                client.run_cmd_master("chroot /mnt/root apt-get -y install python-pip")
+                client.run_cmd_master("chroot /mnt/root pip install -e " + module)
 
         if register:
             for test_def_url in register:
-                client.run_shell_command('chroot /mnt/root lava-test register-test  ' + test_def_url, response=MASTER_STR)
+                client.run_cmd_master('chroot /mnt/root lava-test register-test  ' + test_def_url)
 
         for test in tests:
-            client.run_shell_command(
-                'chroot /mnt/root lava-test install %s' % test,
-                response=MASTER_STR)
+            client.run_cmd_master(
+                'chroot /mnt/root lava-test install %s' % test)
 
-        client.run_shell_command('rm -rf /mnt/root/lava-test', response=MASTER_STR)
+        client.run_cmd_master('rm -rf /mnt/root/lava-test')
 
         _teardown_testrootfs(client)
 
@@ -149,11 +129,11 @@ 
         _setup_testrootfs(client)
         
         #install add-apt-repository
-        client.run_shell_command('chroot /mnt/root apt-get -y install python-software-properties',response=MASTER_STR)
+        client.run_cmd_master('chroot /mnt/root apt-get -y install python-software-properties')
 
         #add ppa
-        client.run_shell_command('chroot /mnt/root add-apt-repository ' + arg[0], response=MASTER_STR)
-        client.run_shell_command('chroot /mnt/root apt-get update', response=MASTER_STR)
+        client.run_cmd_master('chroot /mnt/root add-apt-repository ' + arg[0])
+        client.run_cmd_master('chroot /mnt/root apt-get update')
 
         _teardown_testrootfs(client)
 

=== modified file 'lava_dispatcher/android_client.py'
--- lava_dispatcher/android_client.py	2011-09-02 02:50:19 +0000
+++ lava_dispatcher/android_client.py	2011-09-02 03:27:41 +0000
@@ -108,9 +108,8 @@ 
         # XXX: IP could be assigned in other way in the validation farm
         network_interface = self.board.default_network_interface 
         try:
-            self.run_shell_command('netcfg %s dhcp' % \
-                network_interface, response = TESTER_STR,
-                timeout = 60)
+            self.run_cmd_tester(
+                'netcfg %s dhcp' % network_interface, timeout = 60)
         except:
             print "netcfg %s dhcp exception" % network_interface
             return False

=== modified file 'lava_dispatcher/client.py'
--- lava_dispatcher/client.py	2011-08-31 07:49:52 +0000
+++ lava_dispatcher/client.py	2011-09-02 03:00:59 +0000
@@ -33,6 +33,8 @@ 
 
 class LavaClient(object):
     def __init__(self, hostname):
+        self._master_str = MASTER_STR
+        self._tester_str = TESTER_STR
         cmd = "conmux-console %s" % hostname
         self.sio = SerialIO(sys.stdout)
         self.proc = pexpect.spawn(cmd, timeout=3600, logfile=self.sio)
@@ -42,11 +44,19 @@ 
         # will eventually come from the database
         self.board = BOARDS[hostname]
 
+    @property
+    def master_str(self): 
+        return self._master_str
+    
+    @property
+    def tester_str(self): 
+        return self._tester_str
+    
     def in_master_shell(self):
         """ Check that we are in a shell on the master image
         """
         self.proc.sendline("")
-        id = self.proc.expect([MASTER_STR, pexpect.TIMEOUT])
+        id = self.proc.expect([self.master_str, pexpect.TIMEOUT])
         if id == 1:
             raise OperationFailed
 
@@ -54,7 +64,7 @@ 
         """ Check that we are in a shell on the test image
         """
         self.proc.sendline("")
-        id = self.proc.expect([TESTER_STR, pexpect.TIMEOUT])
+        id = self.proc.expect([self.tester_str, pexpect.TIMEOUT])
         if id == 1:
             raise OperationFailed
 
@@ -109,11 +119,17 @@ 
         if response:
             self.proc.expect(response, timeout=timeout)
 
+    def run_cmd_master(self, cmd, timeout=-1):
+        self.run_shell_command(cmd, self.master_str, timeout)
+
+    def run_cmd_tester(self, cmd, timeout=-1):
+        self.run_shell_command(cmd, self.tester_str, timeout)
+
     def check_network_up(self):
         self.proc.sendline("LC_ALL=C ping -W4 -c1 %s" % LAVA_SERVER_IP)
         id = self.proc.expect(["1 received", "0 received",
             "Network is unreachable"], timeout=5)
-        self.proc.expect(MASTER_STR)
+        self.proc.expect(self.master_str)
         if id == 0:
             return True
         else:
@@ -149,14 +165,12 @@ 
 
     def export_display(self):
         #export the display, ignore errors on non-graphical images
-        self.run_shell_command("su - linaro -c 'DISPLAY=:0 xhost local:'",
-            response=TESTER_STR)
-        self.run_shell_command("export DISPLAY=:0", response=TESTER_STR)
+        self.run_cmd_tester("su - linaro -c 'DISPLAY=:0 xhost local:'")
+        self.run_cmd_tester("export DISPLAY=:0")
 
     def get_seriallog(self):
         return self.sio.getvalue()
 
-
 class SerialIO(file):
     def __init__(self, logfile):
         self.serialio = StringIO()