Merge lp:~tyler-baker/lava-dispatcher/capri-updates into lp:lava-dispatcher

Proposed by Tyler Baker
Status: Merged
Merged at revision: 684
Proposed branch: lp:~tyler-baker/lava-dispatcher/capri-updates
Merge into: lp:lava-dispatcher
Diff against target: 128 lines (+81/-13)
1 file modified
lava_dispatcher/device/capri.py (+81/-13)
To merge this branch: bzr merge lp:~tyler-baker/lava-dispatcher/capri-updates
Reviewer Review Type Date Requested Status
Antonio Terceiro Approve
Review via email: mp+185489@code.launchpad.net

Description of the change

The plan is to use a gether bridge rather than ADB. So i've implemented the code to reflect these platform changes.

Code has been testing on community.validation.linaro.org:

http://community.validation.linaro.org/scheduler/job/1185

To post a comment you must log in.
Revision history for this message
Antonio Terceiro (terceiro) wrote :

Looks good.

At some point we got to unify all this target-side httpd crap though ... but not now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lava_dispatcher/device/capri.py'
--- lava_dispatcher/device/capri.py 2013-08-28 14:55:50 +0000
+++ lava_dispatcher/device/capri.py 2013-09-13 13:20:44 +0000
@@ -19,9 +19,17 @@
19# with this program; if not, see <http://www.gnu.org/licenses>.19# with this program; if not, see <http://www.gnu.org/licenses>.
2020
21import logging21import logging
22import contextlib
23import time
24import os
25import pexpect
26
22from lava_dispatcher.device.target import (27from lava_dispatcher.device.target import (
23 Target28 Target
24)29)
30from lava_dispatcher.client.base import (
31 NetworkCommandRunner,
32)
25from lava_dispatcher.errors import (33from lava_dispatcher.errors import (
26 CriticalError,34 CriticalError,
27)35)
@@ -31,6 +39,13 @@
31from lava_dispatcher.device.master import (39from lava_dispatcher.device.master import (
32 MasterImageTarget40 MasterImageTarget
33)41)
42from lava_dispatcher.utils import (
43 mk_targz,
44 rmtree,
45)
46from lava_dispatcher.downloader import (
47 download_with_retry,
48)
3449
3550
36class CapriTarget(FastbootTarget, MasterImageTarget):51class CapriTarget(FastbootTarget, MasterImageTarget):
@@ -62,26 +77,79 @@
62 self.fastboot.flash('system', system)77 self.fastboot.flash('system', system)
63 self.fastboot.flash('userdata', userdata)78 self.fastboot.flash('userdata', userdata)
6479
65 self.deployment_data = Target.android_deployment_data80 self.deployment_data = Target.ubuntu_deployment_data
66 self.deployment_data['boot_image'] = boot81 self.deployment_data['boot_image'] = boot
6782
68 def power_on(self):83 def power_on(self):
69 if not self.deployment_data.get('boot_image', False):84 if not self.deployment_data.get('boot_image', False):
70 raise CriticalError('Deploy action must be run first')85 raise CriticalError('Deploy action must be run first')
7186
72 self._enter_fastboot()87 if not self._booted:
73 self.fastboot('reboot')88 self._enter_fastboot()
74 self.proc.expect(self.context.device_config.master_str,89 self.fastboot('reboot')
75 timeout=300)90 self._wait_for_prompt(self.proc,
7691 self.context.device_config.master_str,
77 # The capri does not yet have adb support, so we do not wait for adb.92 self.config.boot_linaro_timeout)
78 #self._adb('wait-for-device')93
7994 self._booted = True
80 self._booted = True95 self.proc.sendline('')
81 self.proc.sendline("") # required to put the adb shell in a reasonable state96 self.proc.sendline('')
82 self.proc.sendline("export PS1='%s'" % self.deployment_data['TESTER_PS1'])97 self.proc.sendline('export PS1="%s"' % self.deployment_data['TESTER_PS1'])
83 self._runner = self._get_runner(self.proc)98 self._runner = self._get_runner(self.proc)
8499
85 return self.proc100 return self.proc
86101
102 @contextlib.contextmanager
103 def file_system(self, partition, directory):
104 try:
105 pat = self.deployment_data['TESTER_PS1_PATTERN']
106 incrc = self.deployment_data['TESTER_PS1_INCLUDES_RC']
107 runner = NetworkCommandRunner(self, pat, incrc)
108
109 targetdir = '/%s' % directory
110 runner.run('mkdir -p %s' % targetdir)
111 parent_dir, target_name = os.path.split(targetdir)
112 runner.run('/bin/tar -cmzf /tmp/fs.tgz -C %s %s'
113 % (parent_dir, target_name))
114 runner.run('cd /tmp') # need to be in same dir as fs.tgz
115
116 ip = runner.get_target_ip()
117
118 self.proc.sendline('python -m SimpleHTTPServer 0 2>/dev/null')
119 match_id = self.proc.expect([
120 'Serving HTTP on 0.0.0.0 port (\d+) \.\.',
121 pexpect.EOF, pexpect.TIMEOUT])
122 if match_id != 0:
123 msg = "Unable to start HTTP server on Capri"
124 logging.error(msg)
125 raise CriticalError(msg)
126 port = self.proc.match.groups()[match_id]
127
128 url = "http://%s:%s/fs.tgz" % (ip, port)
129
130 logging.info("Fetching url: %s" % url)
131 tf = download_with_retry(self.context, self.scratch_dir,
132 url, False)
133
134 tfdir = os.path.join(self.scratch_dir, str(time.time()))
135
136 try:
137 os.mkdir(tfdir)
138 self.context.run_command('/bin/tar -C %s -xzf %s'
139 % (tfdir, tf))
140 yield os.path.join(tfdir, target_name)
141 finally:
142 tf = os.path.join(self.scratch_dir, 'fs.tgz')
143 mk_targz(tf, tfdir)
144 rmtree(tfdir)
145
146 self.proc.sendcontrol('c') # kill SimpleHTTPServer
147
148 # get the last 2 parts of tf, ie "scratchdir/tf.tgz"
149 tf = '/'.join(tf.split('/')[-2:])
150 runner.run('rm -rf %s' % targetdir)
151 self._target_extract(runner, tf, parent_dir)
152 finally:
153 self.proc.sendcontrol('c') # kill SimpleHTTPServer
154
87target_class = CapriTarget155target_class = CapriTarget

Subscribers

People subscribed via source and target branches