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
=== modified file 'snappy_proposed_image_builder/worker.py'
--- snappy_proposed_image_builder/worker.py 2015-06-02 01:58:29 +0000
+++ snappy_proposed_image_builder/worker.py 2015-06-02 17:16:41 +0000
@@ -67,13 +67,18 @@
67 )67 )
68 return MessageActions.Retry68 return MessageActions.Retry
6969
70 image_name = get_latest_image_version(release, channel, device)70 (image_version, rootfs_version, device_version) = _get_image_versions(
71 release, channel, device)
72
73 payload['image_version'] = image_version
74 payload['rootfs_version'] = rootfs_version
75 payload['device_version'] = device_version
7176
72 with tempfile.TemporaryDirectory() as tmpdir:77 with tempfile.TemporaryDirectory() as tmpdir:
73 logger.info("Beginning rootfs download.", extra=extra)78 logger.info("Beginning rootfs download.", extra=extra)
74 try:79 try:
75 rootfs_path = download_rootfs(80 rootfs_path = download_rootfs(
76 image_name.split(':')[0],81 image_version,
77 release,82 release,
78 channel,83 channel,
79 device,84 device,
@@ -103,7 +108,7 @@
103 os.remove(rootfs_path)108 os.remove(rootfs_path)
104 try:109 try:
105 rootfs_path = download_rootfs(110 rootfs_path = download_rootfs(
106 image_name.split(':')[0],111 image_version,
107 channel,112 channel,
108 device,113 device,
109 tmpdir114 tmpdir
@@ -129,7 +134,7 @@
129 try:134 try:
130 logger.info("Building the image")135 logger.info("Building the image")
131 image_path = build_image(136 image_path = build_image(
132 image_name.split(':')[0],137 image_version,
133 new_rootfs_path,138 new_rootfs_path,
134 release,139 release,
135 channel,140 channel,
@@ -432,24 +437,22 @@
432 return latest_image_info437 return latest_image_info
433438
434439
435def get_latest_image_version(release, channel, device):440def _get_image_versions(release, channel, device):
436 """Returns latest image version in
437 `version:ubuntu-version:raw_device-version` format
438 """
439 latest_image_info = _get_version_string_output(release, channel, device)441 latest_image_info = _get_version_string_output(release, channel, device)
440 version = ''442 image_version = ''
441 ubuntu_version = ''443 rootfs_version = ''
442 dev_version = ''444 dev_version = ''
443 for info in latest_image_info.decode('utf-8').split("\n"):445 for info in latest_image_info.decode('utf-8').split("\n"):
444 if 'Description' in info:446 if 'Description' in info:
445 for l in info.split(','):447 for l in info.split(','):
446 if 'version' in l:448 if 'version' in l:
447 version = l.split('version=')[1]449 image_version = l.split('version=')[1]
448 continue450 continue
449 if 'ubuntu' in l:451 if 'ubuntu' in l:
450 ubuntu_version = l.split('ubuntu=')[1]452 rootfs_version = l.split('ubuntu=')[1]
451 continue453 continue
452 if 'raw-device' in l:454 if 'raw-device' in l:
453 dev_version = l.split('raw-device=')[1]455 dev_version = l.split('raw-device=')[1]
454 continue456 continue
455 return (':'.join([version, ubuntu_version, dev_version]))457
458 return (image_version, rootfs_version, dev_version)

Subscribers

People subscribed via source and target branches