Merge lp:~dreamhosters/txaws/925050-update-regions into lp:txaws

Proposed by Duncan McGreggor
Status: Merged
Approved by: Duncan McGreggor
Approved revision: 135
Merged at revision: 133
Proposed branch: lp:~dreamhosters/txaws/925050-update-regions
Merge into: lp:txaws
Diff against target: 162 lines (+92/-13)
4 files modified
Makefile (+1/-1)
txaws/ec2/tests/test_client.py (+16/-7)
txaws/regions.py (+67/-0)
txaws/service.py (+8/-5)
To merge this branch: bzr merge lp:~dreamhosters/txaws/925050-update-regions
Reviewer Review Type Date Requested Status
Arsene Rei Approve
Review via email: mp+91181@code.launchpad.net

Description of the change

This code isn't used by anything internally yet, but the newest regions for supported services will provide folks with an easy reference.

New code that will use this will be done in bug #925052.

To post a comment you must log in.
Revision history for this message
Arsene Rei (arsene-rei) wrote :

Yup, looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2012-01-27 07:22:34 +0000
3+++ Makefile 2012-02-01 23:01:22 +0000
4@@ -121,7 +121,7 @@
5
6 check: MOD ?= txaws
7 check: build
8- trial ./txaws
9+ trial $(MOD)
10
11
12 register:
13
14=== modified file 'txaws/ec2/tests/test_client.py'
15--- txaws/ec2/tests/test_client.py 2012-01-29 07:46:54 +0000
16+++ txaws/ec2/tests/test_client.py 2012-02-01 23:01:22 +0000
17@@ -2006,14 +2006,16 @@
18 d.addCallback(self.assertTrue)
19 return d
20
21+
22 class EC2ParserTestCase(TXAWSTestCase):
23
24 def setUp(self):
25 self.parser = client.Parser()
26
27 def test_ec2_terminate_instances(self):
28- """ Given a well formed response from EC2, will we parse the correct thing. """
29-
30+ """
31+ Given a well formed response from EC2, parse the correct thing.
32+ """
33 ec2_xml = """<?xml version="1.0" encoding="UTF-8"?>
34 <TerminateInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2008-12-01/">
35 <requestId>d0adc305-7f97-4652-b7c2-6993b2bb8260</requestId>
36@@ -2032,13 +2034,20 @@
37 </instancesSet>
38 </TerminateInstancesResponse>"""
39 ec2_response = self.parser.terminate_instances(ec2_xml)
40- self.assertEquals([('i-cab0c1aa','running','shutting-down')], ec2_response)
41+ self.assertEquals(
42+ [('i-cab0c1aa', 'running', 'shutting-down')], ec2_response)
43
44 def test_nova_terminate_instances(self):
45- """ Ensure parser can handle the somewhat non-standard response from nova
46- Note that the bug has been reported in nova here:
47- https://launchpad.net/bugs/862680 """
48+ """
49+ Ensure parser can handle the somewhat non-standard response from nova
50+ Note that the bug has been reported in nova here:
51+ https://launchpad.net/bugs/862680
52+ """
53
54- nova_xml = """<?xml version="1.0" ?><TerminateInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2008-12-01/"><requestId>4fe6643d-2346-4add-adb7-a1f61f37c043</requestId><return>true</return></TerminateInstancesResponse>"""
55+ nova_xml = (
56+ '<?xml version="1.0" ?><TerminateInstancesResponse '
57+ 'xmlns="http://ec2.amazonaws.com/doc/2008-12-01/"><requestId>'
58+ '4fe6643d-2346-4add-adb7-a1f61f37c043</requestId>'
59+ '<return>true</return></TerminateInstancesResponse>')
60 nova_response = self.parser.terminate_instances(nova_xml)
61 self.assertEquals([], nova_response)
62
63=== added file 'txaws/regions.py'
64--- txaws/regions.py 1970-01-01 00:00:00 +0000
65+++ txaws/regions.py 2012-02-01 23:01:22 +0000
66@@ -0,0 +1,67 @@
67+# Copyright (C) 2009 Duncan McGreggor <duncan@canonical.com>
68+# Copyright (C) 2009 Robert Collins <robertc@robertcollins.net>
69+# Copyright (C) 2012 New Dream Network, LLC (DreamHost)
70+# Licenced under the txaws licence available at /LICENSE in the txaws source.
71+
72+__all__ = ["REGION_US", "REGION_EU", "EC2_US_EAST", "EC2_US_WEST",
73+"EC2_ASIA_PACIFIC", "EC2_EU_WEST", "EC2_SOUTH_AMERICA_EAST", "EC2_ALL_REGIONS"]
74+
75+
76+# These old EC2 variable names are maintained for backwards compatibility.
77+REGION_US = "US"
78+REGION_EU = "EU"
79+EC2_ENDPOINT_US = "https://us-east-1.ec2.amazonaws.com/"
80+EC2_ENDPOINT_EU = "https://eu-west-1.ec2.amazonaws.com/"
81+
82+# These are the new EC2 variables.
83+EC2_US_EAST = [
84+ {"region": "US East (Northern Virginia) Region",
85+ "endpoint": "https://ec2.us-east-1.amazonaws.com"}]
86+EC2_US_WEST = [
87+ {"region": "US West (Oregon) Region",
88+ "endpoint": "https://ec2.us-west-2.amazonaws.com"},
89+ {"region": "US West (Northern California) Region",
90+ "endpoint": "https://ec2.us-west-1.amazonaws.com"}]
91+EC2_US = EC2_US_EAST + EC2_US_WEST
92+EC2_ASIA_PACIFIC = [
93+ {"region": "Asia Pacific (Singapore) Region",
94+ "endpoint": "https://ec2.ap-southeast-1.amazonaws.com"},
95+ {"region": "Asia Pacific (Tokyo) Region",
96+ "endpoint": "https://ec2.ap-northeast-1.amazonaws.com"}]
97+EC2_EU_WEST = [
98+ {"region": "EU (Ireland) Region",
99+ "endpoint": "https://ec2.eu-west-1.amazonaws.com"}]
100+EC2_EU = EC2_EU_WEST
101+EC2_SOUTH_AMERICA_EAST = [
102+ {"region": "South America (Sao Paulo) Region",
103+ "endpoint": "https://ec2.sa-east-1.amazonaws.com"}]
104+EC2_SOUTH_AMERICA = EC2_SOUTH_AMERICA_EAST
105+EC2_ALL_REGIONS = EC2_US + EC2_ASIA_PACIFIC + EC2_EU + EC2_SOUTH_AMERICA
106+
107+# This old S3 variable is maintained for backwards compatibility.
108+S3_ENDPOINT = "https://s3.amazonaws.com/"
109+
110+# These are the new S3 variables.
111+S3_US_DEFAULT = [
112+ {"region": "US Standard *",
113+ "endpoint": "https://s3.amazonaws.com"}]
114+S3_US_WEST = [
115+ {"region": "US West (Oregon) Region",
116+ "endpoint": "https://s3-us-west-2.amazonaws.com"},
117+ {"region": "US West (Northern California) Region",
118+ "endpoint": "https://s3-us-west-1.amazonaws.com"}]
119+S3_ASIA_PACIFIC = [
120+ {"region": "Asia Pacific (Singapore) Region",
121+ "endpoint": "https://s3-ap-southeast-1.amazonaws.com"},
122+ {"region": "Asia Pacific (Tokyo) Region",
123+ "endpoint": "https://s3-ap-northeast-1.amazonaws.com"}]
124+S3_US = S3_US_DEFAULT + S3_US_WEST
125+S3_EU_WEST = [
126+ {"region": "EU (Ireland) Region",
127+ "endpoint": "https://s3-eu-west-1.amazonaws.com"}]
128+S3_EU = S3_EU_WEST
129+S3_SOUTH_AMERICA_EAST = [
130+ {"region": "South America (Sao Paulo) Region",
131+ "endpoint": "s3-sa-east-1.amazonaws.com"}]
132+S3_SOUTH_AMERICA = S3_SOUTH_AMERICA_EAST
133+S3_ALL_REGIONS = S3_US + S3_ASIA_PACIFIC + S3_EU + S3_SOUTH_AMERICA
134
135=== modified file 'txaws/service.py'
136--- txaws/service.py 2011-11-29 08:17:54 +0000
137+++ txaws/service.py 2012-02-01 23:01:22 +0000
138@@ -3,16 +3,19 @@
139 # Licenced under the txaws licence available at /LICENSE in the txaws source.
140
141 from txaws.credentials import AWSCredentials
142+from txaws import regions
143 from txaws.util import parse
144
145+
146 __all__ = ["AWSServiceEndpoint", "AWSServiceRegion", "REGION_US", "REGION_EU"]
147
148
149-REGION_US = "US"
150-REGION_EU = "EU"
151-EC2_ENDPOINT_US = "https://us-east-1.ec2.amazonaws.com/"
152-EC2_ENDPOINT_EU = "https://eu-west-1.ec2.amazonaws.com/"
153-S3_ENDPOINT = "https://s3.amazonaws.com/"
154+# These old variable names are maintained for backwards compatibility.
155+REGION_US = regions.REGION_US
156+REGION_EU = regions.REGION_EU
157+EC2_ENDPOINT_US = regions.EC2_ENDPOINT_US
158+EC2_ENDPOINT_EU = regions.EC2_ENDPOINT_EU
159+S3_ENDPOINT = regions.S3_ENDPOINT
160
161
162 class AWSServiceEndpoint(object):

Subscribers

People subscribed via source and target branches