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
=== modified file 'azure_image_streams.py'
--- azure_image_streams.py 2016-07-22 16:17:08 +0000
+++ azure_image_streams.py 2016-07-22 19:43:09 +0000
@@ -33,32 +33,32 @@
3333
3434
35ITEM_NAMES = {35ITEM_NAMES = {
36 "Australia East": "auee1i3",36 "australiaeast": "auee1i3",
37 "Australia Southeast": "ause1i3",37 "australiasoutheast": "ause1i3",
38 "Brazil South": "brss1i3",38 "brazilsouth": "brss1i3",
39 "Canada Central": "cacc1i3",39 "canadacentral": "cacc1i3",
40 "Canada East": "caee1i3",40 "canadaeast": "caee1i3",
41 "Central India": "incc1i3",41 "centralindia": "incc1i3",
42 "Central US": "uscc1i3",42 "centralus": "uscc1i3",
43 "China East": "cnee1i3",43 "chinaeast": "cnee1i3",
44 "China North": "cnnn1i3",44 "chinanorth": "cnnn1i3",
45 "East Asia": "asee1i3",45 "eastasia": "asee1i3",
46 "East US 2": "usee2i3",46 "eastus2": "usee2i3",
47 "East US": "usee1i3",47 "eastus": "usee1i3",
48 "Japan East": "jpee1i3",48 "japaneast": "jpee1i3",
49 "Japan West": "jpww1i3",49 "japanwest": "jpww1i3",
50 "North Central US": "usnc1i3",50 "northcentralus": "usnc1i3",
51 "North Europe": "eunn1i3",51 "northeurope": "eunn1i3",
52 "South Central US": "ussc1i3",52 "southcentralus": "ussc1i3",
53 "Southeast Asia": "asse1i3",53 "southeastasia": "asse1i3",
54 "South India": "inss1i3",54 "southindia": "inss1i3",
55 "UK North": "gbnn1i3",55 "uknorth": "gbnn1i3",
56 "UK South 2": "gbss2i3",56 "uksouth2": "gbss2i3",
57 "West Central US": "uswc1i3",57 "westcentralus": "uswc1i3",
58 "West Europe": "euww1i3",58 "westeurope": "euww1i3",
59 "West India": "inww1i3",59 "westindia": "inww1i3",
60 "West US 2": "usww2i3",60 "westus2": "usww2i3",
61 "West US": "usww1i3",61 "westus": "usww1i3",
62}62}
6363
6464
@@ -143,11 +143,11 @@
143 return True143 return True
144144
145145
146def convert_item_to_arm(item, urn, endpoint):146def convert_item_to_arm(item, urn, endpoint, region):
147 """Return the ARM equivalent of an item, given a urn + endpoint."""147 """Return the ARM equivalent of an item, given a urn + endpoint."""
148 data = dict(item.data)148 data = dict(item.data)
149 data.pop('crsn', None)149 data.pop('crsn', None)
150 data.update({'id': urn, 'endpoint': endpoint})150 data.update({'id': urn, 'endpoint': endpoint, 'region': region})
151 return Item(item.content_id, item.product_name, item.version_name,151 return Item(item.content_id, item.product_name, item.version_name,
152 item.item_name, data=data)152 item.item_name, data=data)
153153
@@ -186,7 +186,7 @@
186 if (sku, version) in EXPECTED_MISSING:186 if (sku, version) in EXPECTED_MISSING:
187 raise UnexpectedImage(187 raise UnexpectedImage(
188 'Unexpectedly found {} in {}\n'.format(urn, location))188 'Unexpectedly found {} in {}\n'.format(urn, location))
189 arm_items.append(convert_item_to_arm(item, urn, endpoint))189 arm_items.append(convert_item_to_arm(item, urn, endpoint, location))
190 return arm_items, unknown_locations190 return arm_items, unknown_locations
191191
192192
@@ -212,7 +212,7 @@
212 continue212 continue
213 for version in versions:213 for version in versions:
214 location_versions.setdefault(214 location_versions.setdefault(
215 version.name, set()).add(location.display_name)215 version.name, set()).add(location.name)
216 lv2 = sorted(location_versions.items(), key=lambda x: [216 lv2 = sorted(location_versions.items(), key=lambda x: [
217 int(ns) for ns in x[0].split('.')])217 int(ns) for ns in x[0].split('.')])
218 for num, (version, v_locations) in enumerate(lv2):218 for num, (version, v_locations) in enumerate(lv2):
219219
=== modified file 'tests/test_azure_image_streams.py'
--- tests/test_azure_image_streams.py 2016-07-22 16:17:08 +0000
+++ tests/test_azure_image_streams.py 2016-07-22 19:43:09 +0000
@@ -164,19 +164,19 @@
164 def test_convert_item_to_arm(self, item_id=None):164 def test_convert_item_to_arm(self, item_id=None):
165 item = make_old_item(item_id)165 item = make_old_item(item_id)
166 arm_item = convert_item_to_arm(166 arm_item = convert_item_to_arm(
167 item, 'ww:xx:yy:zz', 'http://example.com/arm')167 item, 'ww:xx:yy:zz', 'http://example.com/arm', 'westeros')
168 self.assertEqual(arm_item, Item('aa', 'bb', 'cc', '99', {168 self.assertEqual(arm_item, Item('aa', 'bb', 'cc', '99', {
169 'id': 'ww:xx:yy:zz',169 'id': 'ww:xx:yy:zz',
170 'foo': 'bar',170 'foo': 'bar',
171 'endpoint': 'http://example.com/arm',171 'endpoint': 'http://example.com/arm',
172 'region': 'Westeros',172 'region': 'westeros',
173 }))173 }))
174174
175 def test_discard_crsn(self):175 def test_discard_crsn(self):
176 item = make_old_item()176 item = make_old_item()
177 item.data['crsn'] = 'asdf'177 item.data['crsn'] = 'asdf'
178 arm_item = convert_item_to_arm(178 arm_item = convert_item_to_arm(
179 item, 'ww:xx:yy:zz', 'http://example.com/arm')179 item, 'ww:xx:yy:zz', 'http://example.com/arm', 'westeros')
180 self.assertNotIn('crsn', arm_item.data)180 self.assertNotIn('crsn', arm_item.data)
181181
182182
@@ -187,7 +187,8 @@
187 sku, version = parse_id(old_item.data['id'])187 sku, version = parse_id(old_item.data['id'])
188 full_spec = (CANONICAL, UBUNTU_SERVER, sku, version)188 full_spec = (CANONICAL, UBUNTU_SERVER, sku, version)
189 urn = ':'.join(full_spec)189 urn = ':'.join(full_spec)
190 expected_item = convert_item_to_arm(old_item, urn, endpoint)190 arm_region = old_item.data['region'].lower().replace(' ', '')
191 expected_item = convert_item_to_arm(old_item, urn, endpoint, arm_region)
191 return old_item, full_spec, expected_item192 return old_item, full_spec, expected_item
192193
193194
@@ -243,7 +244,7 @@
243 offer = 'CentOS' if centos else 'bar'244 offer = 'CentOS' if centos else 'bar'
244 release = 'centos7' if centos else 'win95'245 release = 'centos7' if centos else 'win95'
245 full_spec = (release, 'foo', offer, 'baz')246 full_spec = (release, 'foo', offer, 'baz')
246 region_name = 'Canada East'247 region_name = 'canadaeast'
247 endpoint = 'http://example.org'248 endpoint = 'http://example.org'
248 return make_item('1', 'pete', full_spec, region_name, endpoint)249 return make_item('1', 'pete', full_spec, region_name, endpoint)
249250
@@ -256,7 +257,7 @@
256 'caee1i3', {257 'caee1i3', {
257 'arch': 'amd64',258 'arch': 'amd64',
258 'virt': 'Hyper-V',259 'virt': 'Hyper-V',
259 'region': 'Canada East',260 'region': 'canadaeast',
260 'id': 'foo:bar:baz:pete',261 'id': 'foo:bar:baz:pete',
261 'label': 'release',262 'label': 'release',
262 'endpoint': 'http://example.org',263 'endpoint': 'http://example.org',
@@ -272,7 +273,7 @@
272 'caee1i3', {273 'caee1i3', {
273 'arch': 'amd64',274 'arch': 'amd64',
274 'virt': 'Hyper-V',275 'virt': 'Hyper-V',
275 'region': 'Canada East',276 'region': 'canadaeast',
276 'id': 'foo:CentOS:baz:pete',277 'id': 'foo:CentOS:baz:pete',
277 'label': 'release',278 'label': 'release',
278 'endpoint': 'http://example.org',279 'endpoint': 'http://example.org',
@@ -304,10 +305,10 @@
304 expected_items = []305 expected_items = []
305 expected_calls = []306 expected_calls = []
306 for spec in specs:307 for spec in specs:
307 expected_calls.append(call('region1', *spec[1:]))308 expected_calls.append(call('canadaeast', *spec[1:]))
308 for num, version in enumerate(versions):309 for num, version in enumerate(versions):
309 expected_items.append(310 expected_items.append(
310 make_item(str(num), version, spec, 'Canada East',311 make_item(str(num), version, spec, 'canadaeast',
311 client.config.base_url))312 client.config.base_url))
312 return expected_calls, expected_items313 return expected_calls, expected_items
313314
@@ -316,7 +317,7 @@
316317
317 def test_make_spec_items(self):318 def test_make_spec_items(self):
318 client = mock_compute_client(['1', '2'])319 client = mock_compute_client(['1', '2'])
319 locations = [mock_location('region1', 'Canada East')]320 locations = [mock_location('canadaeast', 'Canada East')]
320 items = list(make_spec_items(client, IMAGE_SPEC[0], locations))321 items = list(make_spec_items(client, IMAGE_SPEC[0], locations))
321 expected_calls, expected_items = make_expected(322 expected_calls, expected_items = make_expected(
322 client, ['1', '2'], [IMAGE_SPEC[0]])323 client, ['1', '2'], [IMAGE_SPEC[0]])

Subscribers

People subscribed via source and target branches