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
=== modified file 'core-service.conf'
--- core-service.conf 2015-03-31 14:27:00 +0000
+++ core-service.conf 2015-04-22 19:35:13 +0000
@@ -4,7 +4,8 @@
4uris = amqp://guest:guest@localhost:5672//4uris = amqp://guest:guest@localhost:5672//
55
6[image]6[image]
7channel = ubuntu-core/devel-proposed7channel = edge
8release = rolling
8device = generic_amd649device = generic_amd64
9location = /tmp/latest-core-image-version10location = /tmp/latest-core-image-version
10poll_period = 6011poll_period = 60
1112
=== modified file 'core_image_watcher/__init__.py'
--- core_image_watcher/__init__.py 2015-04-08 01:59:01 +0000
+++ core_image_watcher/__init__.py 2015-04-22 19:35:13 +0000
@@ -57,13 +57,13 @@
57 logger.info('Done!', extra=extra)57 logger.info('Done!', extra=extra)
5858
5959
60def _get_version_string_output(channel, device):60def _get_version_string_output(release, channel, device):
61 """Obtains a bytestring of the images info from the core image server"""61 """Obtains a bytestring of the images info from the core image server"""
62 cmd = [62 cmd = [
63 'ubuntu-device-flash',63 'ubuntu-device-flash',
64 'query',64 'query',
65 '--list-images',65 '--list-images',
66 '--channel={}'.format(channel),66 '--channel=ubuntu-core/{}/{}'.format(release, channel),
67 '--device={}'.format(device),67 '--device={}'.format(device),
68 ]68 ]
69 images = b''69 images = b''
@@ -75,11 +75,12 @@
75 return images75 return images
7676
7777
78def _get_latest_image_version(channel,78def _get_latest_image_version(release,
79 channel,
79 device,80 device,
80 get_output=_get_version_string_output):81 get_output=_get_version_string_output):
81 """Returns largest image version"""82 """Returns largest image version"""
82 images = get_output(channel, device).split()83 images = get_output(release, channel, device).split()
83 if (len(images) >= 2):84 if (len(images) >= 2):
84 return images[-2].decode('utf-8').replace(':', '')85 return images[-2].decode('utf-8').replace(':', '')
8586
@@ -110,12 +111,13 @@
110111
111112
112def _check_for_new_image(location,113def _check_for_new_image(location,
114 release,
113 channel,115 channel,
114 device,116 device,
115 latest_image_version=_get_latest_image_version,117 latest_image_version=_get_latest_image_version,
116 cached_version=_cache_version_to_disk):118 cached_version=_cache_version_to_disk):
117 """Check if a new image is present in the core image server"""119 """Check if a new image is present in the core image server"""
118 latest_version = latest_image_version(channel, device)120 latest_version = latest_image_version(release, channel, device)
119 try:121 try:
120 ret = cached_version(location, latest_version)122 ret = cached_version(location, latest_version)
121 if not ret:123 if not ret:
@@ -127,6 +129,7 @@
127 return None129 return None
128 body = {130 body = {
129 'image_name': latest_version,131 'image_name': latest_version,
132 'release': release,
130 'channel': channel,133 'channel': channel,
131 'device': device,134 'device': device,
132 'request_id': uuid(),135 'request_id': uuid(),
@@ -156,6 +159,7 @@
156159
157 amqp_uris = config.get('amqp', 'uris').split()160 amqp_uris = config.get('amqp', 'uris').split()
158 location = config.get('image', 'location')161 location = config.get('image', 'location')
162 release = config.get('image', 'release')
159 channel = config.get('image', 'channel')163 channel = config.get('image', 'channel')
160 device = config.get('image', 'device')164 device = config.get('image', 'device')
161 poll_period = float(config.get('image', 'poll_period'))165 poll_period = float(config.get('image', 'poll_period'))
@@ -163,6 +167,7 @@
163 try:167 try:
164 while True:168 while True:
165 message_body = _check_for_new_image(location,169 message_body = _check_for_new_image(location,
170 release,
166 channel,171 channel,
167 device)172 device)
168 if message_body:173 if message_body:
169174
=== modified file 'core_image_watcher/tests/test_image_watcher.py'
--- core_image_watcher/tests/test_image_watcher.py 2015-04-07 23:58:33 +0000
+++ core_image_watcher/tests/test_image_watcher.py 2015-04-22 19:35:13 +0000
@@ -65,32 +65,35 @@
65 self.assertEqual(return_value, '112')65 self.assertEqual(return_value, '112')
6666
67 def test_get_latest_version(self):67 def test_get_latest_version(self):
68 def get_output(channel, device):68 def get_output(release, channel, device):
69 return b"295: description='fake295'\n\69 return b"295: description='fake295'\n\
70 296: description='fake296'\n\70 296: description='fake296'\n\
71 297: description='fake297'\n\71 297: description='fake297'\n\
72 298: description='fake338'\n"72 298: description='fake338'\n"
73 observed = _get_latest_image_version('fakechannel',73 observed = _get_latest_image_version('fakerelease',
74 'fakechannel',
74 'fakedevice',75 'fakedevice',
75 get_output)76 get_output)
76 self.assertEqual(observed, '298')77 self.assertEqual(observed, '298')
7778
78 def test_dont_get_latest_version(self):79 def test_dont_get_latest_version(self):
79 def get_output(channel, device):80 def get_output(release, channel, device):
80 return b"100: description='fake100'\n"81 return b"100: description='fake100'\n"
81 observed = _get_latest_image_version('fakechannel',82 observed = _get_latest_image_version('fakerelease',
83 'fakechannel',
82 'fakedevice',84 'fakedevice',
83 get_output)85 get_output)
84 self.assertEqual(observed, '100')86 self.assertEqual(observed, '100')
8587
86 def test_check_for_new_image(self):88 def test_check_for_new_image(self):
87 def _get_latest_image_version(channel, device):89 def _get_latest_image_version(release, channel, device):
88 return '100'90 return '100'
8991
90 def _cache_version_to_disk(location, latest_version):92 def _cache_version_to_disk(location, latest_version):
91 return '99'93 return '99'
9294
93 body = _check_for_new_image('fakelocation',95 body = _check_for_new_image('fakelocation',
96 'fakerelease',
94 'fakechannel',97 'fakechannel',
95 'fakedevice',98 'fakedevice',
96 _get_latest_image_version,99 _get_latest_image_version,
@@ -101,6 +104,7 @@
101 {104 {
102 'device': Equals('fakedevice'),105 'device': Equals('fakedevice'),
103 'image_name': Equals('100'),106 'image_name': Equals('100'),
107 'release': Equals('fakerelease'),
104 'channel': Equals('fakechannel'),108 'channel': Equals('fakechannel'),
105 'request_id': NotEquals(''),109 'request_id': NotEquals(''),
106 }110 }
@@ -108,13 +112,14 @@
108 )112 )
109113
110 def test_check_for_no_new_image(self):114 def test_check_for_no_new_image(self):
111 def _get_latest_image_version(channel, device):115 def _get_latest_image_version(release, channel, device):
112 return '100'116 return '100'
113117
114 def _cache_version_to_disk(location, latest_version):118 def _cache_version_to_disk(location, latest_version):
115 return None119 return None
116120
117 body = _check_for_new_image('fakelocation',121 body = _check_for_new_image('fakelocation',
122 'fakerelease',
118 'fakechannel',123 'fakechannel',
119 'fakedevice',124 'fakedevice',
120 _get_latest_image_version,125 _get_latest_image_version,

Subscribers

People subscribed via source and target branches