From patchwork Tue Jun 26 15:52:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Doan X-Patchwork-Id: 9627 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 6C21523EE9 for ; Tue, 26 Jun 2012 15:52:13 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id 205F1A18699 for ; Tue, 26 Jun 2012 15:52:13 +0000 (UTC) Received: by ghbz12 with SMTP id z12so81955ghb.11 for ; Tue, 26 Jun 2012 08:52:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :content-type:mime-version:x-launchpad-project:x-launchpad-branch :x-launchpad-message-rationale:x-launchpad-branch-revision-number :x-launchpad-notification-type:to:from:subject:message-id:date :reply-to:sender:errors-to:precedence:x-generated-by :x-launchpad-hash:x-gm-message-state; bh=/r1t7MrmyfFN2XhcYUUiAxlKNQs6/WgiRN+eloUBp3Q=; b=Cma1g7TNuuEfCceW0IXJJyJKzPX+BMLJTKP/HJnF4ekUzJYvH6n5wF01lLmGpjEJZa rutXHMcClq4wMEhM99OxJGts0N9BZJW+mJLM9OXSq5qXltLKbnazzrjrJ+CAAPR2a25d 7MASOdyiwu7qswSalBzikLdzJgqw5r9/BgF2kmFGnUvY/cXigJOJ0JH0s8FY2EwDMJTQ 80t6RJP9wD67rZIZYkDG7gvS6txZJAc5QA648xRmsN8Wv5sqKtsm+GrBCFxNqtwyGqDK dte1bIM2QXhhC+CsVFu/B++uMkqE6kQ0j7n2C5Pzx9+OBjP0zqi+rpSGeQA89o5XOr71 cZOA== Received: by 10.50.57.167 with SMTP id j7mr11604332igq.53.1340725932422; Tue, 26 Jun 2012 08:52:12 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp81778ibb; Tue, 26 Jun 2012 08:52:11 -0700 (PDT) Received: by 10.181.11.137 with SMTP id ei9mr33771876wid.21.1340725930665; Tue, 26 Jun 2012 08:52:10 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id p2si4897862wiw.5.2012.06.26.08.52.10 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 26 Jun 2012 08:52:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1SjY3m-0006vP-4H for ; Tue, 26 Jun 2012 15:52:10 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 156A8E0020 for ; Tue, 26 Jun 2012 15:52:10 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-dispatcher X-Launchpad-Branch: ~linaro-validation/lava-dispatcher/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 333 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dispatcher/trunk] Rev 333: support linaro-android-media-create in fastmodel client Message-Id: <20120626155210.22321.6066.launchpad@ackee.canonical.com> Date: Tue, 26 Jun 2012 15:52:10 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="15482"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 41c80f6e84fe0532b3e12f40a27c2e8d3e1a4b12 X-Gm-Message-State: ALoCoQlbBTL1z7tRa/djHakW/gKAHSN/WKbI5lxmEj7XCXGnqRNk8Y1p1LhAQMJY1CoME208mnst Merge authors: Andy Doan (doanac) Related merge proposals: https://code.launchpad.net/~doanac/lava-dispatcher/linaro-android-media-create/+merge/111998 proposed by: Andy Doan (doanac) ------------------------------------------------------------ revno: 333 [merge] committer: Andy Doan branch nick: lava-dispatcher timestamp: Tue 2012-06-26 10:50:46 -0500 message: support linaro-android-media-create in fastmodel client modified: lava_dispatcher/actions/android_deploy.py lava_dispatcher/client/fastmodel.py lava_dispatcher/client/lmc_utils.py lava_dispatcher/downloader.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 === modified file 'lava_dispatcher/actions/android_deploy.py' --- lava_dispatcher/actions/android_deploy.py 2012-06-15 20:36:11 +0000 +++ lava_dispatcher/actions/android_deploy.py 2012-06-25 21:36:11 +0000 @@ -20,6 +20,7 @@ # along with this program; if not, see . from lava_dispatcher.actions import BaseAction +from lava_dispatcher.client.fastmodel import LavaFastModelClient from lava_dispatcher.client.master import LavaMasterImageClient @@ -39,6 +40,7 @@ } def run(self, boot, system, data, pkg=None, use_cache=True, rootfstype='ext4'): - if not isinstance(self.client, LavaMasterImageClient): + if not isinstance(self.client, LavaMasterImageClient) and \ + not isinstance(self.client, LavaFastModelClient): raise RuntimeError("Invalid LavaClient for this action") self.client.deploy_linaro_android(boot, system, data, pkg, use_cache, rootfstype) === modified file 'lava_dispatcher/client/fastmodel.py' --- lava_dispatcher/client/fastmodel.py 2012-06-22 16:18:50 +0000 +++ lava_dispatcher/client/fastmodel.py 2012-06-25 21:36:11 +0000 @@ -23,6 +23,7 @@ import logging import os import pexpect +import shutil import threading from lava_dispatcher.client.base import ( @@ -31,6 +32,7 @@ ) from lava_dispatcher.client.lmc_utils import ( image_partition_mounted, + generate_android_image, get_partition_offset, ) from lava_dispatcher.downloader import ( @@ -91,6 +93,28 @@ else: self._customize_ubuntu() + def deploy_linaro_android(self, boot, system, data, pkg=None, + use_cache=True, rootfstype='ext4'): + logging.info("Deploying Android on %s" % self.hostname) + + self._boot = download_image(boot, self.context, decompress=False) + self._data = download_image(data, self.context, decompress=False) + self._system = download_image(system, self.context, decompress=False) + + self._sd_image = '%s/android.img' % os.path.dirname(self._system) + + 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._customize_android() + def _close_sim_proc(self): self._sim_proc.close(True) === modified file 'lava_dispatcher/client/lmc_utils.py' --- lava_dispatcher/client/lmc_utils.py 2012-04-10 15:29:26 +0000 +++ lava_dispatcher/client/lmc_utils.py 2012-06-26 03:59:26 +0000 @@ -115,6 +115,14 @@ raise return image_file +def generate_android_image(device, boot, data, system, ofile, size="2000M"): + cmd = ("flock /var/lock/lava-lmc.lck sudo linaro-android-media-create " + "--dev %s --image_file %s --image_size %s " + "--boot %s --userdata %s --system %s" % + (device, ofile, size, boot, data,system) ) + logging.info("Generating android image with: %s" % cmd) + _run_linaro_media_create(cmd) + def get_partition_offset(image, partno): cmd = 'parted %s -m -s unit b print' % image part_data = getoutput(cmd) === modified file 'lava_dispatcher/downloader.py' --- lava_dispatcher/downloader.py 2012-06-15 20:35:05 +0000 +++ lava_dispatcher/downloader.py 2012-06-25 20:45:16 +0000 @@ -75,15 +75,15 @@ fd.close() @contextlib.contextmanager -def _decompressor_stream(url, imgdir): +def _decompressor_stream(url, imgdir, decompress): fd = None decompressor = None fname,suffix = _url_to_fname_suffix(url, imgdir) - if suffix == 'gz': + if suffix == 'gz' and decompress: decompressor = zlib.decompressobj(16+zlib.MAX_WBITS) - elif suffix == 'bz2': + elif suffix == 'bz2' and decompress: decompressor = bz2.BZ2Decompressor() else: fname = '%s.%s' % (fname, suffix) #don't remove the file's real suffix @@ -107,9 +107,10 @@ filename = os.path.join(path, '.'.join(parts[:-1])) return (filename, suffix) -def download_image(url, context, imgdir=None, delete_on_exit=True): +def download_image(url, context, imgdir=None, + delete_on_exit=True, decompress=True): '''downloads a image that's been compressed as .bz2 or .gz and - decompresses it on the file to the cache directory + optionally decompresses it on the file to the cache directory ''' logging.info("Downloading image: %s" % url) if not imgdir: @@ -129,7 +130,7 @@ raise Exception("Unsupported url protocol scheme: %s" % url.scheme) with reader(url, context.lava_proxy, context.lava_cookies) as r: - with _decompressor_stream(url, imgdir) as (writer, fname): + with _decompressor_stream(url, imgdir, decompress) as (writer, fname): bsize = 32768 buff = r.read(bsize) while buff: