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

Proposed by Francis Ginther
Status: Rejected
Rejected by: Francis Ginther
Proposed branch: lp:~fginther/core-image-watcher/edge-support
Merge into: lp:core-image-watcher
Diff against target: 156 lines (+23/-12)
3 files modified
core-service.conf (+2/-1)
core_image_watcher/__init__.py (+10/-5)
core_image_watcher/tests/test_image_watcher.py (+11/-6)
To merge this branch: bzr merge lp:~fginther/core-image-watcher/edge-support
Reviewer Review Type Date Requested Status
Celso Providelo (community) Needs Information
Review via email: mp+257164@code.launchpad.net

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,

Wouldn't it be easier to simply have "channel = ubuntu-core/rolling/edge" ?

review: Needs Information
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

17. 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-service.conf'
2--- core-service.conf 2015-03-31 14:27:00 +0000
3+++ core-service.conf 2015-04-22 19:35:13 +0000
4@@ -4,7 +4,8 @@
5 uris = amqp://guest:guest@localhost:5672//
6
7 [image]
8-channel = ubuntu-core/devel-proposed
9+channel = edge
10+release = rolling
11 device = generic_amd64
12 location = /tmp/latest-core-image-version
13 poll_period = 60
14
15=== modified file 'core_image_watcher/__init__.py'
16--- core_image_watcher/__init__.py 2015-04-08 01:59:01 +0000
17+++ core_image_watcher/__init__.py 2015-04-22 19:35:13 +0000
18@@ -57,13 +57,13 @@
19 logger.info('Done!', extra=extra)
20
21
22-def _get_version_string_output(channel, device):
23+def _get_version_string_output(release, channel, device):
24 """Obtains a bytestring of the images info from the core image server"""
25 cmd = [
26 'ubuntu-device-flash',
27 'query',
28 '--list-images',
29- '--channel={}'.format(channel),
30+ '--channel=ubuntu-core/{}/{}'.format(release, channel),
31 '--device={}'.format(device),
32 ]
33 images = b''
34@@ -75,11 +75,12 @@
35 return images
36
37
38-def _get_latest_image_version(channel,
39+def _get_latest_image_version(release,
40+ channel,
41 device,
42 get_output=_get_version_string_output):
43 """Returns largest image version"""
44- images = get_output(channel, device).split()
45+ images = get_output(release, channel, device).split()
46 if (len(images) >= 2):
47 return images[-2].decode('utf-8').replace(':', '')
48
49@@ -110,12 +111,13 @@
50
51
52 def _check_for_new_image(location,
53+ release,
54 channel,
55 device,
56 latest_image_version=_get_latest_image_version,
57 cached_version=_cache_version_to_disk):
58 """Check if a new image is present in the core image server"""
59- latest_version = latest_image_version(channel, device)
60+ latest_version = latest_image_version(release, channel, device)
61 try:
62 ret = cached_version(location, latest_version)
63 if not ret:
64@@ -127,6 +129,7 @@
65 return None
66 body = {
67 'image_name': latest_version,
68+ 'release': release,
69 'channel': channel,
70 'device': device,
71 'request_id': uuid(),
72@@ -156,6 +159,7 @@
73
74 amqp_uris = config.get('amqp', 'uris').split()
75 location = config.get('image', 'location')
76+ release = config.get('image', 'release')
77 channel = config.get('image', 'channel')
78 device = config.get('image', 'device')
79 poll_period = float(config.get('image', 'poll_period'))
80@@ -163,6 +167,7 @@
81 try:
82 while True:
83 message_body = _check_for_new_image(location,
84+ release,
85 channel,
86 device)
87 if message_body:
88
89=== modified file 'core_image_watcher/tests/test_image_watcher.py'
90--- core_image_watcher/tests/test_image_watcher.py 2015-04-07 23:58:33 +0000
91+++ core_image_watcher/tests/test_image_watcher.py 2015-04-22 19:35:13 +0000
92@@ -65,32 +65,35 @@
93 self.assertEqual(return_value, '112')
94
95 def test_get_latest_version(self):
96- def get_output(channel, device):
97+ def get_output(release, channel, device):
98 return b"295: description='fake295'\n\
99 296: description='fake296'\n\
100 297: description='fake297'\n\
101 298: description='fake338'\n"
102- observed = _get_latest_image_version('fakechannel',
103+ observed = _get_latest_image_version('fakerelease',
104+ 'fakechannel',
105 'fakedevice',
106 get_output)
107 self.assertEqual(observed, '298')
108
109 def test_dont_get_latest_version(self):
110- def get_output(channel, device):
111+ def get_output(release, channel, device):
112 return b"100: description='fake100'\n"
113- observed = _get_latest_image_version('fakechannel',
114+ observed = _get_latest_image_version('fakerelease',
115+ 'fakechannel',
116 'fakedevice',
117 get_output)
118 self.assertEqual(observed, '100')
119
120 def test_check_for_new_image(self):
121- def _get_latest_image_version(channel, device):
122+ def _get_latest_image_version(release, channel, device):
123 return '100'
124
125 def _cache_version_to_disk(location, latest_version):
126 return '99'
127
128 body = _check_for_new_image('fakelocation',
129+ 'fakerelease',
130 'fakechannel',
131 'fakedevice',
132 _get_latest_image_version,
133@@ -101,6 +104,7 @@
134 {
135 'device': Equals('fakedevice'),
136 'image_name': Equals('100'),
137+ 'release': Equals('fakerelease'),
138 'channel': Equals('fakechannel'),
139 'request_id': NotEquals(''),
140 }
141@@ -108,13 +112,14 @@
142 )
143
144 def test_check_for_no_new_image(self):
145- def _get_latest_image_version(channel, device):
146+ def _get_latest_image_version(release, channel, device):
147 return '100'
148
149 def _cache_version_to_disk(location, latest_version):
150 return None
151
152 body = _check_for_new_image('fakelocation',
153+ 'fakerelease',
154 'fakechannel',
155 'fakedevice',
156 _get_latest_image_version,

Subscribers

People subscribed via source and target branches