Merge lp:~abentley/juju-release-tools/image-index into lp:juju-release-tools

Proposed by Aaron Bentley
Status: Merged
Merged at revision: 304
Proposed branch: lp:~abentley/juju-release-tools/image-index
Merge into: lp:juju-release-tools
Diff against target: 77 lines (+13/-7)
2 files modified
make_aws_image_streams.py (+9/-3)
tests/test_make_aws_image_streams.py (+4/-4)
To merge this branch: bzr merge lp:~abentley/juju-release-tools/image-index
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+295334@code.launchpad.net

Commit message

Use index.json, not index2.json for images.

Description of the change

This branch switches image streams to use index.json as their index.

index2.json is a workaround needed for agents because we now use multiple content-ids, and early jujus couldn't cope with that. But it was not a change to the simplestreams format. Juju considers index.json a "legacy" file, but it still uses it, and this is still the only file generated by cloud-images.

Early jujus could break if they encountered multiple image-ids in simplestreams, but they didn't access streams.canonical.com/images/releases by default. Setting image-streams changes both content-id and URL, so there's no reason for image streams to have multiple content-ids. So streams.canonical.com/images/releases is unlikely to ever have multiple content-ids, but even if it did, it would not break old jujus.

Therefore, image streams should follow the format used by cloud-images.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'make_aws_image_streams.py'
2--- make_aws_image_streams.py 2016-05-10 19:03:36 +0000
3+++ make_aws_image_streams.py 2016-05-20 15:27:55 +0000
4@@ -11,6 +11,7 @@
5
6 from boto import ec2
7 from simplestreams.generate_simplestreams import (
8+ FileNamer,
9 generate_index,
10 items2content_trees,
11 json_dump,
12@@ -18,11 +19,17 @@
13 from simplestreams.json2streams import (
14 Item,
15 JujuFileNamer,
16- write_release_index,
17 )
18 from simplestreams import util
19
20
21+class WindowsFriendlyNamer(JujuFileNamer):
22+
23+ @classmethod
24+ def get_index_path(cls):
25+ return FileNamer.get_index_path()
26+
27+
28 def get_parameters(argv=None):
29 """Return streams, creds_filename for this invocation.
30
31@@ -205,7 +212,7 @@
32 # Based on simplestreams.json2streams.write_juju_streams +
33 # simplestreams.generate_simplestreams.write_streams,
34 # but allows sticky to be specified.
35- namer = JujuFileNamer
36+ namer = WindowsFriendlyNamer
37 index = generate_index(trees, updated, namer)
38 to_write = [(namer.get_index_path(), index,)]
39 # Don't let products_condense modify the input
40@@ -221,7 +228,6 @@
41 util.mkdir_p(os.path.dirname(filef))
42 json_dump(data, filef)
43 out_filenames.append(filef)
44- out_filenames.append(write_release_index(out_d))
45 return out_filenames
46
47
48
49=== modified file 'tests/test_make_aws_image_streams.py'
50--- tests/test_make_aws_image_streams.py 2016-05-10 17:20:21 +0000
51+++ tests/test_make_aws_image_streams.py 2016-05-20 15:27:55 +0000
52@@ -282,13 +282,13 @@
53 with patch('sys.stderr'):
54 write_streams(credentials, china_credentials, now,
55 streams)
56+ self.assertFalse(
57+ os.path.exists(os.path.join(streams, 'streams', 'v1',
58+ 'index2.json')))
59 index = load_json(streams, 'index.json')
60- index2 = load_json(streams, 'index2.json')
61 releases = load_json(streams, 'com.ubuntu.cloud.released-aws.json')
62 irc_mock.assert_called_once_with(credentials, china_credentials)
63 self.assertEqual(
64- {'format': 'index:1.0', 'updated': 'now', 'index': {}}, index)
65- self.assertEqual(
66 {'format': 'index:1.0', 'updated': 'now', 'index': {
67 'com.ubuntu.cloud.released:aws': {
68 'format': 'products:1.0',
69@@ -297,7 +297,7 @@
70 'path': 'streams/v1/com.ubuntu.cloud.released-aws.json',
71 'products': ['com.ubuntu.cloud:server:centos7:amd64'],
72 }
73- }}, index2)
74+ }}, index)
75 expected = {
76 'content_id': 'com.ubuntu.cloud.released:aws',
77 'format': 'products:1.0',

Subscribers

People subscribed via source and target branches