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

Proposed by Tyler Baker on 2013-09-13
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 2013-09-13 Approve on 2013-09-13
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.
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
1=== modified file 'lava_dispatcher/device/capri.py'
2--- lava_dispatcher/device/capri.py 2013-08-28 14:55:50 +0000
3+++ lava_dispatcher/device/capri.py 2013-09-13 13:20:44 +0000
4@@ -19,9 +19,17 @@
5 # with this program; if not, see <http://www.gnu.org/licenses>.
6
7 import logging
8+import contextlib
9+import time
10+import os
11+import pexpect
12+
13 from lava_dispatcher.device.target import (
14 Target
15 )
16+from lava_dispatcher.client.base import (
17+ NetworkCommandRunner,
18+)
19 from lava_dispatcher.errors import (
20 CriticalError,
21 )
22@@ -31,6 +39,13 @@
23 from lava_dispatcher.device.master import (
24 MasterImageTarget
25 )
26+from lava_dispatcher.utils import (
27+ mk_targz,
28+ rmtree,
29+)
30+from lava_dispatcher.downloader import (
31+ download_with_retry,
32+)
33
34
35 class CapriTarget(FastbootTarget, MasterImageTarget):
36@@ -62,26 +77,79 @@
37 self.fastboot.flash('system', system)
38 self.fastboot.flash('userdata', userdata)
39
40- self.deployment_data = Target.android_deployment_data
41+ self.deployment_data = Target.ubuntu_deployment_data
42 self.deployment_data['boot_image'] = boot
43
44 def power_on(self):
45 if not self.deployment_data.get('boot_image', False):
46 raise CriticalError('Deploy action must be run first')
47
48- self._enter_fastboot()
49- self.fastboot('reboot')
50- self.proc.expect(self.context.device_config.master_str,
51- timeout=300)
52-
53- # The capri does not yet have adb support, so we do not wait for adb.
54- #self._adb('wait-for-device')
55-
56- self._booted = True
57- self.proc.sendline("") # required to put the adb shell in a reasonable state
58- self.proc.sendline("export PS1='%s'" % self.deployment_data['TESTER_PS1'])
59- self._runner = self._get_runner(self.proc)
60+ if not self._booted:
61+ self._enter_fastboot()
62+ self.fastboot('reboot')
63+ self._wait_for_prompt(self.proc,
64+ self.context.device_config.master_str,
65+ self.config.boot_linaro_timeout)
66+
67+ self._booted = True
68+ self.proc.sendline('')
69+ self.proc.sendline('')
70+ self.proc.sendline('export PS1="%s"' % self.deployment_data['TESTER_PS1'])
71+ self._runner = self._get_runner(self.proc)
72
73 return self.proc
74
75+ @contextlib.contextmanager
76+ def file_system(self, partition, directory):
77+ try:
78+ pat = self.deployment_data['TESTER_PS1_PATTERN']
79+ incrc = self.deployment_data['TESTER_PS1_INCLUDES_RC']
80+ runner = NetworkCommandRunner(self, pat, incrc)
81+
82+ targetdir = '/%s' % directory
83+ runner.run('mkdir -p %s' % targetdir)
84+ parent_dir, target_name = os.path.split(targetdir)
85+ runner.run('/bin/tar -cmzf /tmp/fs.tgz -C %s %s'
86+ % (parent_dir, target_name))
87+ runner.run('cd /tmp') # need to be in same dir as fs.tgz
88+
89+ ip = runner.get_target_ip()
90+
91+ self.proc.sendline('python -m SimpleHTTPServer 0 2>/dev/null')
92+ match_id = self.proc.expect([
93+ 'Serving HTTP on 0.0.0.0 port (\d+) \.\.',
94+ pexpect.EOF, pexpect.TIMEOUT])
95+ if match_id != 0:
96+ msg = "Unable to start HTTP server on Capri"
97+ logging.error(msg)
98+ raise CriticalError(msg)
99+ port = self.proc.match.groups()[match_id]
100+
101+ url = "http://%s:%s/fs.tgz" % (ip, port)
102+
103+ logging.info("Fetching url: %s" % url)
104+ tf = download_with_retry(self.context, self.scratch_dir,
105+ url, False)
106+
107+ tfdir = os.path.join(self.scratch_dir, str(time.time()))
108+
109+ try:
110+ os.mkdir(tfdir)
111+ self.context.run_command('/bin/tar -C %s -xzf %s'
112+ % (tfdir, tf))
113+ yield os.path.join(tfdir, target_name)
114+ finally:
115+ tf = os.path.join(self.scratch_dir, 'fs.tgz')
116+ mk_targz(tf, tfdir)
117+ rmtree(tfdir)
118+
119+ self.proc.sendcontrol('c') # kill SimpleHTTPServer
120+
121+ # get the last 2 parts of tf, ie "scratchdir/tf.tgz"
122+ tf = '/'.join(tf.split('/')[-2:])
123+ runner.run('rm -rf %s' % targetdir)
124+ self._target_extract(runner, tf, parent_dir)
125+ finally:
126+ self.proc.sendcontrol('c') # kill SimpleHTTPServer
127+
128 target_class = CapriTarget

Subscribers

People subscribed via source and target branches