diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 359: fastmodel-ubuntu-support

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

Commit Message

Andy Doan July 27, 2012, 3:40 p.m. UTC
Merge authors:
  Andy Doan (doanac)
Related merge proposals:
  https://code.launchpad.net/~doanac/lava-dispatcher/fastmodel-ubuntu-support/+merge/116397
  proposed by: Andy Doan (doanac)
  review: Approve - Spring Zhang (qzhang)
------------------------------------------------------------
revno: 359 [merge]
committer: Andy Doan <andy.doan@linaro.org>
branch nick: lava-dispatcher
timestamp: Fri 2012-07-27 10:38:56 -0500
message:
  fastmodel-ubuntu-support
modified:
  lava_dispatcher/actions/deploy.py
  lava_dispatcher/actions/launch_control.py
  lava_dispatcher/actions/lava-test.py
  lava_dispatcher/client/fastmodel.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	2012-07-06 01:43:50 +0000
+++ lava_dispatcher/actions/deploy.py	2012-07-24 03:56:32 +0000
@@ -18,6 +18,7 @@ 
 # along with this program; if not, see <http://www.gnu.org/licenses>.
 
 from lava_dispatcher.actions import BaseAction
+from lava_dispatcher.client.fastmodel import LavaFastModelClient
 from lava_dispatcher.client.master import LavaMasterImageClient
 from lava_dispatcher.client.qemu import LavaQEMUClient
 
@@ -78,7 +79,8 @@ 
     def run(self, hwpack=None, rootfs=None, image=None, kernel_matrix=None,
             rootfstype='ext3'):
         if not isinstance(self.client, LavaMasterImageClient) and \
-            not isinstance(self.client, LavaQEMUClient):
+            not isinstance(self.client, LavaQEMUClient) and \
+            not isinstance(self.client, LavaFastModelClient):
                 raise RuntimeError("Invalid LavaClient for this action")
 
         self.client.deploy_linaro(

=== modified file 'lava_dispatcher/actions/launch_control.py'
--- lava_dispatcher/actions/launch_control.py	2012-06-22 01:25:13 +0000
+++ lava_dispatcher/actions/launch_control.py	2012-07-24 04:01:01 +0000
@@ -113,8 +113,6 @@ 
                     status = 'fail'
                     err_msg = err_msg + " Some test case result appending failed."
                     logging.warning(err_msg)
-                finally:
-                    shutil.rmtree(os.path.dirname(result_path))
         except:
             logging.exception('retrieve_results failed')
         return device_bundles, status, err_msg

=== modified file 'lava_dispatcher/actions/lava-test.py'
--- lava_dispatcher/actions/lava-test.py	2012-07-19 02:59:59 +0000
+++ lava_dispatcher/actions/lava-test.py	2012-07-24 04:00:12 +0000
@@ -120,6 +120,7 @@ 
                 'type': 'array', 'items': {'type': 'string'}, 'optional': True
                 },
             'timeout': {'type': 'integer', 'optional': True},
+            'install_lava_test': {'type': 'boolean', 'optional': True, 'default': True}
             },
         'additionalProperties': False,
         }
@@ -133,7 +134,8 @@ 
         else:
             self.context.test_data.add_result(test_result_name, 'pass')
 
-    def run(self, tests, install_python=None, install_deb=None, register=None, timeout=2400):
+    def run(self, tests, install_python=None, install_deb=None, register=None,
+            timeout=2400, install_lava_test=True):
         logging.info(
             "Executing lava_test_install (%s) command" % ",".join(tests))
 
@@ -148,7 +150,8 @@ 
                 # just ignore it
                 session.run("rm -f /etc/apt/apt.conf.d/30proxy")
 
-            _install_lava_test(self.client, session)
+            if install_lava_test:
+                _install_lava_test(self.client, session)
 
             if install_python:
                 for module in install_python:

=== modified file 'lava_dispatcher/client/fastmodel.py'
--- lava_dispatcher/client/fastmodel.py	2012-07-23 10:42:59 +0000
+++ lava_dispatcher/client/fastmodel.py	2012-07-24 03:59:15 +0000
@@ -34,6 +34,7 @@ 
 from lava_dispatcher.client.lmc_utils import (
     image_partition_mounted,
     generate_android_image,
+    generate_fastmodel_image,
     get_partition_offset,
     )
 from lava_dispatcher.downloader import (
@@ -104,6 +105,13 @@ 
         else:
             self._customize_ubuntu()
 
+    def _copy_axf(self, partno, fname):
+        with image_partition_mounted(self._sd_image, partno) as mntdir:
+            src = '%s/%s' % (mntdir,fname)
+            odir = os.path.dirname(self._sd_image)
+            self._axf = '%s/%s' % (odir, os.path.split(src)[1])
+            shutil.copyfile(src, self._axf)
+
     def deploy_linaro_android(self, boot, system, data, pkg=None,
                                 rootfstype='ext4'):
         logging.info("Deploying Android on %s" % self.hostname)
@@ -117,15 +125,34 @@ 
         generate_android_image(
             'vexpress-a9', self._boot, self._data, self._system, self._sd_image)
 
-        # now grab the axf file from the boot partition
-        with image_partition_mounted(self._sd_image, self.boot_part) as mntdir:
-            src = '%s/linux-system-ISW.axf' % mntdir
-            self._axf = \
-                '%s/%s' % (os.path.dirname(self._system), os.path.split(src)[1])
-            shutil.copyfile(src, self._axf)
+        self._copy_axf(self.boot_part, 'linux-system-ISW.axf')
 
         self._customize_android()
 
+    def deploy_linaro(self, hwpack=None, rootfs=None, image=None,
+                      kernel_matrix=None, rootfstype='ext3'):
+        if image is None:
+            if hwpack is None or rootfs is None:
+                raise CriticalError(
+                    "must specify both hwpack and rootfs when not specifying image")
+        elif hwpack is not None or rootfs is not None:
+            raise CriticalError(
+                    "cannot specify hwpack or rootfs when specifying image")
+
+        if image is None:
+            hwpack = download_image(hwpack, self.context, decompress=False)
+            rootfs = download_image(rootfs, self.context, decompress=False)
+            odir = os.path.dirname(rootfs)
+
+            generate_fastmodel_image(hwpack, rootfs, odir)
+            self._sd_image = '%s/sd.img' % odir
+            self._axf = '%s/img.axf' % odir
+        else:
+            self._sd_image = download_image(image, self.context)
+            self._copy_axf(self.root_part, 'boot/img.axf')
+
+        self._customize_ubuntu()
+
     def _close_sim_proc(self):
         self._sim_proc.close(True)
 
@@ -143,6 +170,11 @@ 
         os.chmod(self._sd_image, stat.S_IRWXG|stat.S_IRWXU)
         os.chmod(self._axf, stat.S_IRWXG|stat.S_IRWXU)
 
+        #lmc ignores the parent directories group owner
+        st = os.stat(d)
+        os.chown(self._axf, st.st_uid, st.st_gid)
+        os.chown(self._sd_image, st.st_uid, st.st_gid)
+
     def _get_sim_cmd(self):
         return ("%s -a coretile.cluster0.*=%s "
             "-C motherboard.smsc_91c111.enabled=1 "
@@ -153,12 +185,15 @@ 
             "-C motherboard.hostbridge.userNetPorts='5555=5555'") % (
             self._sim_binary, self._axf, self._sd_image)
 
-    def _boot_linaro_image(self):
+    def _stop(self):
         if self.proc is not None:
             self.proc.close()
         if self._sim_proc is not None:
             self._sim_proc.close()
 
+    def _boot_linaro_image(self):
+        self._stop()
+
         self._fix_perms()
         sim_cmd = self._get_sim_cmd()
 
@@ -195,6 +230,17 @@ 
     def reliable_session(self):
         return self.tester_session()
 
+    def retrieve_results(self, result_disk):
+        self._stop()
+
+        tardir = os.path.dirname(self._sd_image)
+        tarfile = os.path.join(tardir, 'lava_results.tgz')
+        with image_partition_mounted(self._sd_image, self.root_part) as mnt:
+            logging_system(
+                'tar czf %s -C %s%s .' % (
+                    tarfile, mnt, self.context.lava_result_dir))
+        return 'pass', '', tarfile
+
 class _pexpect_drain(threading.Thread):
     ''' The simulator process can dump a lot of information to its console. If
     don't actively read from it, the pipe will get full and the process will