Merge lp:~terceiro/lava-dispatcher/master-device-version into lp:lava-dispatcher

Proposed by Antonio Terceiro
Status: Merged
Merged at revision: 490
Proposed branch: lp:~terceiro/lava-dispatcher/master-device-version
Merge into: lp:lava-dispatcher
Diff against target: 80 lines (+30/-1)
2 files modified
lava_dispatcher/device/master.py (+26/-0)
lava_dispatcher/job.py (+4/-1)
To merge this branch: bzr merge lp:~terceiro/lava-dispatcher/master-device-version
Reviewer Review Type Date Requested Status
Linaro Validation Team Pending
Review via email: mp+138463@code.launchpad.net

Description of the change

this branch adds support for obtaining the version (hwpack/rootfs) for master images.

To post a comment you must log in.
Revision history for this message
Andy Doan (doanac) wrote :

On 12/06/2012 08:21 AM, Antonio Terceiro wrote:
> === modified file 'lava_dispatcher/job.py'
> --- lava_dispatcher/job.py 2012-11-24 20:58:07 +0000
> +++ lava_dispatcher/job.py 2012-12-06 14:20:27 +0000
> @@ -148,7 +148,6 @@
>
> metadata = {
> 'target.hostname': self.target,
> - 'target.device_version': self.context.get_device_version(),
> }
>
> if 'device_type' in self.job_data:
> @@ -232,6 +231,7 @@
> self.context.test_data.job_status = 'fail'
> raise
> finally:
> + self.context.test_data.add_metadata({ 'target.device_version': self.context.get_device_version() or 'error'})

Is the get_device_version sufficiently exception-safe? ie - the 3 lines
of code after this are important or the lava-results won't get submitted
properly. I'm not the best at proper error handling, maybe Michael can
speculate. Also - this wraps way past column 80 and is going to make
pylint/pflakes/etc complain.

> if submit_results:
> params = submit_results.get('parameters', {})
> action = lava_commands[submit_results['command']](

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Andy Doan <email address hidden> writes:

> On 12/06/2012 08:21 AM, Antonio Terceiro wrote:
>> === modified file 'lava_dispatcher/job.py'
>> --- lava_dispatcher/job.py 2012-11-24 20:58:07 +0000
>> +++ lava_dispatcher/job.py 2012-12-06 14:20:27 +0000
>> @@ -148,7 +148,6 @@
>>
>> metadata = {
>> 'target.hostname': self.target,
>> - 'target.device_version': self.context.get_device_version(),
>> }
>>
>> if 'device_type' in self.job_data:
>> @@ -232,6 +231,7 @@
>> self.context.test_data.job_status = 'fail'
>> raise
>> finally:
>> + self.context.test_data.add_metadata({ 'target.device_version': self.context.get_device_version() or 'error'})
>
> Is the get_device_version sufficiently exception-safe? ie - the 3 lines
> of code after this are important or the lava-results won't get submitted
> properly. I'm not the best at proper error handling, maybe Michael can
> speculate.

It looks ok to me, but the part that concerns me is the point at which
it is called -- get_device_version will only work usefully if the board
is in the master image, but I don't think its guaranteed to be at this
point. I would rather have the target squirrel the device version away
the first time the device boots into the master image, if that's
possible.

CHeers,
mwh

> Also - this wraps way past column 80 and is going to make
> pylint/pflakes/etc complain.
>
>> if submit_results:
>> params = submit_results.get('parameters', {})
>> action = lava_commands[submit_results['command']](
>
>
> --
> https://code.launchpad.net/~terceiro/lava-dispatcher/master-device-version/+merge/138463
> You are subscribed to branch lp:lava-dispatcher.

Revision history for this message
Andy Doan (doanac) wrote :

On 12/06/2012 04:58 PM, Michael Hudson-Doyle wrote:
> It looks ok to me, but the part that concerns me is the point at which
> it is called -- get_device_version will only work usefully if the board
> is in the master image, but I don't think its guaranteed to be at this
> point. I would rather have the target squirrel the device version away
> the first time the device boots into the master image, if that's
> possible.

Read again - I thought the same thing the first time I read the code. It
actually sets this the first time it boots to master and is safe to call
from any context afterwards.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Andy Doan <email address hidden> writes:

> On 12/06/2012 04:58 PM, Michael Hudson-Doyle wrote:
>> It looks ok to me, but the part that concerns me is the point at which
>> it is called -- get_device_version will only work usefully if the board
>> is in the master image, but I don't think its guaranteed to be at this
>> point. I would rather have the target squirrel the device version away
>> the first time the device boots into the master image, if that's
>> possible.
>
> Read again - I thought the same thing the first time I read the code. It
> actually sets this the first time it boots to master and is safe to call
> from any context afterwards.

Ah quite right. +1 to merge.

Cheers,
mwh

481. By Antonio Terceiro

reformat long line

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lava_dispatcher/device/master.py'
2--- lava_dispatcher/device/master.py 2012-12-05 19:10:40 +0000
3+++ lava_dispatcher/device/master.py 2012-12-07 20:01:22 +0000
4@@ -81,6 +81,7 @@
5 }
6
7 self.master_ip = None
8+ self.device_version = None
9
10 if config.pre_connect_command:
11 logging_system(config.pre_connect_command)
12@@ -88,6 +89,9 @@
13 self.proc = self._connect_carefully(config.connection_command)
14 atexit.register(self._close_logging_spawn)
15
16+ def get_device_version(self):
17+ return self.device_version
18+
19 def power_on(self):
20 self._boot_linaro_image()
21 return self.proc
22@@ -400,6 +404,7 @@
23 runner = MasterCommandRunner(self)
24 try:
25 self.master_ip = runner.get_master_ip()
26+ self.device_version = runner.get_device_version()
27 except NetworkError as e:
28 msg = "Failed to get network up: " % e
29 logging.warning(msg)
30@@ -518,6 +523,27 @@
31 logging.debug("Master image IP is %s" % ip)
32 return ip
33
34+ def get_device_version(self):
35+ pattern = 'device_version=(\d+-\d+/\d+-\d+)'
36+ self.run("echo \"device_version="
37+ "$(lava-master-image-info --master-image-hwpack "
38+ "| sed 's/[^0-9-]//g; s/^-\+//')"
39+ "/"
40+ "$(lava-master-image-info --master-image-rootfs "
41+ "| sed 's/[^0-9-]//g; s/^-\+//')"
42+ "\"",
43+ [pattern, pexpect.EOF, pexpect.TIMEOUT],
44+ timeout = 5)
45+
46+ device_version = None
47+ if self.match_id == 0:
48+ device_version = self.match.group(1)
49+ logging.debug('Master image version (hwpack/rootfs) is %s' % device_version)
50+ else:
51+ logging.warning('Could not determine image version!')
52+
53+ return device_version
54+
55 def has_partition_with_label(self, label):
56 if not label:
57 return False
58
59=== modified file 'lava_dispatcher/job.py'
60--- lava_dispatcher/job.py 2012-11-24 20:58:07 +0000
61+++ lava_dispatcher/job.py 2012-12-07 20:01:22 +0000
62@@ -148,7 +148,6 @@
63
64 metadata = {
65 'target.hostname': self.target,
66- 'target.device_version': self.context.get_device_version(),
67 }
68
69 if 'device_type' in self.job_data:
70@@ -232,6 +231,10 @@
71 self.context.test_data.job_status = 'fail'
72 raise
73 finally:
74+ device_version = self.context.get_device_version() or 'error'
75+ self.context.test_data.add_metadata({
76+ 'target.device_version': device_version
77+ })
78 if submit_results:
79 params = submit_results.get('parameters', {})
80 action = lava_commands[submit_results['command']](

Subscribers

People subscribed via source and target branches