Merge lp:~abentley/juju-release-tools/lowercase-azure-regions into lp:juju-release-tools

Proposed by Aaron Bentley
Status: Merged
Merged at revision: 326
Proposed branch: lp:~abentley/juju-release-tools/lowercase-azure-regions
Merge into: lp:juju-release-tools
Diff against target: 180 lines (+41/-40)
2 files modified
azure_image_streams.py (+30/-30)
tests/test_azure_image_streams.py (+11/-10)
To merge this branch: bzr merge lp:~abentley/juju-release-tools/lowercase-azure-regions
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+300946@code.launchpad.net

Commit message

Use location name as region instead of display name.

Description of the change

This branch changes the region for azure-ARM to be the location name.

Old Azure's simplestreams used the display name, a value with capital letters and spaces. Andrew Wilkins has asked us to use the actual location name, which is the same value users might enter at the commandline when bootstrapping.

Given that old-Azure and Azure-ARM seem to be completely different when it comes to simplestreams, this seems like a reasonable request to me.

To post a comment you must log in.
326. By Aaron Bentley

Merge trunk.

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 'azure_image_streams.py'
2--- azure_image_streams.py 2016-07-22 16:17:08 +0000
3+++ azure_image_streams.py 2016-07-22 19:43:09 +0000
4@@ -33,32 +33,32 @@
5
6
7 ITEM_NAMES = {
8- "Australia East": "auee1i3",
9- "Australia Southeast": "ause1i3",
10- "Brazil South": "brss1i3",
11- "Canada Central": "cacc1i3",
12- "Canada East": "caee1i3",
13- "Central India": "incc1i3",
14- "Central US": "uscc1i3",
15- "China East": "cnee1i3",
16- "China North": "cnnn1i3",
17- "East Asia": "asee1i3",
18- "East US 2": "usee2i3",
19- "East US": "usee1i3",
20- "Japan East": "jpee1i3",
21- "Japan West": "jpww1i3",
22- "North Central US": "usnc1i3",
23- "North Europe": "eunn1i3",
24- "South Central US": "ussc1i3",
25- "Southeast Asia": "asse1i3",
26- "South India": "inss1i3",
27- "UK North": "gbnn1i3",
28- "UK South 2": "gbss2i3",
29- "West Central US": "uswc1i3",
30- "West Europe": "euww1i3",
31- "West India": "inww1i3",
32- "West US 2": "usww2i3",
33- "West US": "usww1i3",
34+ "australiaeast": "auee1i3",
35+ "australiasoutheast": "ause1i3",
36+ "brazilsouth": "brss1i3",
37+ "canadacentral": "cacc1i3",
38+ "canadaeast": "caee1i3",
39+ "centralindia": "incc1i3",
40+ "centralus": "uscc1i3",
41+ "chinaeast": "cnee1i3",
42+ "chinanorth": "cnnn1i3",
43+ "eastasia": "asee1i3",
44+ "eastus2": "usee2i3",
45+ "eastus": "usee1i3",
46+ "japaneast": "jpee1i3",
47+ "japanwest": "jpww1i3",
48+ "northcentralus": "usnc1i3",
49+ "northeurope": "eunn1i3",
50+ "southcentralus": "ussc1i3",
51+ "southeastasia": "asse1i3",
52+ "southindia": "inss1i3",
53+ "uknorth": "gbnn1i3",
54+ "uksouth2": "gbss2i3",
55+ "westcentralus": "uswc1i3",
56+ "westeurope": "euww1i3",
57+ "westindia": "inww1i3",
58+ "westus2": "usww2i3",
59+ "westus": "usww1i3",
60 }
61
62
63@@ -143,11 +143,11 @@
64 return True
65
66
67-def convert_item_to_arm(item, urn, endpoint):
68+def convert_item_to_arm(item, urn, endpoint, region):
69 """Return the ARM equivalent of an item, given a urn + endpoint."""
70 data = dict(item.data)
71 data.pop('crsn', None)
72- data.update({'id': urn, 'endpoint': endpoint})
73+ data.update({'id': urn, 'endpoint': endpoint, 'region': region})
74 return Item(item.content_id, item.product_name, item.version_name,
75 item.item_name, data=data)
76
77@@ -186,7 +186,7 @@
78 if (sku, version) in EXPECTED_MISSING:
79 raise UnexpectedImage(
80 'Unexpectedly found {} in {}\n'.format(urn, location))
81- arm_items.append(convert_item_to_arm(item, urn, endpoint))
82+ arm_items.append(convert_item_to_arm(item, urn, endpoint, location))
83 return arm_items, unknown_locations
84
85
86@@ -212,7 +212,7 @@
87 continue
88 for version in versions:
89 location_versions.setdefault(
90- version.name, set()).add(location.display_name)
91+ version.name, set()).add(location.name)
92 lv2 = sorted(location_versions.items(), key=lambda x: [
93 int(ns) for ns in x[0].split('.')])
94 for num, (version, v_locations) in enumerate(lv2):
95
96=== modified file 'tests/test_azure_image_streams.py'
97--- tests/test_azure_image_streams.py 2016-07-22 16:17:08 +0000
98+++ tests/test_azure_image_streams.py 2016-07-22 19:43:09 +0000
99@@ -164,19 +164,19 @@
100 def test_convert_item_to_arm(self, item_id=None):
101 item = make_old_item(item_id)
102 arm_item = convert_item_to_arm(
103- item, 'ww:xx:yy:zz', 'http://example.com/arm')
104+ item, 'ww:xx:yy:zz', 'http://example.com/arm', 'westeros')
105 self.assertEqual(arm_item, Item('aa', 'bb', 'cc', '99', {
106 'id': 'ww:xx:yy:zz',
107 'foo': 'bar',
108 'endpoint': 'http://example.com/arm',
109- 'region': 'Westeros',
110+ 'region': 'westeros',
111 }))
112
113 def test_discard_crsn(self):
114 item = make_old_item()
115 item.data['crsn'] = 'asdf'
116 arm_item = convert_item_to_arm(
117- item, 'ww:xx:yy:zz', 'http://example.com/arm')
118+ item, 'ww:xx:yy:zz', 'http://example.com/arm', 'westeros')
119 self.assertNotIn('crsn', arm_item.data)
120
121
122@@ -187,7 +187,8 @@
123 sku, version = parse_id(old_item.data['id'])
124 full_spec = (CANONICAL, UBUNTU_SERVER, sku, version)
125 urn = ':'.join(full_spec)
126- expected_item = convert_item_to_arm(old_item, urn, endpoint)
127+ arm_region = old_item.data['region'].lower().replace(' ', '')
128+ expected_item = convert_item_to_arm(old_item, urn, endpoint, arm_region)
129 return old_item, full_spec, expected_item
130
131
132@@ -243,7 +244,7 @@
133 offer = 'CentOS' if centos else 'bar'
134 release = 'centos7' if centos else 'win95'
135 full_spec = (release, 'foo', offer, 'baz')
136- region_name = 'Canada East'
137+ region_name = 'canadaeast'
138 endpoint = 'http://example.org'
139 return make_item('1', 'pete', full_spec, region_name, endpoint)
140
141@@ -256,7 +257,7 @@
142 'caee1i3', {
143 'arch': 'amd64',
144 'virt': 'Hyper-V',
145- 'region': 'Canada East',
146+ 'region': 'canadaeast',
147 'id': 'foo:bar:baz:pete',
148 'label': 'release',
149 'endpoint': 'http://example.org',
150@@ -272,7 +273,7 @@
151 'caee1i3', {
152 'arch': 'amd64',
153 'virt': 'Hyper-V',
154- 'region': 'Canada East',
155+ 'region': 'canadaeast',
156 'id': 'foo:CentOS:baz:pete',
157 'label': 'release',
158 'endpoint': 'http://example.org',
159@@ -304,10 +305,10 @@
160 expected_items = []
161 expected_calls = []
162 for spec in specs:
163- expected_calls.append(call('region1', *spec[1:]))
164+ expected_calls.append(call('canadaeast', *spec[1:]))
165 for num, version in enumerate(versions):
166 expected_items.append(
167- make_item(str(num), version, spec, 'Canada East',
168+ make_item(str(num), version, spec, 'canadaeast',
169 client.config.base_url))
170 return expected_calls, expected_items
171
172@@ -316,7 +317,7 @@
173
174 def test_make_spec_items(self):
175 client = mock_compute_client(['1', '2'])
176- locations = [mock_location('region1', 'Canada East')]
177+ locations = [mock_location('canadaeast', 'Canada East')]
178 items = list(make_spec_items(client, IMAGE_SPEC[0], locations))
179 expected_calls, expected_items = make_expected(
180 client, ['1', '2'], [IMAGE_SPEC[0]])

Subscribers

People subscribed via source and target branches