Merge lp:~joetalbott/snappy-proposed-image-builder/add_versions into lp:snappy-proposed-image-builder

Proposed by Joe Talbott
Status: Merged
Approved by: Joe Talbott
Approved revision: 16
Merged at revision: 12
Proposed branch: lp:~joetalbott/snappy-proposed-image-builder/add_versions
Merge into: lp:snappy-proposed-image-builder
Diff against target: 74 lines (+16/-13)
1 file modified
snappy_proposed_image_builder/worker.py (+16/-13)
To merge this branch: bzr merge lp:~joetalbott/snappy-proposed-image-builder/add_versions
Reviewer Review Type Date Requested Status
Paul Larson Approve
Celso Providelo (community) Approve
Review via email: mp+260856@code.launchpad.net

Commit message

Add rootfs, image, and device versions to output payload.

Description of the change

Add rootfs, image, and device versions to output payload.

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

Couldn't you have just done something like:
(payload['image_version'], payload['rootfs_version'], payload['device_version']) = image_versions.split(':')

review: Needs Information
Revision history for this message
Celso Providelo (cprov) wrote :

Joe,

Thanks for adding this.

I have few comments inline, but nothing blocking, just a suggestion and a clarification request.

review: Approve
14. By Joe Talbott

Remove a few layers of indirection.

15. By Joe Talbott

We're not using the combined image name so remove the code.

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

Sorry, I think I mistyped the last comment. I meant - why do you need _get_image_versions() at all? Couldn't you have just called get_latest_image_version() and then used .split(':') to get the pieces of it that you need for the other fields?

16. By Joe Talbott

Avoid having payload['xyz'] all over the place.

Revision history for this message
Paul Larson (pwlars) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'snappy_proposed_image_builder/worker.py'
2--- snappy_proposed_image_builder/worker.py 2015-06-02 01:58:29 +0000
3+++ snappy_proposed_image_builder/worker.py 2015-06-02 17:16:41 +0000
4@@ -67,13 +67,18 @@
5 )
6 return MessageActions.Retry
7
8- image_name = get_latest_image_version(release, channel, device)
9+ (image_version, rootfs_version, device_version) = _get_image_versions(
10+ release, channel, device)
11+
12+ payload['image_version'] = image_version
13+ payload['rootfs_version'] = rootfs_version
14+ payload['device_version'] = device_version
15
16 with tempfile.TemporaryDirectory() as tmpdir:
17 logger.info("Beginning rootfs download.", extra=extra)
18 try:
19 rootfs_path = download_rootfs(
20- image_name.split(':')[0],
21+ image_version,
22 release,
23 channel,
24 device,
25@@ -103,7 +108,7 @@
26 os.remove(rootfs_path)
27 try:
28 rootfs_path = download_rootfs(
29- image_name.split(':')[0],
30+ image_version,
31 channel,
32 device,
33 tmpdir
34@@ -129,7 +134,7 @@
35 try:
36 logger.info("Building the image")
37 image_path = build_image(
38- image_name.split(':')[0],
39+ image_version,
40 new_rootfs_path,
41 release,
42 channel,
43@@ -432,24 +437,22 @@
44 return latest_image_info
45
46
47-def get_latest_image_version(release, channel, device):
48- """Returns latest image version in
49- `version:ubuntu-version:raw_device-version` format
50- """
51+def _get_image_versions(release, channel, device):
52 latest_image_info = _get_version_string_output(release, channel, device)
53- version = ''
54- ubuntu_version = ''
55+ image_version = ''
56+ rootfs_version = ''
57 dev_version = ''
58 for info in latest_image_info.decode('utf-8').split("\n"):
59 if 'Description' in info:
60 for l in info.split(','):
61 if 'version' in l:
62- version = l.split('version=')[1]
63+ image_version = l.split('version=')[1]
64 continue
65 if 'ubuntu' in l:
66- ubuntu_version = l.split('ubuntu=')[1]
67+ rootfs_version = l.split('ubuntu=')[1]
68 continue
69 if 'raw-device' in l:
70 dev_version = l.split('raw-device=')[1]
71 continue
72- return (':'.join([version, ubuntu_version, dev_version]))
73+
74+ return (image_version, rootfs_version, dev_version)

Subscribers

People subscribed via source and target branches