Merge lp:~david-schwarz/lava-dispatcher/ssh_qemu_clients_v3 into lp:lava-dispatcher
- ssh_qemu_clients_v3
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 105 |
Proposed branch: | lp:~david-schwarz/lava-dispatcher/ssh_qemu_clients_v3 |
Merge into: | lp:lava-dispatcher |
Diff against target: |
1169 lines (+538/-255) (has conflicts) 20 files modified
config/hosts/localhost.json (+5/-0) config/hosts/qemu1.json (+11/-0) config/hosts/qemu2.json (+11/-0) config/hosts/vs3.json (+6/-0) config/hosts/vs8.json (+6/-0) doc/qemu-ltp-job.json (+41/-0) doc/ssh-ltp-job.json (+23/-0) lava_dispatcher/__init__.py (+43/-14) lava_dispatcher/actions/android_basic.py (+0/-1) lava_dispatcher/actions/android_deploy.py (+55/-123) lava_dispatcher/actions/deploy.py (+20/-41) lava_dispatcher/actions/launch_control.py (+14/-21) lava_dispatcher/actions/lava-test.py (+21/-45) lava_dispatcher/android_client.py (+3/-3) lava_dispatcher/client.py (+21/-7) lava_dispatcher/config.py (+10/-0) lava_dispatcher/qemu_client.py (+135/-0) lava_dispatcher/qemu_config.py (+20/-0) lava_dispatcher/ssh_client.py (+75/-0) lava_dispatcher/ssh_config.py (+18/-0) Text conflict in lava_dispatcher/__init__.py |
To merge this branch: | bzr merge lp:~david-schwarz/lava-dispatcher/ssh_qemu_clients_v3 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Linaro Validation Team | Pending | ||
Review via email: mp+70892@code.launchpad.net |
Commit message
Description of the change
This is a cleaner version of the ssh_qemu_clients feature branch--the older version was uploaded by mistake.
Paul Larson (pwlars) wrote : | # |
David Schwarz (david-schwarz) wrote : | # |
I agree that the machine config rather than job should specify the
client type--particularly because it's entirely possible in our testing
that we may have a mix of different client types in a single
multi-target test job.
I was thinking of splitting the board and machine configs into separate
groups of files to help cut down duplication of common settings.
Machine config (currently in config/hosts in this branch) would include
any machine-specific configuration, including its board type:
panda01.conf:
[machine]
client_type = ssh
hostname = panda01
# References a board-specific config file
board_type = PandaBoard
ip_addr = 192.168.1.1
username = test1
password = test1
has_feature_x = yes
...then the board configuration file could include the information
common to all machines of a particular type, currently being stored in
the config.py Board classes:
PandaBoard.conf
[board]
uboot_cmds = yadda yadda
boot_part = 1
test_part = 2
David
David Schwarz (david-schwarz) wrote : | # |
Rereading, I believe we're proposing the same thing.
David
On 08/09/2011 04:46 PM, Paul Larson wrote:
> As discussed offline, I'd like to see about merging this with what Yongqin has been working on (https:/
>
> I think what we really want, is a directory containing config details for specific board types:
> - bootloader commands to send for booting to the test image
> - partition offsets
> - possibly even client type specific sections
>
> and a config file listing the boards you have in your environment, and which board_type config to use, along with any specific information, or overrides for that individual system.
Paul Larson (pwlars) wrote : | # |
Yep, exactly :)
Preview Diff
1 | === added directory 'config' | |||
2 | === added directory 'config/hosts' | |||
3 | === added file 'config/hosts/localhost.json' | |||
4 | --- config/hosts/localhost.json 1970-01-01 00:00:00 +0000 | |||
5 | +++ config/hosts/localhost.json 2011-08-09 14:40:36 +0000 | |||
6 | @@ -0,0 +1,5 @@ | |||
7 | 1 | { | ||
8 | 2 | "board_name": "localhost", | ||
9 | 3 | "board_type": "BeagleBoard", | ||
10 | 4 | "hostname": "localhost" | ||
11 | 5 | } | ||
12 | 0 | 6 | ||
13 | === added file 'config/hosts/qemu1.json' | |||
14 | --- config/hosts/qemu1.json 1970-01-01 00:00:00 +0000 | |||
15 | +++ config/hosts/qemu1.json 2011-08-09 14:40:36 +0000 | |||
16 | @@ -0,0 +1,11 @@ | |||
17 | 1 | { | ||
18 | 2 | "board_name": "qemu1", | ||
19 | 3 | "board_type": "BeagleBoard", | ||
20 | 4 | "hostname": "qemu1", | ||
21 | 5 | "machine_type": "beagle", | ||
22 | 6 | "qemu_macaddr": "52:54:00:12:34:56", | ||
23 | 7 | "qemu_disk": "qemu/linaroDiskMaster", | ||
24 | 8 | "vlan_number": 0, | ||
25 | 9 | "boot_image": "qemu/startup.bin", | ||
26 | 10 | "additional_options": "-nographic -no-reboot " | ||
27 | 11 | } | ||
28 | 0 | 12 | ||
29 | === added file 'config/hosts/qemu2.json' | |||
30 | --- config/hosts/qemu2.json 1970-01-01 00:00:00 +0000 | |||
31 | +++ config/hosts/qemu2.json 2011-08-09 14:40:36 +0000 | |||
32 | @@ -0,0 +1,11 @@ | |||
33 | 1 | { | ||
34 | 2 | "board_name": "qemu2", | ||
35 | 3 | "board_type": "BeagleBoard", | ||
36 | 4 | "hostname": "qemu2", | ||
37 | 5 | "machine_type": "beagle", | ||
38 | 6 | "qemu_macaddr": "12:34:56:78:90:12", | ||
39 | 7 | "qemu_disk": "qemu/linaroDiskMaster", | ||
40 | 8 | "vlan_number": 0, | ||
41 | 9 | "boot_image": "qemu/startup.bin", | ||
42 | 10 | "additional_options": "-nographic -no-reboot " | ||
43 | 11 | } | ||
44 | 0 | 12 | ||
45 | === added file 'config/hosts/vs3.json' | |||
46 | --- config/hosts/vs3.json 1970-01-01 00:00:00 +0000 | |||
47 | +++ config/hosts/vs3.json 2011-08-09 14:40:36 +0000 | |||
48 | @@ -0,0 +1,6 @@ | |||
49 | 1 | { | ||
50 | 2 | "board_name": "vs3", | ||
51 | 3 | "hostname": "vs3", | ||
52 | 4 | "username": "test", | ||
53 | 5 | "password": "test" | ||
54 | 6 | } | ||
55 | 0 | 7 | ||
56 | === added file 'config/hosts/vs8.json' | |||
57 | --- config/hosts/vs8.json 1970-01-01 00:00:00 +0000 | |||
58 | +++ config/hosts/vs8.json 2011-08-09 14:40:36 +0000 | |||
59 | @@ -0,0 +1,6 @@ | |||
60 | 1 | { | ||
61 | 2 | "board_name": "vs8", | ||
62 | 3 | "hostname": "vs8", | ||
63 | 4 | "username": "test", | ||
64 | 5 | "password": "test" | ||
65 | 6 | } | ||
66 | 0 | 7 | ||
67 | === added file 'doc/qemu-ltp-job.json' | |||
68 | --- doc/qemu-ltp-job.json 1970-01-01 00:00:00 +0000 | |||
69 | +++ doc/qemu-ltp-job.json 2011-08-09 14:40:36 +0000 | |||
70 | @@ -0,0 +1,41 @@ | |||
71 | 1 | { | ||
72 | 2 | "job_name": "qemu_ltp", | ||
73 | 3 | "target": "qemu1", | ||
74 | 4 | "target_type": "qemu", | ||
75 | 5 | "timeout": 18000, | ||
76 | 6 | "actions": [ | ||
77 | 7 | { | ||
78 | 8 | "command": "deploy_linaro_image", | ||
79 | 9 | "parameters": | ||
80 | 10 | { | ||
81 | 11 | "rootfs": "http://snapshots.linaro.org/11.05-daily/linaro-developer/20110208/0/images/tar/linaro-n-developer-tar-20110208-0.tar.gz", | ||
82 | 12 | "hwpack": "http://snapshots.linaro.org/11.05-daily/linaro-hwpacks/panda/20110208/0/images/hwpack/hwpack_linaro-panda_20110208-0_armel_supported.tar.gz" | ||
83 | 13 | } | ||
84 | 14 | }, | ||
85 | 15 | { | ||
86 | 16 | "command": "lava_test_install", | ||
87 | 17 | "parameters": | ||
88 | 18 | { | ||
89 | 19 | "tests": ["ltp"] | ||
90 | 20 | } | ||
91 | 21 | }, | ||
92 | 22 | { | ||
93 | 23 | "command": "boot_linaro_image" | ||
94 | 24 | }, | ||
95 | 25 | { | ||
96 | 26 | "command": "lava_test_run", | ||
97 | 27 | "parameters": | ||
98 | 28 | { | ||
99 | 29 | "test_name": "ltp" | ||
100 | 30 | } | ||
101 | 31 | }, | ||
102 | 32 | { | ||
103 | 33 | "command": "submit_results", | ||
104 | 34 | "parameters": | ||
105 | 35 | { | ||
106 | 36 | "server": "http://validation.linaro.org/launch-control", | ||
107 | 37 | "stream": "/anonymous/panda01-ltp/" | ||
108 | 38 | } | ||
109 | 39 | } | ||
110 | 40 | ] | ||
111 | 41 | } | ||
112 | 0 | 42 | ||
113 | === added file 'doc/ssh-ltp-job.json' | |||
114 | --- doc/ssh-ltp-job.json 1970-01-01 00:00:00 +0000 | |||
115 | +++ doc/ssh-ltp-job.json 2011-08-09 14:40:36 +0000 | |||
116 | @@ -0,0 +1,23 @@ | |||
117 | 1 | { | ||
118 | 2 | "job_name": "ssh_ltp", | ||
119 | 3 | "target": "vs3", | ||
120 | 4 | "target_type": "ssh", | ||
121 | 5 | "timeout": 18000, | ||
122 | 6 | "actions": [ | ||
123 | 7 | { | ||
124 | 8 | "command": "lava_test_run", | ||
125 | 9 | "parameters": | ||
126 | 10 | { | ||
127 | 11 | "test_name": "ltp" | ||
128 | 12 | } | ||
129 | 13 | }, | ||
130 | 14 | { | ||
131 | 15 | "command": "submit_results", | ||
132 | 16 | "parameters": | ||
133 | 17 | { | ||
134 | 18 | "server": "http://validation.linaro.org/launch-control", | ||
135 | 19 | "stream": "/anonymous/panda01-ltp/" | ||
136 | 20 | } | ||
137 | 21 | } | ||
138 | 22 | ] | ||
139 | 23 | } | ||
140 | 0 | 24 | ||
141 | === modified file 'lava_dispatcher/__init__.py' | |||
142 | --- lava_dispatcher/__init__.py 2011-08-04 07:19:53 +0000 | |||
143 | +++ lava_dispatcher/__init__.py 2011-08-09 14:40:36 +0000 | |||
144 | @@ -29,6 +29,8 @@ | |||
145 | 29 | from lava_dispatcher.actions import get_all_cmds | 29 | from lava_dispatcher.actions import get_all_cmds |
146 | 30 | from lava_dispatcher.client import LavaClient, CriticalError, GeneralError | 30 | from lava_dispatcher.client import LavaClient, CriticalError, GeneralError |
147 | 31 | from lava_dispatcher.android_client import LavaAndroidClient | 31 | from lava_dispatcher.android_client import LavaAndroidClient |
148 | 32 | from lava_dispatcher.qemu_client import LavaQEMUClient | ||
149 | 33 | from lava_dispatcher.ssh_client import LavaSSHClient | ||
150 | 32 | 34 | ||
151 | 33 | __version__ = "0.1.0" | 35 | __version__ = "0.1.0" |
152 | 34 | 36 | ||
153 | @@ -36,19 +38,22 @@ | |||
154 | 36 | def __init__(self, job_json): | 38 | def __init__(self, job_json): |
155 | 37 | self.job_status = 'pass' | 39 | self.job_status = 'pass' |
156 | 38 | self.load_job_data(job_json) | 40 | self.load_job_data(job_json) |
158 | 39 | self.context = LavaContext(self.target, self.image_type) | 41 | self.context = LavaContext(self.target, self.image_type, self.target_type) |
159 | 40 | 42 | ||
160 | 41 | def load_job_data(self, job_json): | 43 | def load_job_data(self, job_json): |
161 | 42 | self.job_data = json.loads(job_json) | 44 | self.job_data = json.loads(job_json) |
162 | 43 | 45 | ||
163 | 44 | @property | 46 | @property |
164 | 45 | def target(self): | 47 | def target(self): |
166 | 46 | return self.job_data['target'] | 48 | return self.job_data.get('target') |
167 | 47 | 49 | ||
168 | 48 | @property | 50 | @property |
169 | 49 | def image_type(self): | 51 | def image_type(self): |
172 | 50 | if self.job_data.has_key('image_type'): | 52 | return self.job_data.get('image_type') |
173 | 51 | return self.job_data['image_type'] | 53 | |
174 | 54 | @property | ||
175 | 55 | def target_type(self): | ||
176 | 56 | return self.job_data.get('target_type') | ||
177 | 52 | 57 | ||
178 | 53 | def run(self): | 58 | def run(self): |
179 | 54 | lava_commands = get_all_cmds() | 59 | lava_commands = get_all_cmds() |
180 | @@ -65,19 +70,26 @@ | |||
181 | 65 | metadata['target.hostname'] = self.target | 70 | metadata['target.hostname'] = self.target |
182 | 66 | self.context.test_data.add_metadata(metadata) | 71 | self.context.test_data.add_metadata(metadata) |
183 | 67 | action = lava_commands[cmd['command']](self.context) | 72 | action = lava_commands[cmd['command']](self.context) |
184 | 73 | except_str = "" | ||
185 | 68 | try: | 74 | try: |
186 | 69 | status = 'fail' | 75 | status = 'fail' |
187 | 70 | action.run(**params) | 76 | action.run(**params) |
191 | 71 | except CriticalError, err: | 77 | except CriticalError as err: |
192 | 72 | raise err | 78 | except_str = str(err) |
193 | 73 | except (pexpect.TIMEOUT, GeneralError), err: | 79 | raise |
194 | 80 | except (pexpect.TIMEOUT, GeneralError) as err: | ||
195 | 81 | except_str = str(err) | ||
196 | 74 | pass | 82 | pass |
198 | 75 | except Exception, err: | 83 | except Exception as err: |
199 | 84 | except_str = str(err) | ||
200 | 76 | raise | 85 | raise |
201 | 77 | else: | 86 | else: |
202 | 78 | status = 'pass' | 87 | status = 'pass' |
203 | 79 | finally: | 88 | finally: |
204 | 89 | err_msg = "" | ||
205 | 90 | command = cmd['command'] | ||
206 | 80 | if status == 'fail': | 91 | if status == 'fail': |
207 | 92 | <<<<<<< TREE | ||
208 | 81 | err_msg = "Lava failed at action " + cmd['command'] \ | 93 | err_msg = "Lava failed at action " + cmd['command'] \ |
209 | 82 | + " with error: " + str(err) + "\n" | 94 | + " with error: " + str(err) + "\n" |
210 | 83 | if cmd['command'] == 'lava_test_run': | 95 | if cmd['command'] == 'lava_test_run': |
211 | @@ -91,6 +103,18 @@ | |||
212 | 91 | err_msg = "" | 103 | err_msg = "" |
213 | 92 | self.context.test_data.add_result(cmd['command'], | 104 | self.context.test_data.add_result(cmd['command'], |
214 | 93 | status, err_msg) | 105 | status, err_msg) |
215 | 106 | ======= | ||
216 | 107 | err_msg = "Lava failed at action %s with error: %s\n" %\ | ||
217 | 108 | (command, except_str) | ||
218 | 109 | if command == 'lava_test_run': | ||
219 | 110 | err_msg += "Lava failed on test: %s" %\ | ||
220 | 111 | params.get('test_name') | ||
221 | 112 | exc_type, exc_value, exc_traceback = sys.exc_info() | ||
222 | 113 | err_msg += repr(traceback.format_tb(exc_traceback)) | ||
223 | 114 | print >> sys.stderr, err_msg | ||
224 | 115 | self.context.test_data.add_result(command, status, err_msg) | ||
225 | 116 | |||
226 | 117 | >>>>>>> MERGE-SOURCE | ||
227 | 94 | except: | 118 | except: |
228 | 95 | #Capture all user-defined and non-user-defined critical errors | 119 | #Capture all user-defined and non-user-defined critical errors |
229 | 96 | self.context.test_data.job_status='fail' | 120 | self.context.test_data.job_status='fail' |
230 | @@ -104,11 +128,16 @@ | |||
231 | 104 | 128 | ||
232 | 105 | 129 | ||
233 | 106 | class LavaContext(object): | 130 | class LavaContext(object): |
236 | 107 | def __init__(self, target, image_type): | 131 | def __init__(self, target, image_type, target_type): |
237 | 108 | if image_type != "android": | 132 | if image_type == "android": |
238 | 133 | self._client = LavaAndroidClient(target) | ||
239 | 134 | elif target_type == "qemu": | ||
240 | 135 | self._client = LavaQEMUClient(target) | ||
241 | 136 | elif target_type == "ssh": | ||
242 | 137 | self._client = LavaSSHClient(target) | ||
243 | 138 | else: | ||
244 | 139 | # conmux / serial | ||
245 | 109 | self._client = LavaClient(target) | 140 | self._client = LavaClient(target) |
246 | 110 | else: | ||
247 | 111 | self._client = LavaAndroidClient(target) | ||
248 | 112 | self.test_data = LavaTestData() | 141 | self.test_data = LavaTestData() |
249 | 113 | 142 | ||
250 | 114 | @property | 143 | @property |
251 | @@ -143,8 +172,8 @@ | |||
252 | 143 | self._job_status = status | 172 | self._job_status = status |
253 | 144 | 173 | ||
254 | 145 | def add_result(self, test_case_id, result, message=""): | 174 | def add_result(self, test_case_id, result, message=""): |
257 | 146 | result_data = { 'test_case_id': test_case_id, 'result': result \ | 175 | result_data = {'test_case_id': test_case_id, 'result': result, \ |
258 | 147 | , 'message': message} | 176 | 'message': message} |
259 | 148 | self._test_run['test_results'].append(result_data) | 177 | self._test_run['test_results'].append(result_data) |
260 | 149 | 178 | ||
261 | 150 | def add_attachment(self, attachment): | 179 | def add_attachment(self, attachment): |
262 | 151 | 180 | ||
263 | === modified file 'lava_dispatcher/actions/android_basic.py' | |||
264 | --- lava_dispatcher/actions/android_basic.py 2011-06-27 04:55:08 +0000 | |||
265 | +++ lava_dispatcher/actions/android_basic.py 2011-08-09 14:40:36 +0000 | |||
266 | @@ -21,7 +21,6 @@ | |||
267 | 21 | 21 | ||
268 | 22 | from lava_dispatcher.actions import BaseAndroidAction | 22 | from lava_dispatcher.actions import BaseAndroidAction |
269 | 23 | from lava_dispatcher.client import OperationFailed | 23 | from lava_dispatcher.client import OperationFailed |
270 | 24 | from lava_dispatcher.android_config import TESTER_STR | ||
271 | 25 | import time | 24 | import time |
272 | 26 | import pexpect | 25 | import pexpect |
273 | 27 | import sys | 26 | import sys |
274 | 28 | 27 | ||
275 | === modified file 'lava_dispatcher/actions/android_deploy.py' | |||
276 | --- lava_dispatcher/actions/android_deploy.py 2011-08-04 07:19:53 +0000 | |||
277 | +++ lava_dispatcher/actions/android_deploy.py 2011-08-09 14:40:36 +0000 | |||
278 | @@ -20,7 +20,7 @@ | |||
279 | 20 | # along with this program; if not, see <http://www.gnu.org/licenses>. | 20 | # along with this program; if not, see <http://www.gnu.org/licenses>. |
280 | 21 | 21 | ||
281 | 22 | from lava_dispatcher.actions import BaseAction | 22 | from lava_dispatcher.actions import BaseAction |
283 | 23 | from lava_dispatcher.config import LAVA_IMAGE_TMPDIR, LAVA_IMAGE_URL, MASTER_STR | 23 | from lava_dispatcher.config import LAVA_IMAGE_TMPDIR, LAVA_IMAGE_URL |
284 | 24 | import os | 24 | import os |
285 | 25 | import sys | 25 | import sys |
286 | 26 | import shutil | 26 | import shutil |
287 | @@ -101,156 +101,88 @@ | |||
288 | 101 | 101 | ||
289 | 102 | def deploy_linaro_android_testboot(self, boottbz2): | 102 | def deploy_linaro_android_testboot(self, boottbz2): |
290 | 103 | client = self.client | 103 | client = self.client |
306 | 104 | client.run_shell_command( | 104 | client.run_cmd_master('mkfs.vfat /dev/disk/by-label/testboot ' |
307 | 105 | 'mkfs.vfat /dev/disk/by-label/testboot -n testboot', | 105 | '-n testboot') |
308 | 106 | response = MASTER_STR) | 106 | client.run_cmd_master('udevadm trigger') |
309 | 107 | client.run_shell_command( | 107 | client.run_cmd_master('mkdir -p /mnt/lava/boot') |
310 | 108 | 'udevadm trigger', | 108 | client.run_cmd_master('mount /dev/disk/by-label/testboot ' |
311 | 109 | response = MASTER_STR) | 109 | '/mnt/lava/boot') |
312 | 110 | client.run_shell_command( | 110 | client.run_cmd_master('wget -qO- %s |tar --numeric-owner -C /mnt/lava -xjf -' % boottbz2) |
298 | 111 | 'mkdir -p /mnt/lava/boot', | ||
299 | 112 | response = MASTER_STR) | ||
300 | 113 | client.run_shell_command( | ||
301 | 114 | 'mount /dev/disk/by-label/testboot /mnt/lava/boot', | ||
302 | 115 | response = MASTER_STR) | ||
303 | 116 | client.run_shell_command( | ||
304 | 117 | 'wget -qO- %s |tar --numeric-owner -C /mnt/lava -xjf -' % boottbz2, | ||
305 | 118 | response = MASTER_STR) | ||
313 | 119 | 111 | ||
314 | 120 | self.recreate_uInitrd() | 112 | self.recreate_uInitrd() |
315 | 121 | 113 | ||
319 | 122 | client.run_shell_command( | 114 | client.run_cmd_master('umount /mnt/lava/boot') |
317 | 123 | 'umount /mnt/lava/boot', | ||
318 | 124 | response = MASTER_STR) | ||
320 | 125 | 115 | ||
321 | 126 | def recreate_uInitrd(self): | 116 | def recreate_uInitrd(self): |
322 | 127 | client = self.client | 117 | client = self.client |
356 | 128 | client.run_shell_command( | 118 | client.run_cmd_master('mkdir -p ~/tmp/') |
357 | 129 | 'mkdir -p ~/tmp/', | 119 | client.run_cmd_master('mv /mnt/lava/boot/uInitrd ~/tmp') |
358 | 130 | response = MASTER_STR) | 120 | client.run_cmd_master('cd ~/tmp/') |
359 | 131 | client.run_shell_command( | 121 | |
360 | 132 | 'mv /mnt/lava/boot/uInitrd ~/tmp', | 122 | client.run_cmd_master('mv uInitrd.data ramdisk.cpio.gz') |
361 | 133 | response = MASTER_STR) | 123 | client.run_cmd_master( |
362 | 134 | client.run_shell_command( | 124 | 'gzip -d ramdisk.cpio.gz; cpio -i -F ramdisk.cpio') |
363 | 135 | 'cd ~/tmp/', | 125 | client.run_cmd_master( |
364 | 136 | response = MASTER_STR) | 126 | 'sed -i "/mount ext4 \/dev\/block\/mmcblk0p3/d" init.rc') |
365 | 137 | 127 | client.run_cmd_master( | |
366 | 138 | client.run_shell_command( | 128 | 'sed -i "/mount ext4 \/dev\/block\/mmcblk0p5/d" init.rc') |
367 | 139 | 'dd if=uInitrd of=uInitrd.data ibs=64 skip=1', | 129 | client.run_cmd_master('sed -i "s/mmcblk0p2/mmcblk0p5/g" init.rc') |
368 | 140 | response = MASTER_STR) | 130 | client.run_cmd_master( |
369 | 141 | client.run_shell_command( | 131 | 'sed -i "/export PATH/a \ \ \ \ export PS1 root@linaro: " init.rc') |
370 | 142 | 'mv uInitrd.data ramdisk.cpio.gz', | 132 | |
371 | 143 | response = MASTER_STR) | 133 | client.run_cmd_master( |
339 | 144 | client.run_shell_command( | ||
340 | 145 | 'gzip -d ramdisk.cpio.gz; cpio -i -F ramdisk.cpio', | ||
341 | 146 | response = MASTER_STR) | ||
342 | 147 | client.run_shell_command( | ||
343 | 148 | 'sed -i "/mount ext4 \/dev\/block\/mmcblk0p3/d" init.rc', | ||
344 | 149 | response = MASTER_STR) | ||
345 | 150 | client.run_shell_command( | ||
346 | 151 | 'sed -i "/mount ext4 \/dev\/block\/mmcblk0p5/d" init.rc', | ||
347 | 152 | response = MASTER_STR) | ||
348 | 153 | client.run_shell_command( | ||
349 | 154 | 'sed -i "s/mmcblk0p2/mmcblk0p5/g" init.rc', | ||
350 | 155 | response = MASTER_STR) | ||
351 | 156 | client.run_shell_command( | ||
352 | 157 | 'sed -i "/export PATH/a \ \ \ \ export PS1 root@linaro: " init.rc', | ||
353 | 158 | response = MASTER_STR) | ||
354 | 159 | |||
355 | 160 | client.run_shell_command( | ||
372 | 161 | 'cpio -i -t -F ramdisk.cpio | cpio -o -H newc | \ | 134 | 'cpio -i -t -F ramdisk.cpio | cpio -o -H newc | \ |
375 | 162 | gzip > ramdisk_new.cpio.gz', | 135 | gzip > ramdisk_new.cpio.gz') |
374 | 163 | response = MASTER_STR) | ||
376 | 164 | 136 | ||
378 | 165 | client.run_shell_command( | 137 | client.run_cmd_master( |
379 | 166 | 'mkimage -A arm -O linux -T ramdisk -n "Android Ramdisk Image" \ | 138 | 'mkimage -A arm -O linux -T ramdisk -n "Android Ramdisk Image" \ |
382 | 167 | -d ramdisk_new.cpio.gz uInitrd', | 139 | -d ramdisk_new.cpio.gz uInitrd') |
381 | 168 | response = MASTER_STR) | ||
383 | 169 | 140 | ||
393 | 170 | client.run_shell_command( | 141 | client.run_cmd_master('cd -') |
394 | 171 | 'cd -', | 142 | client.run_cmd_master('mv ~/tmp/uInitrd /mnt/lava/boot/uInitrd') |
395 | 172 | response = MASTER_STR) | 143 | client.run_cmd_master('rm -rf ~/tmp') |
387 | 173 | client.run_shell_command( | ||
388 | 174 | 'mv ~/tmp/uInitrd /mnt/lava/boot/uInitrd', | ||
389 | 175 | response = MASTER_STR) | ||
390 | 176 | client.run_shell_command( | ||
391 | 177 | 'rm -rf ~/tmp', | ||
392 | 178 | response = MASTER_STR) | ||
396 | 179 | 144 | ||
397 | 180 | def deploy_linaro_android_testrootfs(self, systemtbz2): | 145 | def deploy_linaro_android_testrootfs(self, systemtbz2): |
398 | 181 | client = self.client | 146 | client = self.client |
411 | 182 | client.run_shell_command( | 147 | client.run_cmd_master( |
412 | 183 | 'mkfs.ext4 -q /dev/disk/by-label/testrootfs -L testrootfs', | 148 | 'mkfs.ext4 -q /dev/disk/by-label/testrootfs -L testrootfs') |
413 | 184 | response = MASTER_STR) | 149 | client.run_cmd_master('udevadm trigger') |
414 | 185 | client.run_shell_command( | 150 | client.run_cmd_master('mkdir -p /mnt/lava/system') |
415 | 186 | 'udevadm trigger', | 151 | client.run_cmd_master( |
416 | 187 | response = MASTER_STR) | 152 | 'mount /dev/disk/by-label/testrootfs /mnt/lava/system') |
405 | 188 | client.run_shell_command( | ||
406 | 189 | 'mkdir -p /mnt/lava/system', | ||
407 | 190 | response = MASTER_STR) | ||
408 | 191 | client.run_shell_command( | ||
409 | 192 | 'mount /dev/disk/by-label/testrootfs /mnt/lava/system', | ||
410 | 193 | response = MASTER_STR) | ||
417 | 194 | client.run_shell_command( | 153 | client.run_shell_command( |
418 | 195 | 'wget -qO- %s |tar --numeric-owner -C /mnt/lava -xjf -' % systemtbz2, | 154 | 'wget -qO- %s |tar --numeric-owner -C /mnt/lava -xjf -' % systemtbz2, |
420 | 196 | response = MASTER_STR, timeout = 600) | 155 | client.master_str, 600) |
421 | 197 | 156 | ||
422 | 198 | sed_cmd = "/dev_mount sdcard \/mnt\/sdcard/c dev_mount sdcard /mnt/sdcard 6 " \ | 157 | sed_cmd = "/dev_mount sdcard \/mnt\/sdcard/c dev_mount sdcard /mnt/sdcard 6 " \ |
423 | 199 | "/devices/platform/omap/omap_hsmmc.0/mmc_host/mmc0" | 158 | "/devices/platform/omap/omap_hsmmc.0/mmc_host/mmc0" |
430 | 200 | client.run_shell_command( | 159 | client.run_cmd_master( |
431 | 201 | 'sed -i "%s" /mnt/lava/system/etc/vold.fstab' % sed_cmd, | 160 | 'sed -i "%s" /mnt/lava/system/etc/vold.fstab' % sed_cmd) |
432 | 202 | response = MASTER_STR) | 161 | client.run_cmd_master('umount /mnt/lava/system') |
427 | 203 | client.run_shell_command( | ||
428 | 204 | 'umount /mnt/lava/system', | ||
429 | 205 | response = MASTER_STR) | ||
433 | 206 | 162 | ||
434 | 207 | def purge_linaro_android_sdcard(self): | 163 | def purge_linaro_android_sdcard(self): |
435 | 208 | client = self.client | 164 | client = self.client |
442 | 209 | client.run_shell_command( | 165 | client.run_cmd_master('mkfs.vfat /dev/disk/by-label/sdcard -n sdcard') |
443 | 210 | 'mkfs.vfat /dev/disk/by-label/sdcard -n sdcard', | 166 | client.run_cmd_master('udevadm trigger') |
438 | 211 | response = MASTER_STR) | ||
439 | 212 | client.run_shell_command( | ||
440 | 213 | 'udevadm trigger', | ||
441 | 214 | response = MASTER_STR) | ||
444 | 215 | 167 | ||
445 | 216 | def deploy_linaro_android_system(self, systemtbz2): | 168 | def deploy_linaro_android_system(self, systemtbz2): |
446 | 217 | client = self.client | 169 | client = self.client |
459 | 218 | client.run_shell_command( | 170 | client.run_cmd_master('mkfs.ext4 -q /dev/disk/by-label/system -L system') |
460 | 219 | 'mkfs.ext4 -q /dev/disk/by-label/system -L system', | 171 | client.run_cmd_master('udevadm trigger') |
461 | 220 | response = MASTER_STR) | 172 | client.run_cmd_master('mkdir -p /mnt/lava/system') |
462 | 221 | client.run_shell_command( | 173 | client.run_cmd_master('mount /dev/disk/by-label/system /mnt/lava/system') |
451 | 222 | 'udevadm trigger', | ||
452 | 223 | response = MASTER_STR) | ||
453 | 224 | client.run_shell_command( | ||
454 | 225 | 'mkdir -p /mnt/lava/system', | ||
455 | 226 | response = MASTER_STR) | ||
456 | 227 | client.run_shell_command( | ||
457 | 228 | 'mount /dev/disk/by-label/system /mnt/lava/system', | ||
458 | 229 | response = MASTER_STR) | ||
463 | 230 | client.run_shell_command( | 174 | client.run_shell_command( |
464 | 231 | 'wget -qO- %s |tar --numeric-owner -C /mnt/lava -xjf -' % systemtbz2, | 175 | 'wget -qO- %s |tar --numeric-owner -C /mnt/lava -xjf -' % systemtbz2, |
469 | 232 | response = MASTER_STR, timeout = 600) | 176 | client.master_str, 600) |
470 | 233 | client.run_shell_command( | 177 | client.run_cmd_master('umount /mnt/lava/system') |
467 | 234 | 'umount /mnt/lava/system', | ||
468 | 235 | response = MASTER_STR) | ||
471 | 236 | 178 | ||
472 | 237 | def deploy_linaro_android_data(self, datatbz2): | 179 | def deploy_linaro_android_data(self, datatbz2): |
473 | 238 | client = self.client | 180 | client = self.client |
486 | 239 | client.run_shell_command( | 181 | client.run_cmd_master('mkfs.ext4 -q /dev/disk/by-label/data -L data') |
487 | 240 | 'mkfs.ext4 -q /dev/disk/by-label/data -L data', | 182 | client.run_cmd_master('udevadm trigger') |
488 | 241 | response = MASTER_STR) | 183 | client.run_cmd_master('mkdir -p /mnt/lava/data') |
489 | 242 | client.run_shell_command( | 184 | client.run_cmd_master('mount /dev/disk/by-label/data /mnt/lava/data') |
478 | 243 | 'udevadm trigger', | ||
479 | 244 | response = MASTER_STR) | ||
480 | 245 | client.run_shell_command( | ||
481 | 246 | 'mkdir -p /mnt/lava/data', | ||
482 | 247 | response = MASTER_STR) | ||
483 | 248 | client.run_shell_command( | ||
484 | 249 | 'mount /dev/disk/by-label/data /mnt/lava/data', | ||
485 | 250 | response = MASTER_STR) | ||
490 | 251 | client.run_shell_command( | 185 | client.run_shell_command( |
491 | 252 | 'wget -qO- %s |tar --numeric-owner -C /mnt/lava -xjf -' % datatbz2, | 186 | 'wget -qO- %s |tar --numeric-owner -C /mnt/lava -xjf -' % datatbz2, |
496 | 253 | response = MASTER_STR, timeout = 600) | 187 | client.master_str, 600) |
497 | 254 | client.run_shell_command( | 188 | client.run_cmd_master('umount /mnt/lava/data') |
494 | 255 | 'umount /mnt/lava/data', | ||
495 | 256 | response = MASTER_STR) | ||
498 | 257 | 189 | ||
499 | === modified file 'lava_dispatcher/actions/deploy.py' | |||
500 | --- lava_dispatcher/actions/deploy.py 2011-08-04 07:19:53 +0000 | |||
501 | +++ lava_dispatcher/actions/deploy.py 2011-08-09 14:40:36 +0000 | |||
502 | @@ -27,7 +27,7 @@ | |||
503 | 27 | from tempfile import mkdtemp | 27 | from tempfile import mkdtemp |
504 | 28 | 28 | ||
505 | 29 | from lava_dispatcher.actions import BaseAction | 29 | from lava_dispatcher.actions import BaseAction |
507 | 30 | from lava_dispatcher.config import LAVA_IMAGE_TMPDIR, LAVA_IMAGE_URL, MASTER_STR | 30 | from lava_dispatcher.config import LAVA_IMAGE_TMPDIR, LAVA_IMAGE_URL |
508 | 31 | from lava_dispatcher.utils import download, download_with_cache | 31 | from lava_dispatcher.utils import download, download_with_cache |
509 | 32 | from lava_dispatcher.client import CriticalError | 32 | from lava_dispatcher.client import CriticalError |
510 | 33 | 33 | ||
511 | @@ -126,9 +126,9 @@ | |||
512 | 126 | 126 | ||
513 | 127 | image_file = os.path.join(tarball_dir, "lava.img") | 127 | image_file = os.path.join(tarball_dir, "lava.img") |
514 | 128 | board = client.board | 128 | board = client.board |
518 | 129 | cmd = ("sudo linaro-media-create --hwpack-force-yes --dev %s " | 129 | cmd = ("sudo linaro-media-create --hwpack-force-yes -dev %s " |
519 | 130 | "--image_file %s --binary %s --hwpack %s --image_size 3G" % ( | 130 | "--image_file %s --binary %s --hwpack %s --image_size 3G" % |
520 | 131 | board.type, image_file, rootfs_path, hwpack_path)) | 131 | (board.type, image_file, rootfs_path, hwpack_path)) |
521 | 132 | rc, output = getstatusoutput(cmd) | 132 | rc, output = getstatusoutput(cmd) |
522 | 133 | if rc: | 133 | if rc: |
523 | 134 | shutil.rmtree(tarball_dir) | 134 | shutil.rmtree(tarball_dir) |
524 | @@ -152,46 +152,25 @@ | |||
525 | 152 | def deploy_linaro_rootfs(self, rootfs): | 152 | def deploy_linaro_rootfs(self, rootfs): |
526 | 153 | client = self.client | 153 | client = self.client |
527 | 154 | print "Deploying linaro image" | 154 | print "Deploying linaro image" |
540 | 155 | client.run_shell_command( | 155 | client.run_cmd_master( |
541 | 156 | 'mkfs.ext3 -q /dev/disk/by-label/testrootfs -L testrootfs', | 156 | 'mkfs.ext3 -q /dev/disk/by-label/testrootfs -L testrootfs') |
542 | 157 | response = MASTER_STR) | 157 | client.run_cmd_master('udevadm trigger') |
543 | 158 | client.run_shell_command( | 158 | client.run_cmd_master('mkdir -p /mnt/root') |
544 | 159 | 'udevadm trigger', | 159 | client.run_cmd_master('mount /dev/disk/by-label/testrootfs /mnt/root') |
533 | 160 | response = MASTER_STR) | ||
534 | 161 | client.run_shell_command( | ||
535 | 162 | 'mkdir -p /mnt/root', | ||
536 | 163 | response = MASTER_STR) | ||
537 | 164 | client.run_shell_command( | ||
538 | 165 | 'mount /dev/disk/by-label/testrootfs /mnt/root', | ||
539 | 166 | response = MASTER_STR) | ||
545 | 167 | client.run_shell_command( | 160 | client.run_shell_command( |
546 | 168 | 'wget -qO- %s |tar --numeric-owner -C /mnt/root -xzf -' % rootfs, | 161 | 'wget -qO- %s |tar --numeric-owner -C /mnt/root -xzf -' % rootfs, |
554 | 169 | response = MASTER_STR, timeout = 3600) | 162 | client.master_str, 3600) |
555 | 170 | client.run_shell_command( | 163 | client.run_cmd_master('echo linaro > /mnt/root/etc/hostname') |
556 | 171 | 'echo linaro > /mnt/root/etc/hostname', | 164 | client.run_cmd_master('umount /mnt/root') |
550 | 172 | response = MASTER_STR) | ||
551 | 173 | client.run_shell_command( | ||
552 | 174 | 'umount /mnt/root', | ||
553 | 175 | response = MASTER_STR) | ||
557 | 176 | 165 | ||
558 | 177 | def deploy_linaro_bootfs(self, bootfs): | 166 | def deploy_linaro_bootfs(self, bootfs): |
559 | 178 | client = self.client | 167 | client = self.client |
578 | 179 | client.run_shell_command( | 168 | client.run_cmd_master( |
579 | 180 | 'mkfs.vfat /dev/disk/by-label/testboot -n testboot', | 169 | 'mkfs.vfat /dev/disk/by-label/testboot -n testboot') |
580 | 181 | response = MASTER_STR) | 170 | client.run_cmd_master('udevadm trigger') |
581 | 182 | client.run_shell_command( | 171 | client.run_cmd_master('mkdir -p /mnt/boot') |
582 | 183 | 'udevadm trigger', | 172 | client.run_cmd_master('mount /dev/disk/by-label/testboot /mnt/boot') |
583 | 184 | response = MASTER_STR) | 173 | client.run_cmd_master( |
584 | 185 | client.run_shell_command( | 174 | 'wget -qO- %s |tar --numeric-owner -C /mnt/boot -xzf -' % bootfs) |
585 | 186 | 'mkdir -p /mnt/boot', | 175 | client.run_cmd_master('umount /mnt/boot') |
568 | 187 | response = MASTER_STR) | ||
569 | 188 | client.run_shell_command( | ||
570 | 189 | 'mount /dev/disk/by-label/testboot /mnt/boot', | ||
571 | 190 | response = MASTER_STR) | ||
572 | 191 | client.run_shell_command( | ||
573 | 192 | 'wget -qO- %s |tar --numeric-owner -C /mnt/boot -xzf -' % bootfs, | ||
574 | 193 | response = MASTER_STR) | ||
575 | 194 | client.run_shell_command( | ||
576 | 195 | 'umount /mnt/boot', | ||
577 | 196 | response = MASTER_STR) | ||
586 | 197 | 176 | ||
587 | 198 | 177 | ||
588 | === modified file 'lava_dispatcher/actions/launch_control.py' | |||
589 | --- lava_dispatcher/actions/launch_control.py 2011-06-27 04:55:08 +0000 | |||
590 | +++ lava_dispatcher/actions/launch_control.py 2011-08-09 14:40:36 +0000 | |||
591 | @@ -22,7 +22,7 @@ | |||
592 | 22 | 22 | ||
593 | 23 | import json | 23 | import json |
594 | 24 | from lava_dispatcher.actions import BaseAction | 24 | from lava_dispatcher.actions import BaseAction |
596 | 25 | from lava_dispatcher.config import LAVA_RESULT_DIR, MASTER_STR, LAVA_SERVER_IP | 25 | from lava_dispatcher.config import LAVA_RESULT_DIR, LAVA_SERVER_IP |
597 | 26 | import socket | 26 | import socket |
598 | 27 | from threading import Thread | 27 | from threading import Thread |
599 | 28 | import time | 28 | import time |
600 | @@ -84,32 +84,26 @@ | |||
601 | 84 | except: | 84 | except: |
602 | 85 | client.boot_master_image() | 85 | client.boot_master_image() |
603 | 86 | 86 | ||
612 | 87 | client.run_shell_command( | 87 | client.run_cmd_master('mkdir -p /mnt/root') |
613 | 88 | 'mkdir -p /mnt/root', response = MASTER_STR) | 88 | client.run_cmd_master( |
614 | 89 | client.run_shell_command( | 89 | 'mount /dev/disk/by-label/%s /mnt/root' % result_disk) |
615 | 90 | 'mount /dev/disk/by-label/%s /mnt/root' % result_disk, | 90 | client.run_cmd_master('mkdir -p /tmp/%s' % LAVA_RESULT_DIR) |
616 | 91 | response = MASTER_STR) | 91 | client.run_cmd_master( |
609 | 92 | client.run_shell_command( | ||
610 | 93 | 'mkdir -p /tmp/%s' % LAVA_RESULT_DIR, response = MASTER_STR) | ||
611 | 94 | client.run_shell_command( | ||
617 | 95 | 'cp /mnt/root/%s/*.bundle /tmp/%s' % (LAVA_RESULT_DIR, | 92 | 'cp /mnt/root/%s/*.bundle /tmp/%s' % (LAVA_RESULT_DIR, |
620 | 96 | LAVA_RESULT_DIR), response = MASTER_STR) | 93 | LAVA_RESULT_DIR)) |
621 | 97 | client.run_shell_command('umount /mnt/root', response = MASTER_STR) | 94 | client.run_cmd_master('umount /mnt/root') |
622 | 98 | 95 | ||
623 | 99 | #Upload bundle list-bundle.lst | 96 | #Upload bundle list-bundle.lst |
628 | 100 | client.run_shell_command('cd /tmp/%s' % LAVA_RESULT_DIR, | 97 | client.run_cmd_master('cd /tmp/%s' % LAVA_RESULT_DIR) |
629 | 101 | response = MASTER_STR) | 98 | client.run_cmd_master('ls *.bundle > bundle.lst') |
626 | 102 | client.run_shell_command('ls *.bundle > bundle.lst', | ||
627 | 103 | response = MASTER_STR) | ||
630 | 104 | 99 | ||
631 | 105 | t = ResultUploader() | 100 | t = ResultUploader() |
632 | 106 | t.start() | 101 | t.start() |
633 | 107 | #XXX: Odd problem where we sometimes get stuck here. This is just | 102 | #XXX: Odd problem where we sometimes get stuck here. This is just |
634 | 108 | # a hacky workaround to see if it's a race | 103 | # a hacky workaround to see if it's a race |
635 | 109 | time.sleep(60) | 104 | time.sleep(60) |
639 | 110 | client.run_shell_command( | 105 | client.run_cmd_master('cat bundle.lst |nc %s %d' % |
640 | 111 | 'cat bundle.lst |nc %s %d' % (LAVA_SERVER_IP, t.get_port()), | 106 | (LAVA_SERVER_IP, t.get_port())) |
638 | 112 | response = MASTER_STR) | ||
641 | 113 | t.join() | 107 | t.join() |
642 | 114 | 108 | ||
643 | 115 | bundle_list = t.get_data().strip().splitlines() | 109 | bundle_list = t.get_data().strip().splitlines() |
644 | @@ -124,10 +118,9 @@ | |||
645 | 124 | #XXX: Odd problem where we sometimes get stuck here. This is just | 118 | #XXX: Odd problem where we sometimes get stuck here. This is just |
646 | 125 | # a hacky workaround to see if it's a race | 119 | # a hacky workaround to see if it's a race |
647 | 126 | time.sleep(60) | 120 | time.sleep(60) |
649 | 127 | client.run_shell_command( | 121 | client.run_cmd_master( |
650 | 128 | 'cat /tmp/%s/%s | nc %s %s' % (LAVA_RESULT_DIR, bundle, | 122 | 'cat /tmp/%s/%s | nc %s %s' % (LAVA_RESULT_DIR, bundle, |
653 | 129 | LAVA_SERVER_IP, t.get_port()), | 123 | LAVA_SERVER_IP, t.get_port())) |
652 | 130 | response = MASTER_STR) | ||
654 | 131 | t.join() | 124 | t.join() |
655 | 132 | content = t.get_data() | 125 | content = t.get_data() |
656 | 133 | 126 | ||
657 | 134 | 127 | ||
658 | === modified file 'lava_dispatcher/actions/lava-test.py' | |||
659 | --- lava_dispatcher/actions/lava-test.py 2011-08-04 07:19:53 +0000 | |||
660 | +++ lava_dispatcher/actions/lava-test.py 2011-08-09 14:40:36 +0000 | |||
661 | @@ -25,7 +25,7 @@ | |||
662 | 25 | import traceback | 25 | import traceback |
663 | 26 | from lava_dispatcher.actions import BaseAction | 26 | from lava_dispatcher.actions import BaseAction |
664 | 27 | from lava_dispatcher.client import OperationFailed | 27 | from lava_dispatcher.client import OperationFailed |
666 | 28 | from lava_dispatcher.config import LAVA_RESULT_DIR, MASTER_STR, TESTER_STR | 28 | from lava_dispatcher.config import LAVA_RESULT_DIR |
667 | 29 | 29 | ||
668 | 30 | 30 | ||
669 | 31 | class cmd_lava_test_run(BaseAction): | 31 | class cmd_lava_test_run(BaseAction): |
670 | @@ -33,14 +33,13 @@ | |||
671 | 33 | #Make sure in test image now | 33 | #Make sure in test image now |
672 | 34 | client = self.client | 34 | client = self.client |
673 | 35 | client.in_test_shell() | 35 | client.in_test_shell() |
676 | 36 | client.run_shell_command('mkdir -p %s' % LAVA_RESULT_DIR, | 36 | client.run_cmd_tester('mkdir -p %s' % LAVA_RESULT_DIR) |
675 | 37 | response=TESTER_STR) | ||
677 | 38 | client.export_display() | 37 | client.export_display() |
678 | 39 | bundle_name = test_name + "-" + datetime.now().strftime("%H%M%S") | 38 | bundle_name = test_name + "-" + datetime.now().strftime("%H%M%S") |
679 | 40 | client.run_shell_command( | 39 | client.run_shell_command( |
680 | 41 | 'lava-test run %s -o %s/%s.bundle' % ( | 40 | 'lava-test run %s -o %s/%s.bundle' % ( |
681 | 42 | test_name, LAVA_RESULT_DIR, bundle_name), | 41 | test_name, LAVA_RESULT_DIR, bundle_name), |
683 | 43 | response=TESTER_STR, timeout=timeout) | 42 | client.tester_str, timeout) |
684 | 44 | 43 | ||
685 | 45 | 44 | ||
686 | 46 | class cmd_lava_test_install(BaseAction): | 45 | class cmd_lava_test_install(BaseAction): |
687 | @@ -57,65 +56,42 @@ | |||
688 | 57 | client.boot_master_image() | 56 | client.boot_master_image() |
689 | 58 | 57 | ||
690 | 59 | #install bazaar in tester image | 58 | #install bazaar in tester image |
703 | 60 | client.run_shell_command( | 59 | client.run_cmd_master('mkdir -p /mnt/root') |
704 | 61 | 'mkdir -p /mnt/root', | 60 | client.run_cmd_master('mount /dev/disk/by-label/testrootfs /mnt/root') |
705 | 62 | response=MASTER_STR) | 61 | client.run_cmd_master('cp -f /mnt/root/etc/resolv.conf ' |
706 | 63 | client.run_shell_command( | 62 | '/mnt/root/etc/resolv.conf.bak') |
707 | 64 | 'mount /dev/disk/by-label/testrootfs /mnt/root', | 63 | client.run_cmd_master('cp -L /etc/resolv.conf /mnt/root/etc') |
696 | 65 | response=MASTER_STR) | ||
697 | 66 | client.run_shell_command( | ||
698 | 67 | 'cp -f /mnt/root/etc/resolv.conf /mnt/root/etc/resolv.conf.bak', | ||
699 | 68 | response=MASTER_STR) | ||
700 | 69 | client.run_shell_command( | ||
701 | 70 | 'cp -L /etc/resolv.conf /mnt/root/etc', | ||
702 | 71 | response=MASTER_STR) | ||
708 | 72 | #eliminate warning: Can not write log, openpty() failed | 64 | #eliminate warning: Can not write log, openpty() failed |
709 | 73 | # (/dev/pts not mounted?), does not work | 65 | # (/dev/pts not mounted?), does not work |
716 | 74 | client.run_shell_command( | 66 | client.run_cmd_master('mount --rbind /dev /mnt/root/dev') |
717 | 75 | 'mount --rbind /dev /mnt/root/dev', | 67 | client.run_cmd_master('chroot /mnt/root apt-get update') |
712 | 76 | response=MASTER_STR) | ||
713 | 77 | client.run_shell_command( | ||
714 | 78 | 'chroot /mnt/root apt-get update', | ||
715 | 79 | response=MASTER_STR) | ||
718 | 80 | #Install necessary packages for build lava-test | 68 | #Install necessary packages for build lava-test |
719 | 81 | cmd = ('chroot /mnt/root apt-get -y install bzr usbutils python-apt ' | 69 | cmd = ('chroot /mnt/root apt-get -y install bzr usbutils python-apt ' |
720 | 82 | 'python-setuptools python-simplejson lsb-release') | 70 | 'python-setuptools python-simplejson lsb-release') |
721 | 83 | client.run_shell_command( | 71 | client.run_shell_command( |
722 | 84 | cmd, | 72 | cmd, |
730 | 85 | response=MASTER_STR, timeout=2400) | 73 | self.client.master_str, 2400) |
731 | 86 | client.run_shell_command( | 74 | client.run_cmd_master('chroot /mnt/root bzr branch lp:lava-test') |
732 | 87 | 'chroot /mnt/root bzr branch lp:lava-test', | 75 | client.run_cmd_master('chroot /mnt/root sh -c ' |
733 | 88 | response=MASTER_STR) | 76 | '"cd lava-test && python setup.py install"') |
727 | 89 | client.run_shell_command( | ||
728 | 90 | 'chroot /mnt/root sh -c "cd lava-test && python setup.py install"', | ||
729 | 91 | response=MASTER_STR) | ||
734 | 92 | 77 | ||
735 | 93 | #Test if lava-test installed | 78 | #Test if lava-test installed |
736 | 94 | try: | 79 | try: |
737 | 95 | client.run_shell_command( | 80 | client.run_shell_command( |
738 | 96 | 'chroot /mnt/root lava-test help', | 81 | 'chroot /mnt/root lava-test help', |
740 | 97 | response="list-tests", timeout=10) | 82 | "list-tests", 10) |
741 | 98 | except: | 83 | except: |
742 | 99 | tb = traceback.format_exc() | 84 | tb = traceback.format_exc() |
743 | 100 | client.sio.write(tb) | 85 | client.sio.write(tb) |
744 | 101 | raise OperationFailed("lava-test deployment failed") | 86 | raise OperationFailed("lava-test deployment failed") |
745 | 102 | 87 | ||
746 | 103 | for test in tests: | 88 | for test in tests: |
750 | 104 | client.run_shell_command( | 89 | client.run_cmd_master('chroot /mnt/root lava-test install %s' % test) |
748 | 105 | 'chroot /mnt/root lava-test install %s' % test, | ||
749 | 106 | response=MASTER_STR) | ||
751 | 107 | #clean up | 90 | #clean up |
758 | 108 | client.run_shell_command( | 91 | client.run_cmd_master('cp -f /mnt/root/etc/resolv.conf.bak ' |
759 | 109 | 'cp -f /mnt/root/etc/resolv.conf.bak /mnt/root/etc/resolv.conf', | 92 | '/mnt/root/etc/resolv.conf') |
760 | 110 | response=MASTER_STR) | 93 | client.run_cmd_master('rm -rf /mnt/root/lava-test') |
755 | 111 | client.run_shell_command( | ||
756 | 112 | 'rm -rf /mnt/root/lava-test', | ||
757 | 113 | response=MASTER_STR) | ||
761 | 114 | cmd = ('cat /proc/mounts | awk \'{print $2}\' | grep "^/mnt/root/dev"' | 94 | cmd = ('cat /proc/mounts | awk \'{print $2}\' | grep "^/mnt/root/dev"' |
762 | 115 | '| sort -r | xargs umount') | 95 | '| sort -r | xargs umount') |
769 | 116 | client.run_shell_command( | 96 | client.run_cmd_master(cmd) |
770 | 117 | cmd, | 97 | client.run_cmd_master('umount /mnt/root') |
765 | 118 | response=MASTER_STR) | ||
766 | 119 | client.run_shell_command( | ||
767 | 120 | 'umount /mnt/root', | ||
768 | 121 | response=MASTER_STR) | ||
771 | 122 | 98 | ||
772 | === modified file 'lava_dispatcher/android_client.py' | |||
773 | --- lava_dispatcher/android_client.py 2011-07-20 04:45:23 +0000 | |||
774 | +++ lava_dispatcher/android_client.py 2011-08-09 14:40:36 +0000 | |||
775 | @@ -42,7 +42,7 @@ | |||
776 | 42 | """ Check that we are in a shell on the test image | 42 | """ Check that we are in a shell on the test image |
777 | 43 | """ | 43 | """ |
778 | 44 | self.proc.sendline("") | 44 | self.proc.sendline("") |
780 | 45 | id = self.proc.expect([TESTER_STR , pexpect.TIMEOUT]) | 45 | id = self.proc.expect([self.tester_str , pexpect.TIMEOUT]) |
781 | 46 | if id == 1: | 46 | if id == 1: |
782 | 47 | raise OperationFailed | 47 | raise OperationFailed |
783 | 48 | 48 | ||
784 | @@ -109,7 +109,7 @@ | |||
785 | 109 | network_interface = self.board.network_interface | 109 | network_interface = self.board.network_interface |
786 | 110 | try: | 110 | try: |
787 | 111 | self.run_shell_command('netcfg %s dhcp' % \ | 111 | self.run_shell_command('netcfg %s dhcp' % \ |
789 | 112 | network_interface, response = TESTER_STR, timeout = 60) | 112 | network_interface, self.tester_str, 60) |
790 | 113 | except: | 113 | except: |
791 | 114 | print "netcfg %s dhcp exception" % network_interface | 114 | print "netcfg %s dhcp exception" % network_interface |
792 | 115 | return False | 115 | return False |
793 | @@ -120,7 +120,7 @@ | |||
794 | 120 | self.proc.sendline('') | 120 | self.proc.sendline('') |
795 | 121 | self.proc.sendline(cmd) | 121 | self.proc.sendline(cmd) |
796 | 122 | try: | 122 | try: |
798 | 123 | id = self.proc.expect([ip_pattern, pexpect.EOF], timeout = 60) | 123 | id = self.proc.expect([ip_pattern, pexpect.EOF], timeout=60) |
799 | 124 | except: | 124 | except: |
800 | 125 | print "ifconfig can not match ip pattern" | 125 | print "ifconfig can not match ip pattern" |
801 | 126 | return False | 126 | return False |
802 | 127 | 127 | ||
803 | === modified file 'lava_dispatcher/client.py' | |||
804 | --- lava_dispatcher/client.py 2011-07-21 16:47:16 +0000 | |||
805 | +++ lava_dispatcher/client.py 2011-08-09 14:40:36 +0000 | |||
806 | @@ -33,6 +33,8 @@ | |||
807 | 33 | 33 | ||
808 | 34 | class LavaClient(object): | 34 | class LavaClient(object): |
809 | 35 | def __init__(self, hostname): | 35 | def __init__(self, hostname): |
810 | 36 | self._master_str = MASTER_STR | ||
811 | 37 | self._tester_str = TESTER_STR | ||
812 | 36 | cmd = "conmux-console %s" % hostname | 38 | cmd = "conmux-console %s" % hostname |
813 | 37 | self.sio = SerialIO(sys.stdout) | 39 | self.sio = SerialIO(sys.stdout) |
814 | 38 | self.proc = pexpect.spawn(cmd, timeout=3600, logfile=self.sio) | 40 | self.proc = pexpect.spawn(cmd, timeout=3600, logfile=self.sio) |
815 | @@ -42,11 +44,19 @@ | |||
816 | 42 | # will eventually come from the database | 44 | # will eventually come from the database |
817 | 43 | self.board = BOARDS[hostname] | 45 | self.board = BOARDS[hostname] |
818 | 44 | 46 | ||
819 | 47 | @property | ||
820 | 48 | def master_str(self): | ||
821 | 49 | return self._master_str | ||
822 | 50 | |||
823 | 51 | @property | ||
824 | 52 | def tester_str(self): | ||
825 | 53 | return self._tester_str | ||
826 | 54 | |||
827 | 45 | def in_master_shell(self): | 55 | def in_master_shell(self): |
828 | 46 | """ Check that we are in a shell on the master image | 56 | """ Check that we are in a shell on the master image |
829 | 47 | """ | 57 | """ |
830 | 48 | self.proc.sendline("") | 58 | self.proc.sendline("") |
832 | 49 | id = self.proc.expect([MASTER_STR, pexpect.TIMEOUT]) | 59 | id = self.proc.expect([self.master_str, pexpect.TIMEOUT]) |
833 | 50 | if id == 1: | 60 | if id == 1: |
834 | 51 | raise OperationFailed | 61 | raise OperationFailed |
835 | 52 | 62 | ||
836 | @@ -54,7 +64,7 @@ | |||
837 | 54 | """ Check that we are in a shell on the test image | 64 | """ Check that we are in a shell on the test image |
838 | 55 | """ | 65 | """ |
839 | 56 | self.proc.sendline("") | 66 | self.proc.sendline("") |
841 | 57 | id = self.proc.expect([TESTER_STR, pexpect.TIMEOUT]) | 67 | id = self.proc.expect([self.tester_str, pexpect.TIMEOUT]) |
842 | 58 | if id == 1: | 68 | if id == 1: |
843 | 59 | raise OperationFailed | 69 | raise OperationFailed |
844 | 60 | 70 | ||
845 | @@ -109,11 +119,17 @@ | |||
846 | 109 | if response: | 119 | if response: |
847 | 110 | self.proc.expect(response, timeout=timeout) | 120 | self.proc.expect(response, timeout=timeout) |
848 | 111 | 121 | ||
849 | 122 | def run_cmd_master(self, cmd): | ||
850 | 123 | self.run_shell_command(cmd, self.master_str) | ||
851 | 124 | |||
852 | 125 | def run_cmd_tester(self, cmd): | ||
853 | 126 | self.run_shell_command(cmd, self.tester_str) | ||
854 | 127 | |||
855 | 112 | def check_network_up(self): | 128 | def check_network_up(self): |
856 | 113 | self.proc.sendline("LC_ALL=C ping -W4 -c1 %s" % LAVA_SERVER_IP) | 129 | self.proc.sendline("LC_ALL=C ping -W4 -c1 %s" % LAVA_SERVER_IP) |
857 | 114 | id = self.proc.expect(["1 received", "0 received", | 130 | id = self.proc.expect(["1 received", "0 received", |
858 | 115 | "Network is unreachable"], timeout=5) | 131 | "Network is unreachable"], timeout=5) |
860 | 116 | self.proc.expect(MASTER_STR) | 132 | self.proc.expect(self.master_str) |
861 | 117 | if id == 0: | 133 | if id == 0: |
862 | 118 | return True | 134 | return True |
863 | 119 | else: | 135 | else: |
864 | @@ -128,14 +144,12 @@ | |||
865 | 128 | 144 | ||
866 | 129 | def export_display(self): | 145 | def export_display(self): |
867 | 130 | #export the display, ignore errors on non-graphical images | 146 | #export the display, ignore errors on non-graphical images |
871 | 131 | self.run_shell_command("su - linaro -c 'DISPLAY=:0 xhost local:'", | 147 | self.run_cmd_tester("su - linaro -c 'DISPLAY=:0 xhost local:'") |
872 | 132 | response=TESTER_STR) | 148 | self.run_cmd_tester("export DISPLAY=:0") |
870 | 133 | self.run_shell_command("export DISPLAY=:0", response=TESTER_STR) | ||
873 | 134 | 149 | ||
874 | 135 | def get_seriallog(self): | 150 | def get_seriallog(self): |
875 | 136 | return self.sio.getvalue() | 151 | return self.sio.getvalue() |
876 | 137 | 152 | ||
877 | 138 | |||
878 | 139 | class SerialIO(file): | 153 | class SerialIO(file): |
879 | 140 | def __init__(self, logfile): | 154 | def __init__(self, logfile): |
880 | 141 | self.serialio = StringIO() | 155 | self.serialio = StringIO() |
881 | 142 | 156 | ||
882 | === modified file 'lava_dispatcher/config.py' | |||
883 | --- lava_dispatcher/config.py 2011-07-21 16:47:16 +0000 | |||
884 | +++ lava_dispatcher/config.py 2011-08-09 14:40:36 +0000 | |||
885 | @@ -18,6 +18,16 @@ | |||
886 | 18 | # along | 18 | # along |
887 | 19 | # with this program; if not, see <http://www.gnu.org/licenses>. | 19 | # with this program; if not, see <http://www.gnu.org/licenses>. |
888 | 20 | 20 | ||
889 | 21 | import json | ||
890 | 22 | import os | ||
891 | 23 | |||
892 | 24 | def get_host(hostname): | ||
893 | 25 | cfg_path = 'config/hosts/' | ||
894 | 26 | cfg_file = cfg_path + hostname + '.json' | ||
895 | 27 | host_file = os.path.join(os.curdir, cfg_file) | ||
896 | 28 | with open(host_file, 'r') as fp: | ||
897 | 29 | return json.load(fp) | ||
898 | 30 | |||
899 | 21 | """ | 31 | """ |
900 | 22 | This is an ugly hack, the uboot commands for a given board type and the board | 32 | This is an ugly hack, the uboot commands for a given board type and the board |
901 | 23 | type of a test machine need to come from the device registry. This is an | 33 | type of a test machine need to come from the device registry. This is an |
902 | 24 | 34 | ||
903 | === added file 'lava_dispatcher/qemu_client.py' | |||
904 | --- lava_dispatcher/qemu_client.py 1970-01-01 00:00:00 +0000 | |||
905 | +++ lava_dispatcher/qemu_client.py 2011-08-09 14:40:36 +0000 | |||
906 | @@ -0,0 +1,135 @@ | |||
907 | 1 | # Copyright (C) 2011 Calxeda, Inc. | ||
908 | 2 | # | ||
909 | 3 | # This file is part of LAVA Dispatcher. | ||
910 | 4 | # | ||
911 | 5 | # LAVA Dispatcher is free software; you can redistribute it and/or modify | ||
912 | 6 | # it under the terms of the GNU General Public License as published by | ||
913 | 7 | # the Free Software Foundation; either version 2 of the License, or | ||
914 | 8 | # (at your option) any later version. | ||
915 | 9 | # | ||
916 | 10 | # LAVA Dispatcher is distributed in the hope that it will be useful, | ||
917 | 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
918 | 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
919 | 13 | # GNU General Public License for more details. | ||
920 | 14 | # | ||
921 | 15 | # You should have received a copy of the GNU General Public License | ||
922 | 16 | # along with this program; if not, see <http://www.gnu.org/licenses>. | ||
923 | 17 | |||
924 | 18 | import pexpect | ||
925 | 19 | import sys | ||
926 | 20 | from lava_dispatcher.config import get_host | ||
927 | 21 | from lava_dispatcher.client import LavaClient, SerialIO | ||
928 | 22 | from lava_dispatcher.qemu_config import QEMU_PATH, MASTER_STR, TESTER_STR | ||
929 | 23 | |||
930 | 24 | |||
931 | 25 | class LavaQEMUClient(LavaClient): | ||
932 | 26 | |||
933 | 27 | def __init__(self, hostname): | ||
934 | 28 | self.sio = SerialIO(sys.stdout) | ||
935 | 29 | self.hostname = hostname | ||
936 | 30 | self.host_config = get_host(hostname) | ||
937 | 31 | |||
938 | 32 | self.start_qemu() | ||
939 | 33 | |||
940 | 34 | # Should U-Boot automatically to master image | ||
941 | 35 | self.proc.expect("Starting kernel") | ||
942 | 36 | |||
943 | 37 | # will eventually come from the database | ||
944 | 38 | self.board = self.board_type | ||
945 | 39 | self._master_str = MASTER_STR | ||
946 | 40 | self._tester_str = TESTER_STR | ||
947 | 41 | self.in_master_shell() | ||
948 | 42 | |||
949 | 43 | @property | ||
950 | 44 | def macaddr(self): | ||
951 | 45 | return self.host_config.get('qemu_macaddr') | ||
952 | 46 | |||
953 | 47 | @property | ||
954 | 48 | def disk(self): | ||
955 | 49 | return self.host_config.get('qemu_disk') | ||
956 | 50 | |||
957 | 51 | @property | ||
958 | 52 | def board_type(self): | ||
959 | 53 | return self.host_config.get('board_type') | ||
960 | 54 | |||
961 | 55 | @property | ||
962 | 56 | def vlan_number(self): | ||
963 | 57 | return self.host_config.get('vlan_number') | ||
964 | 58 | |||
965 | 59 | @property | ||
966 | 60 | def boot_image(self): | ||
967 | 61 | return self.host_config.get('boot_image') | ||
968 | 62 | |||
969 | 63 | @property | ||
970 | 64 | def machine_type(self): | ||
971 | 65 | return self.host_config.get('machine_type') | ||
972 | 66 | |||
973 | 67 | @property | ||
974 | 68 | def additional_options(self): | ||
975 | 69 | return self.host_config.get('additional_options') | ||
976 | 70 | |||
977 | 71 | @property | ||
978 | 72 | def network_arguments(self): | ||
979 | 73 | if(self.vlan_number is not None and | ||
980 | 74 | self.macaddr is not None): | ||
981 | 75 | return ("-net nic,vlan=%d,macaddr=%s -net vde,vlan=%d " % | ||
982 | 76 | (self.vlan_number, self.macaddr, self.vlan_number)) | ||
983 | 77 | else: | ||
984 | 78 | return "" | ||
985 | 79 | |||
986 | 80 | @property | ||
987 | 81 | def disk_arguments(self): | ||
988 | 82 | if(self.disk is not None): | ||
989 | 83 | return ('-drive id=disk,if=ide,file=%s ' | ||
990 | 84 | '-device ide-drive,drive=disk,bus=ide.0' % self.disk) | ||
991 | 85 | else: | ||
992 | 86 | return "" | ||
993 | 87 | |||
994 | 88 | def start_qemu(self): | ||
995 | 89 | cmd = ("%sqemu-system-arm %s -M %s -kernel %s " % | ||
996 | 90 | (QEMU_PATH, self.additional_options, self.machine_type, | ||
997 | 91 | self.boot_image)) | ||
998 | 92 | cmd += self.network_arguments | ||
999 | 93 | cmd += self.disk_arguments | ||
1000 | 94 | |||
1001 | 95 | print "Starting QEMU:\n\t%s\n\n" % cmd | ||
1002 | 96 | self.proc = pexpect.spawn(cmd, timeout=7200, logfile=self.sio) | ||
1003 | 97 | self.proc.delaybeforesend=1 | ||
1004 | 98 | |||
1005 | 99 | def boot_master_image(self): | ||
1006 | 100 | """ reboot the system, and check that we are in a master shell | ||
1007 | 101 | """ | ||
1008 | 102 | self.hard_reboot() | ||
1009 | 103 | try: | ||
1010 | 104 | # Necessary to get past U-Boot | ||
1011 | 105 | self.proc.expect("Starting kernel") | ||
1012 | 106 | self.in_master_shell() | ||
1013 | 107 | except: | ||
1014 | 108 | raise | ||
1015 | 109 | |||
1016 | 110 | def boot_linaro_image(self): | ||
1017 | 111 | """ Reboot the system to the test image | ||
1018 | 112 | """ | ||
1019 | 113 | self.hard_reboot() | ||
1020 | 114 | self.enter_uboot() | ||
1021 | 115 | uboot_cmds = self.board.uboot_cmds | ||
1022 | 116 | self.proc.sendline(uboot_cmds[0]) | ||
1023 | 117 | for cmd in uboot_cmd[1:]: | ||
1024 | 118 | if self.board.type in ["mx51evk", "mx53loco"]: | ||
1025 | 119 | self.proc.expect(">") | ||
1026 | 120 | else: | ||
1027 | 121 | self.proc.expect("#") | ||
1028 | 122 | self.proc.sendline(cmd) | ||
1029 | 123 | self.in_test_shell() | ||
1030 | 124 | |||
1031 | 125 | def soft_reboot(self): | ||
1032 | 126 | # Assume soft reboot will not work | ||
1033 | 127 | pass | ||
1034 | 128 | |||
1035 | 129 | def hard_reboot(self): | ||
1036 | 130 | self.proc.sendline("reboot") | ||
1037 | 131 | self.proc.expect([pexpect.TIMEOUT], timeout=60) | ||
1038 | 132 | self.proc.sendcontrol('a') | ||
1039 | 133 | self.proc.send('x') | ||
1040 | 134 | self.start_qemu() | ||
1041 | 135 | |||
1042 | 0 | 136 | ||
1043 | === added file 'lava_dispatcher/qemu_config.py' | |||
1044 | --- lava_dispatcher/qemu_config.py 1970-01-01 00:00:00 +0000 | |||
1045 | +++ lava_dispatcher/qemu_config.py 2011-08-09 14:40:36 +0000 | |||
1046 | @@ -0,0 +1,20 @@ | |||
1047 | 1 | # Copyright (C) 2011 Calxeda, Inc. | ||
1048 | 2 | # | ||
1049 | 3 | # This file is part of LAVA Dispatcher. | ||
1050 | 4 | # | ||
1051 | 5 | # LAVA Dispatcher is free software; you can redistribute it and/or modify | ||
1052 | 6 | # it under the terms of the GNU General Public License as published by | ||
1053 | 7 | # the Free Software Foundation; either version 2 of the License, or | ||
1054 | 8 | # (at your option) any later version. | ||
1055 | 9 | # | ||
1056 | 10 | # LAVA Dispatcher is distributed in the hope that it will be useful, | ||
1057 | 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1058 | 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1059 | 13 | # GNU General Public License for more details. | ||
1060 | 14 | # | ||
1061 | 15 | # You should have received a copy of the GNU General Public License | ||
1062 | 16 | # along with this program; if not, see <http://www.gnu.org/licenses>. | ||
1063 | 17 | |||
1064 | 18 | from lava_dispatcher.config import MASTER_STR, TESTER_STR | ||
1065 | 19 | |||
1066 | 20 | QEMU_PATH = "" | ||
1067 | 0 | 21 | ||
1068 | === added file 'lava_dispatcher/ssh_client.py' | |||
1069 | --- lava_dispatcher/ssh_client.py 1970-01-01 00:00:00 +0000 | |||
1070 | +++ lava_dispatcher/ssh_client.py 2011-08-09 14:40:36 +0000 | |||
1071 | @@ -0,0 +1,75 @@ | |||
1072 | 1 | # Copyright (C) 2011 Calxeda, Inc. | ||
1073 | 2 | # | ||
1074 | 3 | # This file is part of LAVA Dispatcher. | ||
1075 | 4 | # | ||
1076 | 5 | # LAVA Dispatcher is free software; you can redistribute it and/or modify | ||
1077 | 6 | # it under the terms of the GNU General Public License as published by | ||
1078 | 7 | # the Free Software Foundation; either version 2 of the License, or | ||
1079 | 8 | # (at your option) any later version. | ||
1080 | 9 | # | ||
1081 | 10 | # LAVA Dispatcher is distributed in the hope that it will be useful, | ||
1082 | 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1083 | 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1084 | 13 | # GNU General Public License for more details. | ||
1085 | 14 | # | ||
1086 | 15 | # You should have received a copy of the GNU General Public License | ||
1087 | 16 | # along with this program; if not, see <http://www.gnu.org/licenses>. | ||
1088 | 17 | |||
1089 | 18 | import pexpect | ||
1090 | 19 | import sys | ||
1091 | 20 | from lava_dispatcher.client import LavaClient, SerialIO | ||
1092 | 21 | from lava_dispatcher.config import get_host | ||
1093 | 22 | import pxssh | ||
1094 | 23 | |||
1095 | 24 | |||
1096 | 25 | class LavaSSHClient(LavaClient): | ||
1097 | 26 | |||
1098 | 27 | def __init__(self, hostname): | ||
1099 | 28 | self.sio = SerialIO(sys.stdout) | ||
1100 | 29 | self.host_config = get_host(hostname) | ||
1101 | 30 | try: | ||
1102 | 31 | self.proc = pxssh.pxssh(logfile=self.sio) | ||
1103 | 32 | self.proc.login(hostname, self.username, self.password) | ||
1104 | 33 | self.proc.prompt() | ||
1105 | 34 | except pxssh.ExceptionPxssh: | ||
1106 | 35 | raise OperationFailed() | ||
1107 | 36 | |||
1108 | 37 | @property | ||
1109 | 38 | def username(self): | ||
1110 | 39 | return self.host_config['username'] | ||
1111 | 40 | |||
1112 | 41 | @property | ||
1113 | 42 | def password(self): | ||
1114 | 43 | return self.host_config['password'] | ||
1115 | 44 | |||
1116 | 45 | @property | ||
1117 | 46 | def master_str(self): | ||
1118 | 47 | return self.proc.PROMPT | ||
1119 | 48 | |||
1120 | 49 | @property | ||
1121 | 50 | def tester_str(self): | ||
1122 | 51 | return self.proc.PROMPT | ||
1123 | 52 | |||
1124 | 53 | def soft_reboot(self): | ||
1125 | 54 | self.run_shell_command('reboot', sudo=True) | ||
1126 | 55 | |||
1127 | 56 | def hard_reboot(self): | ||
1128 | 57 | """ No way to hard reboot through ssh """ | ||
1129 | 58 | msg = "hard_reboot is not supported by LavaSSHClient" | ||
1130 | 59 | raise OperationFailed(msg) | ||
1131 | 60 | |||
1132 | 61 | def simple_command(self, cmd, timeout=5): | ||
1133 | 62 | self.run_shell_command(cmd, timeout=timeout) | ||
1134 | 63 | |||
1135 | 64 | def run_shell_command(self, cmd, response=None, timeout=-1, sudo=False): | ||
1136 | 65 | expectations = [pexpect.TIMEOUT if not response else response] | ||
1137 | 66 | if sudo: | ||
1138 | 67 | cmd = 'sudo ' + cmd | ||
1139 | 68 | pw_req = "password for %s:" % self.get_username() | ||
1140 | 69 | expectations.append(pw_req) | ||
1141 | 70 | |||
1142 | 71 | self.proc.sendline(cmd) | ||
1143 | 72 | i = self.proc.expect(expectations, timeout=timeout) | ||
1144 | 73 | if i != 0: # pexpect matched pw_req | ||
1145 | 74 | self.proc.sendline(self.get_password()) | ||
1146 | 75 | self.proc.expect(expecting[:-1], timeout=timeout) | ||
1147 | 0 | 76 | ||
1148 | === added file 'lava_dispatcher/ssh_config.py' | |||
1149 | --- lava_dispatcher/ssh_config.py 1970-01-01 00:00:00 +0000 | |||
1150 | +++ lava_dispatcher/ssh_config.py 2011-08-09 14:40:36 +0000 | |||
1151 | @@ -0,0 +1,18 @@ | |||
1152 | 1 | # Copyright (C) 2011 Calxeda, Inc. | ||
1153 | 2 | # | ||
1154 | 3 | # This file is part of LAVA Dispatcher. | ||
1155 | 4 | # | ||
1156 | 5 | # LAVA Dispatcher is free software; you can redistribute it and/or modify | ||
1157 | 6 | # it under the terms of the GNU General Public License as published by | ||
1158 | 7 | # the Free Software Foundation; either version 2 of the License, or | ||
1159 | 8 | # (at your option) any later version. | ||
1160 | 9 | # | ||
1161 | 10 | # LAVA Dispatcher is distributed in the hope that it will be useful, | ||
1162 | 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1163 | 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1164 | 13 | # GNU General Public License for more details. | ||
1165 | 14 | # | ||
1166 | 15 | # You should have received a copy of the GNU General Public License | ||
1167 | 16 | # along with this program; if not, see <http://www.gnu.org/licenses>. | ||
1168 | 17 | |||
1169 | 18 | CFG_PATH = 'config/hosts/' |
As discussed offline, I'd like to see about merging this with what Yongqin has been working on (https:/ /code.launchpad .net/~liuyq0307 /lava-dispatche r/test- client/ +merge/ 69757) and make the config read from a file for the boards and specific machines. One general comment here... You seem to want the job to specify the type of client to use, but I'm betting that each test machine is only going to use pretty much one type of client. Can you envision a case where you might have a conmux client that you want to suddenly use as an ssh client? I don't think it typically makes sense, but if someone has a good reason why this might happen, let me know.
I think what we really want, is a directory containing config details for specific board types:
- bootloader commands to send for booting to the test image
- partition offsets
- possibly even client type specific sections
and a config file listing the boards you have in your environment, and which board_type config to use, along with any specific information, or overrides for that individual system.