Merge lp:~david-schwarz/lava-dispatcher/ssh_qemu_clients_v3 into lp:lava-dispatcher

Proposed by David Schwarz
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
Reviewer Review Type Date Requested Status
Linaro Validation Team Pending
Review via email: mp+70892@code.launchpad.net

Description of the change

This is a cleaner version of the ssh_qemu_clients feature branch--the older version was uploaded by mistake.

To post a comment you must log in.
Revision history for this message
Paul Larson (pwlars) wrote :

As discussed offline, I'd like to see about merging this with what Yongqin has been working on (https://code.launchpad.net/~liuyq0307/lava-dispatcher/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.

Revision history for this message
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

Revision history for this message
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://code.launchpad.net/~liuyq0307/lava-dispatcher/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.

Revision history for this message
Paul Larson (pwlars) wrote :

Yep, exactly :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'config'
=== added directory 'config/hosts'
=== added file 'config/hosts/localhost.json'
--- config/hosts/localhost.json 1970-01-01 00:00:00 +0000
+++ config/hosts/localhost.json 2011-08-09 14:40:36 +0000
@@ -0,0 +1,5 @@
1{
2 "board_name": "localhost",
3 "board_type": "BeagleBoard",
4 "hostname": "localhost"
5}
06
=== added file 'config/hosts/qemu1.json'
--- config/hosts/qemu1.json 1970-01-01 00:00:00 +0000
+++ config/hosts/qemu1.json 2011-08-09 14:40:36 +0000
@@ -0,0 +1,11 @@
1{
2 "board_name": "qemu1",
3 "board_type": "BeagleBoard",
4 "hostname": "qemu1",
5 "machine_type": "beagle",
6 "qemu_macaddr": "52:54:00:12:34:56",
7 "qemu_disk": "qemu/linaroDiskMaster",
8 "vlan_number": 0,
9 "boot_image": "qemu/startup.bin",
10 "additional_options": "-nographic -no-reboot "
11}
012
=== added file 'config/hosts/qemu2.json'
--- config/hosts/qemu2.json 1970-01-01 00:00:00 +0000
+++ config/hosts/qemu2.json 2011-08-09 14:40:36 +0000
@@ -0,0 +1,11 @@
1{
2 "board_name": "qemu2",
3 "board_type": "BeagleBoard",
4 "hostname": "qemu2",
5 "machine_type": "beagle",
6 "qemu_macaddr": "12:34:56:78:90:12",
7 "qemu_disk": "qemu/linaroDiskMaster",
8 "vlan_number": 0,
9 "boot_image": "qemu/startup.bin",
10 "additional_options": "-nographic -no-reboot "
11}
012
=== added file 'config/hosts/vs3.json'
--- config/hosts/vs3.json 1970-01-01 00:00:00 +0000
+++ config/hosts/vs3.json 2011-08-09 14:40:36 +0000
@@ -0,0 +1,6 @@
1{
2 "board_name": "vs3",
3 "hostname": "vs3",
4 "username": "test",
5 "password": "test"
6}
07
=== added file 'config/hosts/vs8.json'
--- config/hosts/vs8.json 1970-01-01 00:00:00 +0000
+++ config/hosts/vs8.json 2011-08-09 14:40:36 +0000
@@ -0,0 +1,6 @@
1{
2 "board_name": "vs8",
3 "hostname": "vs8",
4 "username": "test",
5 "password": "test"
6}
07
=== added file 'doc/qemu-ltp-job.json'
--- doc/qemu-ltp-job.json 1970-01-01 00:00:00 +0000
+++ doc/qemu-ltp-job.json 2011-08-09 14:40:36 +0000
@@ -0,0 +1,41 @@
1{
2 "job_name": "qemu_ltp",
3 "target": "qemu1",
4 "target_type": "qemu",
5 "timeout": 18000,
6 "actions": [
7 {
8 "command": "deploy_linaro_image",
9 "parameters":
10 {
11 "rootfs": "http://snapshots.linaro.org/11.05-daily/linaro-developer/20110208/0/images/tar/linaro-n-developer-tar-20110208-0.tar.gz",
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"
13 }
14 },
15 {
16 "command": "lava_test_install",
17 "parameters":
18 {
19 "tests": ["ltp"]
20 }
21 },
22 {
23 "command": "boot_linaro_image"
24 },
25 {
26 "command": "lava_test_run",
27 "parameters":
28 {
29 "test_name": "ltp"
30 }
31 },
32 {
33 "command": "submit_results",
34 "parameters":
35 {
36 "server": "http://validation.linaro.org/launch-control",
37 "stream": "/anonymous/panda01-ltp/"
38 }
39 }
40 ]
41}
042
=== added file 'doc/ssh-ltp-job.json'
--- doc/ssh-ltp-job.json 1970-01-01 00:00:00 +0000
+++ doc/ssh-ltp-job.json 2011-08-09 14:40:36 +0000
@@ -0,0 +1,23 @@
1{
2 "job_name": "ssh_ltp",
3 "target": "vs3",
4 "target_type": "ssh",
5 "timeout": 18000,
6 "actions": [
7 {
8 "command": "lava_test_run",
9 "parameters":
10 {
11 "test_name": "ltp"
12 }
13 },
14 {
15 "command": "submit_results",
16 "parameters":
17 {
18 "server": "http://validation.linaro.org/launch-control",
19 "stream": "/anonymous/panda01-ltp/"
20 }
21 }
22 ]
23}
024
=== modified file 'lava_dispatcher/__init__.py'
--- lava_dispatcher/__init__.py 2011-08-04 07:19:53 +0000
+++ lava_dispatcher/__init__.py 2011-08-09 14:40:36 +0000
@@ -29,6 +29,8 @@
29from lava_dispatcher.actions import get_all_cmds29from lava_dispatcher.actions import get_all_cmds
30from lava_dispatcher.client import LavaClient, CriticalError, GeneralError30from lava_dispatcher.client import LavaClient, CriticalError, GeneralError
31from lava_dispatcher.android_client import LavaAndroidClient31from lava_dispatcher.android_client import LavaAndroidClient
32from lava_dispatcher.qemu_client import LavaQEMUClient
33from lava_dispatcher.ssh_client import LavaSSHClient
3234
33__version__ = "0.1.0"35__version__ = "0.1.0"
3436
@@ -36,19 +38,22 @@
36 def __init__(self, job_json):38 def __init__(self, job_json):
37 self.job_status = 'pass'39 self.job_status = 'pass'
38 self.load_job_data(job_json)40 self.load_job_data(job_json)
39 self.context = LavaContext(self.target, self.image_type)41 self.context = LavaContext(self.target, self.image_type, self.target_type)
4042
41 def load_job_data(self, job_json):43 def load_job_data(self, job_json):
42 self.job_data = json.loads(job_json)44 self.job_data = json.loads(job_json)
4345
44 @property46 @property
45 def target(self):47 def target(self):
46 return self.job_data['target']48 return self.job_data.get('target')
4749
48 @property50 @property
49 def image_type(self):51 def image_type(self):
50 if self.job_data.has_key('image_type'):52 return self.job_data.get('image_type')
51 return self.job_data['image_type']53
54 @property
55 def target_type(self):
56 return self.job_data.get('target_type')
5257
53 def run(self):58 def run(self):
54 lava_commands = get_all_cmds()59 lava_commands = get_all_cmds()
@@ -65,19 +70,26 @@
65 metadata['target.hostname'] = self.target70 metadata['target.hostname'] = self.target
66 self.context.test_data.add_metadata(metadata)71 self.context.test_data.add_metadata(metadata)
67 action = lava_commands[cmd['command']](self.context)72 action = lava_commands[cmd['command']](self.context)
73 except_str = ""
68 try:74 try:
69 status = 'fail'75 status = 'fail'
70 action.run(**params)76 action.run(**params)
71 except CriticalError, err:77 except CriticalError as err:
72 raise err78 except_str = str(err)
73 except (pexpect.TIMEOUT, GeneralError), err:79 raise
80 except (pexpect.TIMEOUT, GeneralError) as err:
81 except_str = str(err)
74 pass82 pass
75 except Exception, err:83 except Exception as err:
84 except_str = str(err)
76 raise85 raise
77 else:86 else:
78 status = 'pass'87 status = 'pass'
79 finally:88 finally:
89 err_msg = ""
90 command = cmd['command']
80 if status == 'fail':91 if status == 'fail':
92<<<<<<< TREE
81 err_msg = "Lava failed at action " + cmd['command'] \93 err_msg = "Lava failed at action " + cmd['command'] \
82 + " with error: " + str(err) + "\n"94 + " with error: " + str(err) + "\n"
83 if cmd['command'] == 'lava_test_run':95 if cmd['command'] == 'lava_test_run':
@@ -91,6 +103,18 @@
91 err_msg = ""103 err_msg = ""
92 self.context.test_data.add_result(cmd['command'], 104 self.context.test_data.add_result(cmd['command'],
93 status, err_msg)105 status, err_msg)
106=======
107 err_msg = "Lava failed at action %s with error: %s\n" %\
108 (command, except_str)
109 if command == 'lava_test_run':
110 err_msg += "Lava failed on test: %s" %\
111 params.get('test_name')
112 exc_type, exc_value, exc_traceback = sys.exc_info()
113 err_msg += repr(traceback.format_tb(exc_traceback))
114 print >> sys.stderr, err_msg
115 self.context.test_data.add_result(command, status, err_msg)
116
117>>>>>>> MERGE-SOURCE
94 except:118 except:
95 #Capture all user-defined and non-user-defined critical errors119 #Capture all user-defined and non-user-defined critical errors
96 self.context.test_data.job_status='fail'120 self.context.test_data.job_status='fail'
@@ -104,11 +128,16 @@
104128
105129
106class LavaContext(object):130class LavaContext(object):
107 def __init__(self, target, image_type):131 def __init__(self, target, image_type, target_type):
108 if image_type != "android":132 if image_type == "android":
133 self._client = LavaAndroidClient(target)
134 elif target_type == "qemu":
135 self._client = LavaQEMUClient(target)
136 elif target_type == "ssh":
137 self._client = LavaSSHClient(target)
138 else:
139 # conmux / serial
109 self._client = LavaClient(target)140 self._client = LavaClient(target)
110 else:
111 self._client = LavaAndroidClient(target)
112 self.test_data = LavaTestData()141 self.test_data = LavaTestData()
113142
114 @property143 @property
@@ -143,8 +172,8 @@
143 self._job_status = status172 self._job_status = status
144173
145 def add_result(self, test_case_id, result, message=""):174 def add_result(self, test_case_id, result, message=""):
146 result_data = { 'test_case_id': test_case_id, 'result': result \175 result_data = {'test_case_id': test_case_id, 'result': result, \
147 , 'message': message}176 'message': message}
148 self._test_run['test_results'].append(result_data)177 self._test_run['test_results'].append(result_data)
149178
150 def add_attachment(self, attachment):179 def add_attachment(self, attachment):
151180
=== modified file 'lava_dispatcher/actions/android_basic.py'
--- lava_dispatcher/actions/android_basic.py 2011-06-27 04:55:08 +0000
+++ lava_dispatcher/actions/android_basic.py 2011-08-09 14:40:36 +0000
@@ -21,7 +21,6 @@
2121
22from lava_dispatcher.actions import BaseAndroidAction22from lava_dispatcher.actions import BaseAndroidAction
23from lava_dispatcher.client import OperationFailed23from lava_dispatcher.client import OperationFailed
24from lava_dispatcher.android_config import TESTER_STR
25import time24import time
26import pexpect25import pexpect
27import sys26import sys
2827
=== modified file 'lava_dispatcher/actions/android_deploy.py'
--- lava_dispatcher/actions/android_deploy.py 2011-08-04 07:19:53 +0000
+++ lava_dispatcher/actions/android_deploy.py 2011-08-09 14:40:36 +0000
@@ -20,7 +20,7 @@
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>.
2121
22from lava_dispatcher.actions import BaseAction22from lava_dispatcher.actions import BaseAction
23from lava_dispatcher.config import LAVA_IMAGE_TMPDIR, LAVA_IMAGE_URL, MASTER_STR23from lava_dispatcher.config import LAVA_IMAGE_TMPDIR, LAVA_IMAGE_URL
24import os24import os
25import sys25import sys
26import shutil26import shutil
@@ -101,156 +101,88 @@
101101
102 def deploy_linaro_android_testboot(self, boottbz2):102 def deploy_linaro_android_testboot(self, boottbz2):
103 client = self.client103 client = self.client
104 client.run_shell_command(104 client.run_cmd_master('mkfs.vfat /dev/disk/by-label/testboot '
105 'mkfs.vfat /dev/disk/by-label/testboot -n testboot',105 '-n testboot')
106 response = MASTER_STR)106 client.run_cmd_master('udevadm trigger')
107 client.run_shell_command(107 client.run_cmd_master('mkdir -p /mnt/lava/boot')
108 'udevadm trigger',108 client.run_cmd_master('mount /dev/disk/by-label/testboot '
109 response = MASTER_STR)109 '/mnt/lava/boot')
110 client.run_shell_command(110 client.run_cmd_master('wget -qO- %s |tar --numeric-owner -C /mnt/lava -xjf -' % boottbz2)
111 'mkdir -p /mnt/lava/boot',
112 response = MASTER_STR)
113 client.run_shell_command(
114 'mount /dev/disk/by-label/testboot /mnt/lava/boot',
115 response = MASTER_STR)
116 client.run_shell_command(
117 'wget -qO- %s |tar --numeric-owner -C /mnt/lava -xjf -' % boottbz2,
118 response = MASTER_STR)
119111
120 self.recreate_uInitrd()112 self.recreate_uInitrd()
121113
122 client.run_shell_command(114 client.run_cmd_master('umount /mnt/lava/boot')
123 'umount /mnt/lava/boot',
124 response = MASTER_STR)
125115
126 def recreate_uInitrd(self):116 def recreate_uInitrd(self):
127 client = self.client117 client = self.client
128 client.run_shell_command(118 client.run_cmd_master('mkdir -p ~/tmp/')
129 'mkdir -p ~/tmp/',119 client.run_cmd_master('mv /mnt/lava/boot/uInitrd ~/tmp')
130 response = MASTER_STR)120 client.run_cmd_master('cd ~/tmp/')
131 client.run_shell_command(121
132 'mv /mnt/lava/boot/uInitrd ~/tmp',122 client.run_cmd_master('mv uInitrd.data ramdisk.cpio.gz')
133 response = MASTER_STR)123 client.run_cmd_master(
134 client.run_shell_command(124 'gzip -d ramdisk.cpio.gz; cpio -i -F ramdisk.cpio')
135 'cd ~/tmp/',125 client.run_cmd_master(
136 response = MASTER_STR)126 'sed -i "/mount ext4 \/dev\/block\/mmcblk0p3/d" init.rc')
137127 client.run_cmd_master(
138 client.run_shell_command(128 'sed -i "/mount ext4 \/dev\/block\/mmcblk0p5/d" init.rc')
139 'dd if=uInitrd of=uInitrd.data ibs=64 skip=1',129 client.run_cmd_master('sed -i "s/mmcblk0p2/mmcblk0p5/g" init.rc')
140 response = MASTER_STR)130 client.run_cmd_master(
141 client.run_shell_command(131 'sed -i "/export PATH/a \ \ \ \ export PS1 root@linaro: " init.rc')
142 'mv uInitrd.data ramdisk.cpio.gz',132
143 response = MASTER_STR)133 client.run_cmd_master(
144 client.run_shell_command(
145 'gzip -d ramdisk.cpio.gz; cpio -i -F ramdisk.cpio',
146 response = MASTER_STR)
147 client.run_shell_command(
148 'sed -i "/mount ext4 \/dev\/block\/mmcblk0p3/d" init.rc',
149 response = MASTER_STR)
150 client.run_shell_command(
151 'sed -i "/mount ext4 \/dev\/block\/mmcblk0p5/d" init.rc',
152 response = MASTER_STR)
153 client.run_shell_command(
154 'sed -i "s/mmcblk0p2/mmcblk0p5/g" init.rc',
155 response = MASTER_STR)
156 client.run_shell_command(
157 'sed -i "/export PATH/a \ \ \ \ export PS1 root@linaro: " init.rc',
158 response = MASTER_STR)
159
160 client.run_shell_command(
161 'cpio -i -t -F ramdisk.cpio | cpio -o -H newc | \134 'cpio -i -t -F ramdisk.cpio | cpio -o -H newc | \
162 gzip > ramdisk_new.cpio.gz',135 gzip > ramdisk_new.cpio.gz')
163 response = MASTER_STR)
164136
165 client.run_shell_command(137 client.run_cmd_master(
166 'mkimage -A arm -O linux -T ramdisk -n "Android Ramdisk Image" \138 'mkimage -A arm -O linux -T ramdisk -n "Android Ramdisk Image" \
167 -d ramdisk_new.cpio.gz uInitrd',139 -d ramdisk_new.cpio.gz uInitrd')
168 response = MASTER_STR)
169140
170 client.run_shell_command(141 client.run_cmd_master('cd -')
171 'cd -',142 client.run_cmd_master('mv ~/tmp/uInitrd /mnt/lava/boot/uInitrd')
172 response = MASTER_STR)143 client.run_cmd_master('rm -rf ~/tmp')
173 client.run_shell_command(
174 'mv ~/tmp/uInitrd /mnt/lava/boot/uInitrd',
175 response = MASTER_STR)
176 client.run_shell_command(
177 'rm -rf ~/tmp',
178 response = MASTER_STR)
179144
180 def deploy_linaro_android_testrootfs(self, systemtbz2):145 def deploy_linaro_android_testrootfs(self, systemtbz2):
181 client = self.client146 client = self.client
182 client.run_shell_command(147 client.run_cmd_master(
183 'mkfs.ext4 -q /dev/disk/by-label/testrootfs -L testrootfs',148 'mkfs.ext4 -q /dev/disk/by-label/testrootfs -L testrootfs')
184 response = MASTER_STR)149 client.run_cmd_master('udevadm trigger')
185 client.run_shell_command(150 client.run_cmd_master('mkdir -p /mnt/lava/system')
186 'udevadm trigger',151 client.run_cmd_master(
187 response = MASTER_STR)152 'mount /dev/disk/by-label/testrootfs /mnt/lava/system')
188 client.run_shell_command(
189 'mkdir -p /mnt/lava/system',
190 response = MASTER_STR)
191 client.run_shell_command(
192 'mount /dev/disk/by-label/testrootfs /mnt/lava/system',
193 response = MASTER_STR)
194 client.run_shell_command(153 client.run_shell_command(
195 'wget -qO- %s |tar --numeric-owner -C /mnt/lava -xjf -' % systemtbz2,154 'wget -qO- %s |tar --numeric-owner -C /mnt/lava -xjf -' % systemtbz2,
196 response = MASTER_STR, timeout = 600)155 client.master_str, 600)
197156
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 " \
199 "/devices/platform/omap/omap_hsmmc.0/mmc_host/mmc0"158 "/devices/platform/omap/omap_hsmmc.0/mmc_host/mmc0"
200 client.run_shell_command(159 client.run_cmd_master(
201 'sed -i "%s" /mnt/lava/system/etc/vold.fstab' % sed_cmd,160 'sed -i "%s" /mnt/lava/system/etc/vold.fstab' % sed_cmd)
202 response = MASTER_STR)161 client.run_cmd_master('umount /mnt/lava/system')
203 client.run_shell_command(
204 'umount /mnt/lava/system',
205 response = MASTER_STR)
206162
207 def purge_linaro_android_sdcard(self):163 def purge_linaro_android_sdcard(self):
208 client = self.client164 client = self.client
209 client.run_shell_command(165 client.run_cmd_master('mkfs.vfat /dev/disk/by-label/sdcard -n sdcard')
210 'mkfs.vfat /dev/disk/by-label/sdcard -n sdcard',166 client.run_cmd_master('udevadm trigger')
211 response = MASTER_STR)
212 client.run_shell_command(
213 'udevadm trigger',
214 response = MASTER_STR)
215167
216 def deploy_linaro_android_system(self, systemtbz2):168 def deploy_linaro_android_system(self, systemtbz2):
217 client = self.client169 client = self.client
218 client.run_shell_command(170 client.run_cmd_master('mkfs.ext4 -q /dev/disk/by-label/system -L system')
219 'mkfs.ext4 -q /dev/disk/by-label/system -L system',171 client.run_cmd_master('udevadm trigger')
220 response = MASTER_STR)172 client.run_cmd_master('mkdir -p /mnt/lava/system')
221 client.run_shell_command(173 client.run_cmd_master('mount /dev/disk/by-label/system /mnt/lava/system')
222 'udevadm trigger',
223 response = MASTER_STR)
224 client.run_shell_command(
225 'mkdir -p /mnt/lava/system',
226 response = MASTER_STR)
227 client.run_shell_command(
228 'mount /dev/disk/by-label/system /mnt/lava/system',
229 response = MASTER_STR)
230 client.run_shell_command(174 client.run_shell_command(
231 'wget -qO- %s |tar --numeric-owner -C /mnt/lava -xjf -' % systemtbz2,175 'wget -qO- %s |tar --numeric-owner -C /mnt/lava -xjf -' % systemtbz2,
232 response = MASTER_STR, timeout = 600)176 client.master_str, 600)
233 client.run_shell_command(177 client.run_cmd_master('umount /mnt/lava/system')
234 'umount /mnt/lava/system',
235 response = MASTER_STR)
236178
237 def deploy_linaro_android_data(self, datatbz2):179 def deploy_linaro_android_data(self, datatbz2):
238 client = self.client180 client = self.client
239 client.run_shell_command(181 client.run_cmd_master('mkfs.ext4 -q /dev/disk/by-label/data -L data')
240 'mkfs.ext4 -q /dev/disk/by-label/data -L data',182 client.run_cmd_master('udevadm trigger')
241 response = MASTER_STR)183 client.run_cmd_master('mkdir -p /mnt/lava/data')
242 client.run_shell_command(184 client.run_cmd_master('mount /dev/disk/by-label/data /mnt/lava/data')
243 'udevadm trigger',
244 response = MASTER_STR)
245 client.run_shell_command(
246 'mkdir -p /mnt/lava/data',
247 response = MASTER_STR)
248 client.run_shell_command(
249 'mount /dev/disk/by-label/data /mnt/lava/data',
250 response = MASTER_STR)
251 client.run_shell_command(185 client.run_shell_command(
252 'wget -qO- %s |tar --numeric-owner -C /mnt/lava -xjf -' % datatbz2,186 'wget -qO- %s |tar --numeric-owner -C /mnt/lava -xjf -' % datatbz2,
253 response = MASTER_STR, timeout = 600)187 client.master_str, 600)
254 client.run_shell_command(188 client.run_cmd_master('umount /mnt/lava/data')
255 'umount /mnt/lava/data',
256 response = MASTER_STR)
257189
=== modified file 'lava_dispatcher/actions/deploy.py'
--- lava_dispatcher/actions/deploy.py 2011-08-04 07:19:53 +0000
+++ lava_dispatcher/actions/deploy.py 2011-08-09 14:40:36 +0000
@@ -27,7 +27,7 @@
27from tempfile import mkdtemp27from tempfile import mkdtemp
2828
29from lava_dispatcher.actions import BaseAction29from lava_dispatcher.actions import BaseAction
30from lava_dispatcher.config import LAVA_IMAGE_TMPDIR, LAVA_IMAGE_URL, MASTER_STR30from lava_dispatcher.config import LAVA_IMAGE_TMPDIR, LAVA_IMAGE_URL
31from lava_dispatcher.utils import download, download_with_cache31from lava_dispatcher.utils import download, download_with_cache
32from lava_dispatcher.client import CriticalError32from lava_dispatcher.client import CriticalError
3333
@@ -126,9 +126,9 @@
126126
127 image_file = os.path.join(tarball_dir, "lava.img")127 image_file = os.path.join(tarball_dir, "lava.img")
128 board = client.board128 board = client.board
129 cmd = ("sudo linaro-media-create --hwpack-force-yes --dev %s "129 cmd = ("sudo linaro-media-create --hwpack-force-yes -dev %s "
130 "--image_file %s --binary %s --hwpack %s --image_size 3G" % (130 "--image_file %s --binary %s --hwpack %s --image_size 3G" %
131 board.type, image_file, rootfs_path, hwpack_path))131 (board.type, image_file, rootfs_path, hwpack_path))
132 rc, output = getstatusoutput(cmd)132 rc, output = getstatusoutput(cmd)
133 if rc:133 if rc:
134 shutil.rmtree(tarball_dir)134 shutil.rmtree(tarball_dir)
@@ -152,46 +152,25 @@
152 def deploy_linaro_rootfs(self, rootfs):152 def deploy_linaro_rootfs(self, rootfs):
153 client = self.client153 client = self.client
154 print "Deploying linaro image"154 print "Deploying linaro image"
155 client.run_shell_command(155 client.run_cmd_master(
156 'mkfs.ext3 -q /dev/disk/by-label/testrootfs -L testrootfs',156 'mkfs.ext3 -q /dev/disk/by-label/testrootfs -L testrootfs')
157 response = MASTER_STR)157 client.run_cmd_master('udevadm trigger')
158 client.run_shell_command(158 client.run_cmd_master('mkdir -p /mnt/root')
159 'udevadm trigger',159 client.run_cmd_master('mount /dev/disk/by-label/testrootfs /mnt/root')
160 response = MASTER_STR)
161 client.run_shell_command(
162 'mkdir -p /mnt/root',
163 response = MASTER_STR)
164 client.run_shell_command(
165 'mount /dev/disk/by-label/testrootfs /mnt/root',
166 response = MASTER_STR)
167 client.run_shell_command(160 client.run_shell_command(
168 'wget -qO- %s |tar --numeric-owner -C /mnt/root -xzf -' % rootfs,161 'wget -qO- %s |tar --numeric-owner -C /mnt/root -xzf -' % rootfs,
169 response = MASTER_STR, timeout = 3600)162 client.master_str, 3600)
170 client.run_shell_command(163 client.run_cmd_master('echo linaro > /mnt/root/etc/hostname')
171 'echo linaro > /mnt/root/etc/hostname',164 client.run_cmd_master('umount /mnt/root')
172 response = MASTER_STR)
173 client.run_shell_command(
174 'umount /mnt/root',
175 response = MASTER_STR)
176165
177 def deploy_linaro_bootfs(self, bootfs):166 def deploy_linaro_bootfs(self, bootfs):
178 client = self.client167 client = self.client
179 client.run_shell_command(168 client.run_cmd_master(
180 'mkfs.vfat /dev/disk/by-label/testboot -n testboot',169 'mkfs.vfat /dev/disk/by-label/testboot -n testboot')
181 response = MASTER_STR)170 client.run_cmd_master('udevadm trigger')
182 client.run_shell_command(171 client.run_cmd_master('mkdir -p /mnt/boot')
183 'udevadm trigger',172 client.run_cmd_master('mount /dev/disk/by-label/testboot /mnt/boot')
184 response = MASTER_STR)173 client.run_cmd_master(
185 client.run_shell_command(174 'wget -qO- %s |tar --numeric-owner -C /mnt/boot -xzf -' % bootfs)
186 'mkdir -p /mnt/boot',175 client.run_cmd_master('umount /mnt/boot')
187 response = MASTER_STR)
188 client.run_shell_command(
189 'mount /dev/disk/by-label/testboot /mnt/boot',
190 response = MASTER_STR)
191 client.run_shell_command(
192 'wget -qO- %s |tar --numeric-owner -C /mnt/boot -xzf -' % bootfs,
193 response = MASTER_STR)
194 client.run_shell_command(
195 'umount /mnt/boot',
196 response = MASTER_STR)
197176
198177
=== modified file 'lava_dispatcher/actions/launch_control.py'
--- lava_dispatcher/actions/launch_control.py 2011-06-27 04:55:08 +0000
+++ lava_dispatcher/actions/launch_control.py 2011-08-09 14:40:36 +0000
@@ -22,7 +22,7 @@
2222
23import json23import json
24from lava_dispatcher.actions import BaseAction24from lava_dispatcher.actions import BaseAction
25from lava_dispatcher.config import LAVA_RESULT_DIR, MASTER_STR, LAVA_SERVER_IP25from lava_dispatcher.config import LAVA_RESULT_DIR, LAVA_SERVER_IP
26import socket26import socket
27from threading import Thread27from threading import Thread
28import time28import time
@@ -84,32 +84,26 @@
84 except:84 except:
85 client.boot_master_image()85 client.boot_master_image()
8686
87 client.run_shell_command(87 client.run_cmd_master('mkdir -p /mnt/root')
88 'mkdir -p /mnt/root', response = MASTER_STR)88 client.run_cmd_master(
89 client.run_shell_command(89 'mount /dev/disk/by-label/%s /mnt/root' % result_disk)
90 'mount /dev/disk/by-label/%s /mnt/root' % result_disk,90 client.run_cmd_master('mkdir -p /tmp/%s' % LAVA_RESULT_DIR)
91 response = MASTER_STR)91 client.run_cmd_master(
92 client.run_shell_command(
93 'mkdir -p /tmp/%s' % LAVA_RESULT_DIR, response = MASTER_STR)
94 client.run_shell_command(
95 'cp /mnt/root/%s/*.bundle /tmp/%s' % (LAVA_RESULT_DIR,92 'cp /mnt/root/%s/*.bundle /tmp/%s' % (LAVA_RESULT_DIR,
96 LAVA_RESULT_DIR), response = MASTER_STR)93 LAVA_RESULT_DIR))
97 client.run_shell_command('umount /mnt/root', response = MASTER_STR)94 client.run_cmd_master('umount /mnt/root')
9895
99 #Upload bundle list-bundle.lst96 #Upload bundle list-bundle.lst
100 client.run_shell_command('cd /tmp/%s' % LAVA_RESULT_DIR,97 client.run_cmd_master('cd /tmp/%s' % LAVA_RESULT_DIR)
101 response = MASTER_STR)98 client.run_cmd_master('ls *.bundle > bundle.lst')
102 client.run_shell_command('ls *.bundle > bundle.lst',
103 response = MASTER_STR)
10499
105 t = ResultUploader()100 t = ResultUploader()
106 t.start()101 t.start()
107 #XXX: Odd problem where we sometimes get stuck here. This is just102 #XXX: Odd problem where we sometimes get stuck here. This is just
108 # a hacky workaround to see if it's a race103 # a hacky workaround to see if it's a race
109 time.sleep(60)104 time.sleep(60)
110 client.run_shell_command(105 client.run_cmd_master('cat bundle.lst |nc %s %d' %
111 'cat bundle.lst |nc %s %d' % (LAVA_SERVER_IP, t.get_port()),106 (LAVA_SERVER_IP, t.get_port()))
112 response = MASTER_STR)
113 t.join()107 t.join()
114108
115 bundle_list = t.get_data().strip().splitlines()109 bundle_list = t.get_data().strip().splitlines()
@@ -124,10 +118,9 @@
124 #XXX: Odd problem where we sometimes get stuck here. This is just118 #XXX: Odd problem where we sometimes get stuck here. This is just
125 # a hacky workaround to see if it's a race119 # a hacky workaround to see if it's a race
126 time.sleep(60)120 time.sleep(60)
127 client.run_shell_command(121 client.run_cmd_master(
128 'cat /tmp/%s/%s | nc %s %s' % (LAVA_RESULT_DIR, bundle,122 'cat /tmp/%s/%s | nc %s %s' % (LAVA_RESULT_DIR, bundle,
129 LAVA_SERVER_IP, t.get_port()),123 LAVA_SERVER_IP, t.get_port()))
130 response = MASTER_STR)
131 t.join()124 t.join()
132 content = t.get_data()125 content = t.get_data()
133126
134127
=== modified file 'lava_dispatcher/actions/lava-test.py'
--- lava_dispatcher/actions/lava-test.py 2011-08-04 07:19:53 +0000
+++ lava_dispatcher/actions/lava-test.py 2011-08-09 14:40:36 +0000
@@ -25,7 +25,7 @@
25import traceback25import traceback
26from lava_dispatcher.actions import BaseAction26from lava_dispatcher.actions import BaseAction
27from lava_dispatcher.client import OperationFailed27from lava_dispatcher.client import OperationFailed
28from lava_dispatcher.config import LAVA_RESULT_DIR, MASTER_STR, TESTER_STR28from lava_dispatcher.config import LAVA_RESULT_DIR
2929
3030
31class cmd_lava_test_run(BaseAction):31class cmd_lava_test_run(BaseAction):
@@ -33,14 +33,13 @@
33 #Make sure in test image now33 #Make sure in test image now
34 client = self.client34 client = self.client
35 client.in_test_shell()35 client.in_test_shell()
36 client.run_shell_command('mkdir -p %s' % LAVA_RESULT_DIR,36 client.run_cmd_tester('mkdir -p %s' % LAVA_RESULT_DIR)
37 response=TESTER_STR)
38 client.export_display()37 client.export_display()
39 bundle_name = test_name + "-" + datetime.now().strftime("%H%M%S")38 bundle_name = test_name + "-" + datetime.now().strftime("%H%M%S")
40 client.run_shell_command(39 client.run_shell_command(
41 'lava-test run %s -o %s/%s.bundle' % (40 'lava-test run %s -o %s/%s.bundle' % (
42 test_name, LAVA_RESULT_DIR, bundle_name),41 test_name, LAVA_RESULT_DIR, bundle_name),
43 response=TESTER_STR, timeout=timeout)42 client.tester_str, timeout)
4443
4544
46class cmd_lava_test_install(BaseAction):45class cmd_lava_test_install(BaseAction):
@@ -57,65 +56,42 @@
57 client.boot_master_image()56 client.boot_master_image()
5857
59 #install bazaar in tester image58 #install bazaar in tester image
60 client.run_shell_command(59 client.run_cmd_master('mkdir -p /mnt/root')
61 'mkdir -p /mnt/root',60 client.run_cmd_master('mount /dev/disk/by-label/testrootfs /mnt/root')
62 response=MASTER_STR)61 client.run_cmd_master('cp -f /mnt/root/etc/resolv.conf '
63 client.run_shell_command(62 '/mnt/root/etc/resolv.conf.bak')
64 'mount /dev/disk/by-label/testrootfs /mnt/root',63 client.run_cmd_master('cp -L /etc/resolv.conf /mnt/root/etc')
65 response=MASTER_STR)
66 client.run_shell_command(
67 'cp -f /mnt/root/etc/resolv.conf /mnt/root/etc/resolv.conf.bak',
68 response=MASTER_STR)
69 client.run_shell_command(
70 'cp -L /etc/resolv.conf /mnt/root/etc',
71 response=MASTER_STR)
72 #eliminate warning: Can not write log, openpty() failed64 #eliminate warning: Can not write log, openpty() failed
73 # (/dev/pts not mounted?), does not work65 # (/dev/pts not mounted?), does not work
74 client.run_shell_command(66 client.run_cmd_master('mount --rbind /dev /mnt/root/dev')
75 'mount --rbind /dev /mnt/root/dev',67 client.run_cmd_master('chroot /mnt/root apt-get update')
76 response=MASTER_STR)
77 client.run_shell_command(
78 'chroot /mnt/root apt-get update',
79 response=MASTER_STR)
80 #Install necessary packages for build lava-test68 #Install necessary packages for build lava-test
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 '
82 'python-setuptools python-simplejson lsb-release')70 'python-setuptools python-simplejson lsb-release')
83 client.run_shell_command(71 client.run_shell_command(
84 cmd,72 cmd,
85 response=MASTER_STR, timeout=2400)73 self.client.master_str, 2400)
86 client.run_shell_command(74 client.run_cmd_master('chroot /mnt/root bzr branch lp:lava-test')
87 'chroot /mnt/root bzr branch lp:lava-test',75 client.run_cmd_master('chroot /mnt/root sh -c '
88 response=MASTER_STR)76 '"cd lava-test && python setup.py install"')
89 client.run_shell_command(
90 'chroot /mnt/root sh -c "cd lava-test && python setup.py install"',
91 response=MASTER_STR)
9277
93 #Test if lava-test installed78 #Test if lava-test installed
94 try:79 try:
95 client.run_shell_command(80 client.run_shell_command(
96 'chroot /mnt/root lava-test help',81 'chroot /mnt/root lava-test help',
97 response="list-tests", timeout=10)82 "list-tests", 10)
98 except:83 except:
99 tb = traceback.format_exc()84 tb = traceback.format_exc()
100 client.sio.write(tb)85 client.sio.write(tb)
101 raise OperationFailed("lava-test deployment failed")86 raise OperationFailed("lava-test deployment failed")
10287
103 for test in tests:88 for test in tests:
104 client.run_shell_command(89 client.run_cmd_master('chroot /mnt/root lava-test install %s' % test)
105 'chroot /mnt/root lava-test install %s' % test,
106 response=MASTER_STR)
107 #clean up90 #clean up
108 client.run_shell_command(91 client.run_cmd_master('cp -f /mnt/root/etc/resolv.conf.bak '
109 'cp -f /mnt/root/etc/resolv.conf.bak /mnt/root/etc/resolv.conf',92 '/mnt/root/etc/resolv.conf')
110 response=MASTER_STR)93 client.run_cmd_master('rm -rf /mnt/root/lava-test')
111 client.run_shell_command(
112 'rm -rf /mnt/root/lava-test',
113 response=MASTER_STR)
114 cmd = ('cat /proc/mounts | awk \'{print $2}\' | grep "^/mnt/root/dev"'94 cmd = ('cat /proc/mounts | awk \'{print $2}\' | grep "^/mnt/root/dev"'
115 '| sort -r | xargs umount')95 '| sort -r | xargs umount')
116 client.run_shell_command(96 client.run_cmd_master(cmd)
117 cmd,97 client.run_cmd_master('umount /mnt/root')
118 response=MASTER_STR)
119 client.run_shell_command(
120 'umount /mnt/root',
121 response=MASTER_STR)
12298
=== modified file 'lava_dispatcher/android_client.py'
--- lava_dispatcher/android_client.py 2011-07-20 04:45:23 +0000
+++ lava_dispatcher/android_client.py 2011-08-09 14:40:36 +0000
@@ -42,7 +42,7 @@
42 """ Check that we are in a shell on the test image42 """ Check that we are in a shell on the test image
43 """43 """
44 self.proc.sendline("")44 self.proc.sendline("")
45 id = self.proc.expect([TESTER_STR , pexpect.TIMEOUT])45 id = self.proc.expect([self.tester_str , pexpect.TIMEOUT])
46 if id == 1:46 if id == 1:
47 raise OperationFailed47 raise OperationFailed
4848
@@ -109,7 +109,7 @@
109 network_interface = self.board.network_interface 109 network_interface = self.board.network_interface
110 try:110 try:
111 self.run_shell_command('netcfg %s dhcp' % \111 self.run_shell_command('netcfg %s dhcp' % \
112 network_interface, response = TESTER_STR, timeout = 60)112 network_interface, self.tester_str, 60)
113 except:113 except:
114 print "netcfg %s dhcp exception" % network_interface114 print "netcfg %s dhcp exception" % network_interface
115 return False115 return False
@@ -120,7 +120,7 @@
120 self.proc.sendline('')120 self.proc.sendline('')
121 self.proc.sendline(cmd)121 self.proc.sendline(cmd)
122 try:122 try:
123 id = self.proc.expect([ip_pattern, pexpect.EOF], timeout = 60)123 id = self.proc.expect([ip_pattern, pexpect.EOF], timeout=60)
124 except:124 except:
125 print "ifconfig can not match ip pattern"125 print "ifconfig can not match ip pattern"
126 return False126 return False
127127
=== modified file 'lava_dispatcher/client.py'
--- lava_dispatcher/client.py 2011-07-21 16:47:16 +0000
+++ lava_dispatcher/client.py 2011-08-09 14:40:36 +0000
@@ -33,6 +33,8 @@
3333
34class LavaClient(object):34class LavaClient(object):
35 def __init__(self, hostname):35 def __init__(self, hostname):
36 self._master_str = MASTER_STR
37 self._tester_str = TESTER_STR
36 cmd = "conmux-console %s" % hostname38 cmd = "conmux-console %s" % hostname
37 self.sio = SerialIO(sys.stdout)39 self.sio = SerialIO(sys.stdout)
38 self.proc = pexpect.spawn(cmd, timeout=3600, logfile=self.sio)40 self.proc = pexpect.spawn(cmd, timeout=3600, logfile=self.sio)
@@ -42,11 +44,19 @@
42 # will eventually come from the database44 # will eventually come from the database
43 self.board = BOARDS[hostname]45 self.board = BOARDS[hostname]
4446
47 @property
48 def master_str(self):
49 return self._master_str
50
51 @property
52 def tester_str(self):
53 return self._tester_str
54
45 def in_master_shell(self):55 def in_master_shell(self):
46 """ Check that we are in a shell on the master image56 """ Check that we are in a shell on the master image
47 """57 """
48 self.proc.sendline("")58 self.proc.sendline("")
49 id = self.proc.expect([MASTER_STR, pexpect.TIMEOUT])59 id = self.proc.expect([self.master_str, pexpect.TIMEOUT])
50 if id == 1:60 if id == 1:
51 raise OperationFailed61 raise OperationFailed
5262
@@ -54,7 +64,7 @@
54 """ Check that we are in a shell on the test image64 """ Check that we are in a shell on the test image
55 """65 """
56 self.proc.sendline("")66 self.proc.sendline("")
57 id = self.proc.expect([TESTER_STR, pexpect.TIMEOUT])67 id = self.proc.expect([self.tester_str, pexpect.TIMEOUT])
58 if id == 1:68 if id == 1:
59 raise OperationFailed69 raise OperationFailed
6070
@@ -109,11 +119,17 @@
109 if response:119 if response:
110 self.proc.expect(response, timeout=timeout)120 self.proc.expect(response, timeout=timeout)
111121
122 def run_cmd_master(self, cmd):
123 self.run_shell_command(cmd, self.master_str)
124
125 def run_cmd_tester(self, cmd):
126 self.run_shell_command(cmd, self.tester_str)
127
112 def check_network_up(self):128 def check_network_up(self):
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)
114 id = self.proc.expect(["1 received", "0 received",130 id = self.proc.expect(["1 received", "0 received",
115 "Network is unreachable"], timeout=5)131 "Network is unreachable"], timeout=5)
116 self.proc.expect(MASTER_STR)132 self.proc.expect(self.master_str)
117 if id == 0:133 if id == 0:
118 return True134 return True
119 else:135 else:
@@ -128,14 +144,12 @@
128144
129 def export_display(self):145 def export_display(self):
130 #export the display, ignore errors on non-graphical images146 #export the display, ignore errors on non-graphical images
131 self.run_shell_command("su - linaro -c 'DISPLAY=:0 xhost local:'",147 self.run_cmd_tester("su - linaro -c 'DISPLAY=:0 xhost local:'")
132 response=TESTER_STR)148 self.run_cmd_tester("export DISPLAY=:0")
133 self.run_shell_command("export DISPLAY=:0", response=TESTER_STR)
134149
135 def get_seriallog(self):150 def get_seriallog(self):
136 return self.sio.getvalue()151 return self.sio.getvalue()
137152
138
139class SerialIO(file):153class SerialIO(file):
140 def __init__(self, logfile):154 def __init__(self, logfile):
141 self.serialio = StringIO()155 self.serialio = StringIO()
142156
=== modified file 'lava_dispatcher/config.py'
--- lava_dispatcher/config.py 2011-07-21 16:47:16 +0000
+++ lava_dispatcher/config.py 2011-08-09 14:40:36 +0000
@@ -18,6 +18,16 @@
18# along18# along
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 json
22import os
23
24def get_host(hostname):
25 cfg_path = 'config/hosts/'
26 cfg_file = cfg_path + hostname + '.json'
27 host_file = os.path.join(os.curdir, cfg_file)
28 with open(host_file, 'r') as fp:
29 return json.load(fp)
30
21"""31"""
22This is an ugly hack, the uboot commands for a given board type and the board32This is an ugly hack, the uboot commands for a given board type and the board
23type of a test machine need to come from the device registry. This is an33type of a test machine need to come from the device registry. This is an
2434
=== added file 'lava_dispatcher/qemu_client.py'
--- lava_dispatcher/qemu_client.py 1970-01-01 00:00:00 +0000
+++ lava_dispatcher/qemu_client.py 2011-08-09 14:40:36 +0000
@@ -0,0 +1,135 @@
1# Copyright (C) 2011 Calxeda, Inc.
2#
3# This file is part of LAVA Dispatcher.
4#
5# LAVA Dispatcher is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# LAVA Dispatcher is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, see <http://www.gnu.org/licenses>.
17
18import pexpect
19import sys
20from lava_dispatcher.config import get_host
21from lava_dispatcher.client import LavaClient, SerialIO
22from lava_dispatcher.qemu_config import QEMU_PATH, MASTER_STR, TESTER_STR
23
24
25class LavaQEMUClient(LavaClient):
26
27 def __init__(self, hostname):
28 self.sio = SerialIO(sys.stdout)
29 self.hostname = hostname
30 self.host_config = get_host(hostname)
31
32 self.start_qemu()
33
34 # Should U-Boot automatically to master image
35 self.proc.expect("Starting kernel")
36
37 # will eventually come from the database
38 self.board = self.board_type
39 self._master_str = MASTER_STR
40 self._tester_str = TESTER_STR
41 self.in_master_shell()
42
43 @property
44 def macaddr(self):
45 return self.host_config.get('qemu_macaddr')
46
47 @property
48 def disk(self):
49 return self.host_config.get('qemu_disk')
50
51 @property
52 def board_type(self):
53 return self.host_config.get('board_type')
54
55 @property
56 def vlan_number(self):
57 return self.host_config.get('vlan_number')
58
59 @property
60 def boot_image(self):
61 return self.host_config.get('boot_image')
62
63 @property
64 def machine_type(self):
65 return self.host_config.get('machine_type')
66
67 @property
68 def additional_options(self):
69 return self.host_config.get('additional_options')
70
71 @property
72 def network_arguments(self):
73 if(self.vlan_number is not None and
74 self.macaddr is not None):
75 return ("-net nic,vlan=%d,macaddr=%s -net vde,vlan=%d " %
76 (self.vlan_number, self.macaddr, self.vlan_number))
77 else:
78 return ""
79
80 @property
81 def disk_arguments(self):
82 if(self.disk is not None):
83 return ('-drive id=disk,if=ide,file=%s '
84 '-device ide-drive,drive=disk,bus=ide.0' % self.disk)
85 else:
86 return ""
87
88 def start_qemu(self):
89 cmd = ("%sqemu-system-arm %s -M %s -kernel %s " %
90 (QEMU_PATH, self.additional_options, self.machine_type,
91 self.boot_image))
92 cmd += self.network_arguments
93 cmd += self.disk_arguments
94
95 print "Starting QEMU:\n\t%s\n\n" % cmd
96 self.proc = pexpect.spawn(cmd, timeout=7200, logfile=self.sio)
97 self.proc.delaybeforesend=1
98
99 def boot_master_image(self):
100 """ reboot the system, and check that we are in a master shell
101 """
102 self.hard_reboot()
103 try:
104 # Necessary to get past U-Boot
105 self.proc.expect("Starting kernel")
106 self.in_master_shell()
107 except:
108 raise
109
110 def boot_linaro_image(self):
111 """ Reboot the system to the test image
112 """
113 self.hard_reboot()
114 self.enter_uboot()
115 uboot_cmds = self.board.uboot_cmds
116 self.proc.sendline(uboot_cmds[0])
117 for cmd in uboot_cmd[1:]:
118 if self.board.type in ["mx51evk", "mx53loco"]:
119 self.proc.expect(">")
120 else:
121 self.proc.expect("#")
122 self.proc.sendline(cmd)
123 self.in_test_shell()
124
125 def soft_reboot(self):
126 # Assume soft reboot will not work
127 pass
128
129 def hard_reboot(self):
130 self.proc.sendline("reboot")
131 self.proc.expect([pexpect.TIMEOUT], timeout=60)
132 self.proc.sendcontrol('a')
133 self.proc.send('x')
134 self.start_qemu()
135
0136
=== added file 'lava_dispatcher/qemu_config.py'
--- lava_dispatcher/qemu_config.py 1970-01-01 00:00:00 +0000
+++ lava_dispatcher/qemu_config.py 2011-08-09 14:40:36 +0000
@@ -0,0 +1,20 @@
1# Copyright (C) 2011 Calxeda, Inc.
2#
3# This file is part of LAVA Dispatcher.
4#
5# LAVA Dispatcher is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# LAVA Dispatcher is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, see <http://www.gnu.org/licenses>.
17
18from lava_dispatcher.config import MASTER_STR, TESTER_STR
19
20QEMU_PATH = ""
021
=== added file 'lava_dispatcher/ssh_client.py'
--- lava_dispatcher/ssh_client.py 1970-01-01 00:00:00 +0000
+++ lava_dispatcher/ssh_client.py 2011-08-09 14:40:36 +0000
@@ -0,0 +1,75 @@
1# Copyright (C) 2011 Calxeda, Inc.
2#
3# This file is part of LAVA Dispatcher.
4#
5# LAVA Dispatcher is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# LAVA Dispatcher is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, see <http://www.gnu.org/licenses>.
17
18import pexpect
19import sys
20from lava_dispatcher.client import LavaClient, SerialIO
21from lava_dispatcher.config import get_host
22import pxssh
23
24
25class LavaSSHClient(LavaClient):
26
27 def __init__(self, hostname):
28 self.sio = SerialIO(sys.stdout)
29 self.host_config = get_host(hostname)
30 try:
31 self.proc = pxssh.pxssh(logfile=self.sio)
32 self.proc.login(hostname, self.username, self.password)
33 self.proc.prompt()
34 except pxssh.ExceptionPxssh:
35 raise OperationFailed()
36
37 @property
38 def username(self):
39 return self.host_config['username']
40
41 @property
42 def password(self):
43 return self.host_config['password']
44
45 @property
46 def master_str(self):
47 return self.proc.PROMPT
48
49 @property
50 def tester_str(self):
51 return self.proc.PROMPT
52
53 def soft_reboot(self):
54 self.run_shell_command('reboot', sudo=True)
55
56 def hard_reboot(self):
57 """ No way to hard reboot through ssh """
58 msg = "hard_reboot is not supported by LavaSSHClient"
59 raise OperationFailed(msg)
60
61 def simple_command(self, cmd, timeout=5):
62 self.run_shell_command(cmd, timeout=timeout)
63
64 def run_shell_command(self, cmd, response=None, timeout=-1, sudo=False):
65 expectations = [pexpect.TIMEOUT if not response else response]
66 if sudo:
67 cmd = 'sudo ' + cmd
68 pw_req = "password for %s:" % self.get_username()
69 expectations.append(pw_req)
70
71 self.proc.sendline(cmd)
72 i = self.proc.expect(expectations, timeout=timeout)
73 if i != 0: # pexpect matched pw_req
74 self.proc.sendline(self.get_password())
75 self.proc.expect(expecting[:-1], timeout=timeout)
076
=== added file 'lava_dispatcher/ssh_config.py'
--- lava_dispatcher/ssh_config.py 1970-01-01 00:00:00 +0000
+++ lava_dispatcher/ssh_config.py 2011-08-09 14:40:36 +0000
@@ -0,0 +1,18 @@
1# Copyright (C) 2011 Calxeda, Inc.
2#
3# This file is part of LAVA Dispatcher.
4#
5# LAVA Dispatcher is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# LAVA Dispatcher is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, see <http://www.gnu.org/licenses>.
17
18CFG_PATH = 'config/hosts/'

Subscribers

People subscribed via source and target branches