Merge lp:~fginther/core-image-publisher/edge-support into lp:core-image-publisher

Proposed by Francis Ginther
Status: Rejected
Rejected by: Francis Ginther
Proposed branch: lp:~fginther/core-image-publisher/edge-support
Merge into: lp:core-image-publisher
Diff against target: 79 lines (+28/-2)
1 file modified
core_image_publisher/worker.py (+28/-2)
To merge this branch: bzr merge lp:~fginther/core-image-publisher/edge-support
Reviewer Review Type Date Requested Status
Celso Providelo (community) Needs Information
Review via email: mp+257165@code.launchpad.net

Commit message

Add support for release and ubuntu-device-flash 0.20snappy7-0ubuntu1.

The fix_permission thing is a bit troubling to me. But ubuntu-device-flash leaves behind a .gnupg directory in the same location where the image is downloaded that is owned by root:root.

Description of the change

Add support for release and ubuntu-device-flash 0.20snappy7-0ubuntu1.

To post a comment you must log in.
Revision history for this message
Celso Providelo (cprov) wrote :

Francis,

It think the needs of sudo, thus the mis-assigned permission to .gnupg is a u-d-f problem and should be confined to the stage where it's is called (download_image function).

What do you think about chaining a check_call('sudo rm -rf .gnupg') after the image is downloaded ?

review: Needs Information
Revision history for this message
Francis Ginther (fginther) wrote :

> Francis,
>
> It think the needs of sudo, thus the mis-assigned permission to .gnupg is a
> u-d-f problem and should be confined to the stage where it's is called
> (download_image function).
>
> What do you think about chaining a check_call('sudo rm -rf .gnupg') after the
> image is downloaded ?

Lemme try.

Revision history for this message
Francis Ginther (fginther) wrote :

Rejecting as a different solution was implemented that only required modifications to the publisher.

Unmerged revisions

28. By Francis Ginther

Add support for release and ubuntu-device-flash 0.20snappy7-0ubuntu1.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'core_image_publisher/worker.py'
2--- core_image_publisher/worker.py 2015-04-08 20:14:12 +0000
3+++ core_image_publisher/worker.py 2015-04-22 19:38:00 +0000
4@@ -17,6 +17,7 @@
5
6 """Business logic or the service lives here."""
7
8+import getpass
9 import logging
10 import os
11 import subprocess
12@@ -45,6 +46,7 @@
13 extra.update(payload)
14 try:
15 image_name = payload['image_name']
16+ release = payload['release']
17 channel = payload['channel']
18 device = payload['device']
19 except KeyError as e:
20@@ -61,6 +63,7 @@
21 try:
22 image_path = download_image(
23 image_name,
24+ release,
25 channel,
26 device,
27 tmpdir
28@@ -75,6 +78,15 @@
29 logger.info("Ubuntu Core image downloaded OK.", extra=extra)
30
31 try:
32+ fix_permissions(tmpdir)
33+ except subprocess.CalledProcessError as e:
34+ logger.error(
35+ "Unable to fix permissions on %s",
36+ e,
37+ extra=extra)
38+ return MessageActions.Retry
39+
40+ try:
41 nova_image_path = convert_nova_image(image_path)
42 except subprocess.CalledProcessError as e:
43 logger.error(
44@@ -106,7 +118,7 @@
45 return MessageActions.Acknowledge
46
47
48-def download_image(name, channel, device, tmpdir):
49+def download_image(name, release, channel, device, tmpdir):
50 """Download the ubuntu code image, return a path to it on disk."""
51 image_path = os.path.join(tmpdir, 'core-{}.img'.format(name))
52 udf_env = {
53@@ -124,11 +136,25 @@
54 '--size', '3',
55 '-o', image_path,
56 '--developer-mode',
57- '--cloud']
58+ '--cloud',
59+ release]
60+ logger.info("ubuntu-device-flash: %s", cmd)
61 check_call(cmd, env=udf_env)
62 return image_path
63
64
65+def fix_permissions(tmpdir):
66+ """
67+ Fix the permissions of the files left behind by ubuntu-device-flash.
68+ """
69+ cmd = ['sudo',
70+ 'chown',
71+ '-R',
72+ getpass.getuser(),
73+ tmpdir]
74+ check_call(cmd)
75+
76+
77 def convert_nova_image(image_path):
78 """
79 Convert a core image to a nova image, return path to the converted image.

Subscribers

People subscribed via source and target branches