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
=== modified file 'core_image_publisher/__init__.py'
--- core_image_publisher/__init__.py 2015-04-08 20:14:12 +0000
+++ core_image_publisher/__init__.py 2015-06-04 09:29:56 +0000
@@ -70,11 +70,11 @@
70 publisher = CoreImageResultPublisher(connection)70 publisher = CoreImageResultPublisher(connection)
71 retry_policy = DefaultRetryPolicy(71 retry_policy = DefaultRetryPolicy(
72 max_retries=3,72 max_retries=3,
73 dead_queue='core.deadletters.{}'.format(constants.API_VERSION)73 dead_queue=constants.DEAD_QUEUE
74 )74 )
75 monitor = SimpleRabbitQueueWorker(75 monitor = SimpleRabbitQueueWorker(
76 connection,76 connection,
77 'core.image.{}'.format(constants.API_VERSION),77 constants.INPUT_QUEUE,
78 worker.ImagePublisherWorker(config, publisher),78 worker.ImagePublisherWorker(config, publisher),
79 retry_policy,79 retry_policy,
80 )80 )
8181
=== modified file 'core_image_publisher/constants.py'
--- core_image_publisher/constants.py 2015-04-01 01:19:12 +0000
+++ core_image_publisher/constants.py 2015-06-04 09:29:56 +0000
@@ -14,9 +14,11 @@
14# You should have received a copy of the GNU General Public License14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16#16#
17
18"""Constants for this service."""17"""Constants for this service."""
1918
19import socket
20
21
20API_VERSION = "v1"22API_VERSION = "v1"
2123
22RETRY_COUNT = 324RETRY_COUNT = 3
@@ -25,27 +27,11 @@
2527
26SERVICE_NAME = "core-image-publisher"28SERVICE_NAME = "core-image-publisher"
2729
2830DEAD_QUEUE = "core.deadletters.{}".format(API_VERSION)
29def _get_hostname():31
30 """Return sanitized contents of /etc/hostname.32INPUT_QUEUE = "core.image.{}".format(API_VERSION)
3133
32 It is necessary because current juju hostnames (juju-<env-name>-machine-#)34HOSTNAME = socket.gethostname()
33 are too big due to our long environment names ('<spec_name>-<MD5>').
34 Linux (DNS for RFC1035, really) only supports labels up to 64 chars and
35 the fallback varies from tool to tool, `cloud-init` chokes on longer
36 names and sets 'ubuntu' (which is the value considered by socket.get*),
37 `hostnamectl` (systemd) would truncate the given data.
38
39 None of this is ideal to our applications, that's why we will operate
40 on the pristine /etc/hostname and remove the 'juju-' and '-machine' terms
41 added by juju.
42 """
43 with open('/etc/hostname') as fd:
44 hostname = fd.read()
45 return hostname.replace('juju-', '').replace('-machine', '').strip()
46
47
48HOSTNAME = _get_hostname()
4935
50LOGGING_EXTRA = {36LOGGING_EXTRA = {
51 'solution': SOLUTION_NAME,37 'solution': SOLUTION_NAME,
5238
=== modified file 'core_image_publisher/worker.py'
--- core_image_publisher/worker.py 2015-04-23 01:33:11 +0000
+++ core_image_publisher/worker.py 2015-06-04 09:29:56 +0000
@@ -46,6 +46,7 @@
46 try:46 try:
47 image_name = payload['image_name']47 image_name = payload['image_name']
48 channel = payload['channel']48 channel = payload['channel']
49 release = payload['release']
49 device = payload['device']50 device = payload['device']
50 except KeyError as e:51 except KeyError as e:
51 logger.error(52 logger.error(
@@ -61,6 +62,7 @@
61 try:62 try:
62 image_path = download_image(63 image_path = download_image(
63 image_name,64 image_name,
65 release,
64 channel,66 channel,
65 device,67 device,
66 tmpdir68 tmpdir
@@ -106,7 +108,7 @@
106 return MessageActions.Acknowledge108 return MessageActions.Acknowledge
107109
108110
109def download_image(name, channel, device, tmpdir):111def download_image(name, release, channel, device, tmpdir):
110 """Download the ubuntu code image, return a path to it on disk."""112 """Download the ubuntu code image, return a path to it on disk."""
111 image_path = os.path.join(tmpdir, 'core-{}.img'.format(name))113 image_path = os.path.join(tmpdir, 'core-{}.img'.format(name))
112 udf_env = {114 udf_env = {
@@ -122,12 +124,12 @@
122 '--revision', name,124 '--revision', name,
123 'core',125 'core',
124 '--device', device,126 '--device', device,
125 '--channel', 'edge',127 '--channel', channel,
126 '--size', '3',128 '--size', '3',
127 '-o', image_path,129 '-o', image_path,
128 '--developer-mode',130 '--developer-mode',
129 '--cloud',131 '--cloud',
130 'rolling']132 release]
131 check_call(cmd, env=udf_env)133 check_call(cmd, env=udf_env)
132 cmd = ['sudo',134 cmd = ['sudo',
133 'rm',135 'rm',

Subscribers

People subscribed via source and target branches