Merge lp:~psivaa/core-image-publisher/use-payload-channel into lp:core-image-publisher

Proposed by Para Siva
Status: Merged
Approved by: Para Siva
Approved revision: 29
Merged at revision: 29
Proposed branch: lp:~psivaa/core-image-publisher/use-payload-channel
Merge into: lp:core-image-publisher
Diff against target: 111 lines (+15/-27)
3 files modified
core_image_publisher/__init__.py (+2/-2)
core_image_publisher/constants.py (+8/-22)
core_image_publisher/worker.py (+5/-3)
To merge this branch: bzr merge lp:~psivaa/core-image-publisher/use-payload-channel
Reviewer Review Type Date Requested Status
Francis Ginther Approve
Paul Larson Approve
Review via email: mp+261068@code.launchpad.net

Commit message

Reverting changes made in rev28, to not hardcode the channel and introducing release.

Description of the change

Reverting changes made in rev28, to not hardcode the channel and introducing release. Also some refactoring to make more use of constants.py.

NOTE: https://code.launchpad.net/~psivaa/core-image-watcher/channel-release-for-image-publisher/+merge/261065 should land first before landing this one.

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

Thanks Paul. yes, that the image-watcher should land first before landing this particular one. Sorry I just added it in the MP.

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

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'core_image_publisher/__init__.py'
2--- core_image_publisher/__init__.py 2015-04-08 20:14:12 +0000
3+++ core_image_publisher/__init__.py 2015-06-04 09:29:56 +0000
4@@ -70,11 +70,11 @@
5 publisher = CoreImageResultPublisher(connection)
6 retry_policy = DefaultRetryPolicy(
7 max_retries=3,
8- dead_queue='core.deadletters.{}'.format(constants.API_VERSION)
9+ dead_queue=constants.DEAD_QUEUE
10 )
11 monitor = SimpleRabbitQueueWorker(
12 connection,
13- 'core.image.{}'.format(constants.API_VERSION),
14+ constants.INPUT_QUEUE,
15 worker.ImagePublisherWorker(config, publisher),
16 retry_policy,
17 )
18
19=== modified file 'core_image_publisher/constants.py'
20--- core_image_publisher/constants.py 2015-04-01 01:19:12 +0000
21+++ core_image_publisher/constants.py 2015-06-04 09:29:56 +0000
22@@ -14,9 +14,11 @@
23 # You should have received a copy of the GNU General Public License
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #
26-
27 """Constants for this service."""
28
29+import socket
30+
31+
32 API_VERSION = "v1"
33
34 RETRY_COUNT = 3
35@@ -25,27 +27,11 @@
36
37 SERVICE_NAME = "core-image-publisher"
38
39-
40-def _get_hostname():
41- """Return sanitized contents of /etc/hostname.
42-
43- It is necessary because current juju hostnames (juju-<env-name>-machine-#)
44- are too big due to our long environment names ('<spec_name>-<MD5>').
45- Linux (DNS for RFC1035, really) only supports labels up to 64 chars and
46- the fallback varies from tool to tool, `cloud-init` chokes on longer
47- names and sets 'ubuntu' (which is the value considered by socket.get*),
48- `hostnamectl` (systemd) would truncate the given data.
49-
50- None of this is ideal to our applications, that's why we will operate
51- on the pristine /etc/hostname and remove the 'juju-' and '-machine' terms
52- added by juju.
53- """
54- with open('/etc/hostname') as fd:
55- hostname = fd.read()
56- return hostname.replace('juju-', '').replace('-machine', '').strip()
57-
58-
59-HOSTNAME = _get_hostname()
60+DEAD_QUEUE = "core.deadletters.{}".format(API_VERSION)
61+
62+INPUT_QUEUE = "core.image.{}".format(API_VERSION)
63+
64+HOSTNAME = socket.gethostname()
65
66 LOGGING_EXTRA = {
67 'solution': SOLUTION_NAME,
68
69=== modified file 'core_image_publisher/worker.py'
70--- core_image_publisher/worker.py 2015-04-23 01:33:11 +0000
71+++ core_image_publisher/worker.py 2015-06-04 09:29:56 +0000
72@@ -46,6 +46,7 @@
73 try:
74 image_name = payload['image_name']
75 channel = payload['channel']
76+ release = payload['release']
77 device = payload['device']
78 except KeyError as e:
79 logger.error(
80@@ -61,6 +62,7 @@
81 try:
82 image_path = download_image(
83 image_name,
84+ release,
85 channel,
86 device,
87 tmpdir
88@@ -106,7 +108,7 @@
89 return MessageActions.Acknowledge
90
91
92-def download_image(name, channel, device, tmpdir):
93+def download_image(name, release, channel, device, tmpdir):
94 """Download the ubuntu code image, return a path to it on disk."""
95 image_path = os.path.join(tmpdir, 'core-{}.img'.format(name))
96 udf_env = {
97@@ -122,12 +124,12 @@
98 '--revision', name,
99 'core',
100 '--device', device,
101- '--channel', 'edge',
102+ '--channel', channel,
103 '--size', '3',
104 '-o', image_path,
105 '--developer-mode',
106 '--cloud',
107- 'rolling']
108+ release]
109 check_call(cmd, env=udf_env)
110 cmd = ['sudo',
111 'rm',

Subscribers

People subscribed via source and target branches