Merge lp:~thomir-deactivatedaccount/core-image-publisher/trunk-skeleton into lp:core-image-publisher

Proposed by Thomi Richards
Status: Merged
Approved by: Thomi Richards
Approved revision: 10
Merged at revision: 8
Proposed branch: lp:~thomir-deactivatedaccount/core-image-publisher/trunk-skeleton
Merge into: lp:core-image-publisher
Diff against target: 117 lines (+68/-6)
3 files modified
core_image_publisher/__init__.py (+5/-6)
core_image_publisher/queue.py (+5/-0)
core_image_publisher/worker.py (+58/-0)
To merge this branch: bzr merge lp:~thomir-deactivatedaccount/core-image-publisher/trunk-skeleton
Reviewer Review Type Date Requested Status
Paul Larson Approve
Review via email: mp+254310@code.launchpad.net

Commit message

Add some skeleton code.

Description of the change

Add some skeleton code.

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

A couple of small questions, otherwise it looks fine to me.

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

+1

review: Approve
Revision history for this message
Ubuntu CI Bot (uci-bot) wrote :
Download full text (6.6 KiB)

The attempt to merge lp:~thomir/core-image-publisher/trunk-skeleton into lp:core-image-publisher failed. Below is the output from the failed tests.

Using base prefix '/usr'
New python executable in /tmp/venv-core-image-publisherpy50c6da/bin/python3
Also creating executable in /tmp/venv-core-image-publisherpy50c6da/bin/python
Installing setuptools, pip...done.
Running virtualenv with interpreter /usr/bin/python3
Ignoring indexes: https://pypi.python.org/simple/
Downloading/unpacking kombu==3.0.24 (from -r requirements.txt (line 1))
Downloading/unpacking python-logstash==0.4.2 (from -r requirements.txt (line 2))
  Running setup.py (path:/tmp/venv-core-image-publisherpy50c6da/build/python-logstash/setup.py) egg_info for package python-logstash

Downloading/unpacking anyjson>=0.3.3 (from kombu==3.0.24->-r requirements.txt (line 1))
  Running setup.py (path:/tmp/venv-core-image-publisherpy50c6da/build/anyjson/setup.py) egg_info for package anyjson

Downloading/unpacking amqp>=1.4.5,<2.0 (from kombu==3.0.24->-r requirements.txt (line 1))
  Running setup.py (path:/tmp/venv-core-image-publisherpy50c6da/build/amqp/setup.py) egg_info for package amqp

Installing collected packages: kombu, python-logstash, anyjson, amqp
  Running setup.py install for python-logstash

  Running setup.py install for anyjson
    Fixing build/lib/anyjson/__init__.py
    Skipping implicit fixer: buffer
    Skipping implicit fixer: idioms
    Skipping implicit fixer: set_literal
    Skipping implicit fixer: ws_comma
    Fixing build/lib/anyjson/__init__.py
    Skipping implicit fixer: buffer
    Skipping implicit fixer: idioms
    Skipping implicit fixer: set_literal
    Skipping implicit fixer: ws_comma

  Running setup.py install for amqp

Successfully installed kombu python-logstash anyjson amqp
Cleaning up...
Downloading/unpacking testtools==1.7.1 (from -r test_requirements.txt (line 1))
Downloading/unpacking python-mimeparse (from testtools==1.7.1->-r test_requirements.txt (line 1))
  Downloading python-mimeparse-0.1.4.tar.gz
  Running setup.py (path:/tmp/venv-core-image-publisherpy50c6da/build/python-mimeparse/setup.py) egg_info for package python-mimeparse

Downloading/unpacking extras (from testtools==1.7.1->-r test_requirements.txt (line 1))
  Downloading extras-0.0.3.tar.gz
  Running setup.py (path:/tmp/venv-core-image-publisherpy50c6da/build/extras/setup.py) egg_info for package extras

Downloading/unpacking unittest2>=1.0.0 (from testtools==1.7.1->-r test_requirements.txt (line 1))
Downloading/unpacking traceback2 (from testtools==1.7.1->-r test_requirements.txt (line 1))
  Downloading traceback2-1.4.0-py2.py3-none-any.whl
Downloading/unpacking argparse (from unittest2>=1.0.0->testtools==1.7.1->-r test_requirements.txt (line 1))
  Downloading argparse-1.3.0-py2.py3-none-any.whl
Downloading/unpacking six>=1.4 (from unittest2>=1.0.0->testtools==1.7.1->-r test_requirements.txt (line 1))
  Downloading six-1.9.0-py2.py3-none-any.whl
Downloading/unpacking linecache2 (from traceback2->testtools==1.7.1->-r test_requirements.txt (line 1))
  Downloading linecache2-1.0.0-py2.py3-none-any.whl
Installing collected packages: testtools, python-mi...

Read more...

10. By Thomi Richards

Fix import.

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-03-25 23:51:59 +0000
3+++ core_image_publisher/__init__.py 2015-03-26 22:26:38 +0000
4@@ -26,6 +26,7 @@
5 create_connection_from_config,
6 CoreImagePublisherQueueMonitor,
7 )
8+from core_image_publisher import worker
9
10 logger = logging.getLogger(__name__)
11
12@@ -77,18 +78,16 @@
13 )
14
15
16-def logging_worker(message):
17- logger.info("Got %r", message.payload, extra=message.payload)
18- message.ack()
19-
20-
21 def main():
22 config = read_config()
23 configure_logging(config)
24 connection = create_connection_from_config(config)
25 try:
26 with connection:
27- worker = CoreImagePublisherQueueMonitor(connection, logging_worker)
28+ worker = CoreImagePublisherQueueMonitor(
29+ connection,
30+ worker.logging_worker
31+ )
32 worker.run()
33 except KeyboardInterrupt:
34 print("Bye!")
35
36=== modified file 'core_image_publisher/queue.py'
37--- core_image_publisher/queue.py 2015-03-25 23:51:59 +0000
38+++ core_image_publisher/queue.py 2015-03-26 22:26:38 +0000
39@@ -27,6 +27,7 @@
40 __all__ = [
41 'CoreImagePublisherQueueMonitor',
42 'create_connection_from_config',
43+ 'enqueue_message',
44 ]
45
46
47@@ -87,3 +88,7 @@
48 """
49 amqp_uris = config.get('amqp', 'uris').split()
50 return kombu.Connection(amqp_uris)
51+
52+
53+def enqueue_message(payload):
54+ """Enqueue 'payload' for the core-image-tester."""
55
56=== added file 'core_image_publisher/worker.py'
57--- core_image_publisher/worker.py 1970-01-01 00:00:00 +0000
58+++ core_image_publisher/worker.py 2015-03-26 22:26:38 +0000
59@@ -0,0 +1,58 @@
60+# core-image-publisher
61+# Copyright (C) 2015 Canonical
62+#
63+# This program is free software: you can redistribute it and/or modify
64+# it under the terms of the GNU General Public License as published by
65+# the Free Software Foundation, either version 3 of the License, or
66+# (at your option) any later version.
67+#
68+# This program is distributed in the hope that it will be useful,
69+# but WITHOUT ANY WARRANTY; without even the implied warranty of
70+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
71+# GNU General Public License for more details.
72+#
73+# You should have received a copy of the GNU General Public License
74+# along with this program. If not, see <http://www.gnu.org/licenses/>.
75+#
76+
77+"""Business logic or the service lives here."""
78+
79+from core_image_publisher.queue import enqueue_message
80+
81+
82+def logging_worker(message):
83+ logger.info("Got %r", message.payload, extra=message.payload)
84+ payload = message.payload
85+ try:
86+ image_name = payload['image_name']
87+ channel = payload['channel']
88+ device = payload['device']
89+ except KeyError as e:
90+ logger.error(
91+ "Unable to deserialize message payload - rejecting message: %s",
92+ s,
93+ extra=payload
94+ )
95+ message.reject()
96+ return
97+
98+ image_path = download_image(image_name, channel, device)
99+ nova_image_path = convert_nova_image(image_path)
100+ glance_image_name = upload_image_to_glance(nova_image_path)
101+
102+ payload['nova_image'] = glance_image_name
103+ enqueue_message(payload)
104+ message.ack()
105+
106+
107+def download_image(name, channel, device):
108+ """Download the ubuntu code image, return a path to it on disk."""
109+
110+
111+def convert_nova_image(image_path):
112+ """Convert a core image to a nova image, return path to the converted image."""
113+
114+
115+def upload_image_to_glance(nova_image_path):
116+ """Upload the nova image to glance, returning the name of the image in glance."""
117+

Subscribers

People subscribed via source and target branches

to all changes: