Merge lp:~oubiwann/txaws/422066-fix-optional-params into lp:~txawsteam/txaws/trunk
- 422066-fix-optional-params
- Merge into trunk
Proposed by
Duncan McGreggor
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | not available | ||||
Proposed branch: | lp:~oubiwann/txaws/422066-fix-optional-params | ||||
Merge into: | lp:~txawsteam/txaws/trunk | ||||
Diff against target: | None lines | ||||
To merge this branch: | bzr merge lp:~oubiwann/txaws/422066-fix-optional-params | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Robert Collins (community) | Approve | ||
Review via email: mp+10941@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Duncan McGreggor (oubiwann) wrote : | # |
Revision history for this message
Robert Collins (lifeless) wrote : | # |
review +1
I think we should have kept the XML namespace support - its not correct
without it.
-Rob
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'txaws/ec2/client.py' | |||
2 | --- txaws/ec2/client.py 2009-08-31 07:52:14 +0000 | |||
3 | +++ txaws/ec2/client.py 2009-08-31 19:25:50 +0000 | |||
4 | @@ -1,4 +1,7 @@ | |||
5 | 1 | # -*- coding: utf-8 -*- | ||
6 | 1 | # Copyright (C) 2009 Robert Collins <robertc@robertcollins.net> | 2 | # Copyright (C) 2009 Robert Collins <robertc@robertcollins.net> |
7 | 3 | # Copyright (C) 2009 Duncan McGreggor <duncan@canonical.com> | ||
8 | 4 | # Copyright (C) 2009 Thomas Hervé <thomas@canonical.com> | ||
9 | 2 | # Licenced under the txaws licence available at /LICENSE in the txaws source. | 5 | # Licenced under the txaws licence available at /LICENSE in the txaws source. |
10 | 3 | 6 | ||
11 | 4 | """EC2 client support.""" | 7 | """EC2 client support.""" |
12 | @@ -8,6 +11,7 @@ | |||
13 | 8 | 11 | ||
14 | 9 | from twisted.web.client import getPage | 12 | from twisted.web.client import getPage |
15 | 10 | 13 | ||
16 | 14 | from txaws import version | ||
17 | 11 | from txaws.credentials import AWSCredentials | 15 | from txaws.credentials import AWSCredentials |
18 | 12 | from txaws.service import AWSServiceEndpoint | 16 | from txaws.service import AWSServiceEndpoint |
19 | 13 | from txaws.util import iso8601time, XML | 17 | from txaws.util import iso8601time, XML |
20 | @@ -140,6 +144,14 @@ | |||
21 | 140 | return the object that most developers and their code will be | 144 | return the object that most developers and their code will be |
22 | 141 | interested in: the instances. In instances reservation is available on | 145 | interested in: the instances. In instances reservation is available on |
23 | 142 | the instance object. | 146 | the instance object. |
24 | 147 | |||
25 | 148 | The following instance attributes are optional: | ||
26 | 149 | * ami_launch_index | ||
27 | 150 | * key_name | ||
28 | 151 | * kernel_id | ||
29 | 152 | * product_codes | ||
30 | 153 | * ramdisk_id | ||
31 | 154 | * reason | ||
32 | 143 | """ | 155 | """ |
33 | 144 | root = XML(xml_bytes) | 156 | root = XML(xml_bytes) |
34 | 145 | results = [] | 157 | results = [] |
35 | @@ -171,9 +183,10 @@ | |||
36 | 171 | placement = instance_data.find("placement").findtext( | 183 | placement = instance_data.find("placement").findtext( |
37 | 172 | "availabilityZone") | 184 | "availabilityZone") |
38 | 173 | products = [] | 185 | products = [] |
42 | 174 | for product_data in instance_data.find("productCodesSet"): | 186 | product_codes = instance_data.find("productCodes") |
43 | 175 | product_code = product_data.findtext("productCode") | 187 | if product_codes: |
44 | 176 | products.append(product_code) | 188 | for product_data in instance_data.find("productCodes"): |
45 | 189 | products.append(product_data.text) | ||
46 | 177 | kernel_id = instance_data.findtext("kernelId") | 190 | kernel_id = instance_data.findtext("kernelId") |
47 | 178 | ramdisk_id = instance_data.findtext("ramdiskId") | 191 | ramdisk_id = instance_data.findtext("ramdiskId") |
48 | 179 | instance = Instance( | 192 | instance = Instance( |
49 | @@ -362,15 +375,15 @@ | |||
50 | 362 | """A query that may be submitted to EC2.""" | 375 | """A query that may be submitted to EC2.""" |
51 | 363 | 376 | ||
52 | 364 | def __init__(self, action, creds, endpoint, other_params=None, | 377 | def __init__(self, action, creds, endpoint, other_params=None, |
54 | 365 | time_tuple=None): | 378 | time_tuple=None, api_version=None): |
55 | 366 | """Create a Query to submit to EC2.""" | 379 | """Create a Query to submit to EC2.""" |
56 | 367 | self.creds = creds | 380 | self.creds = creds |
57 | 368 | self.endpoint = endpoint | 381 | self.endpoint = endpoint |
61 | 369 | # Require params (2008-12-01 API): | 382 | # Currently, txAWS only supports version 2008-12-01 |
62 | 370 | # Version, SignatureVersion, SignatureMethod, Action, AWSAccessKeyId, | 383 | if api_version is None: |
63 | 371 | # Timestamp || Expires, Signature, | 384 | api_version = version.aws_api |
64 | 372 | self.params = { | 385 | self.params = { |
66 | 373 | 'Version': '2008-12-01', | 386 | 'Version': api_version, |
67 | 374 | 'SignatureVersion': '2', | 387 | 'SignatureVersion': '2', |
68 | 375 | 'SignatureMethod': 'HmacSHA1', | 388 | 'SignatureMethod': 'HmacSHA1', |
69 | 376 | 'Action': action, | 389 | 'Action': action, |
70 | 377 | 390 | ||
71 | === modified file 'txaws/ec2/tests/test_client.py' | |||
72 | --- txaws/ec2/tests/test_client.py 2009-08-31 07:52:14 +0000 | |||
73 | +++ txaws/ec2/tests/test_client.py 2009-08-31 20:07:58 +0000 | |||
74 | @@ -1,4 +1,7 @@ | |||
75 | 1 | # -*- coding: utf-8 -*- | ||
76 | 1 | # Copyright (C) 2009 Robert Collins <robertc@robertcollins.net> | 2 | # Copyright (C) 2009 Robert Collins <robertc@robertcollins.net> |
77 | 3 | # Copyright (C) 2009 Duncan McGreggor <duncan@canonical.com> | ||
78 | 4 | # Copyright (C) 2009 Thomas Hervé <thomas@canonical.com> | ||
79 | 2 | # Licenced under the txaws licence available at /LICENSE in the txaws source. | 5 | # Licenced under the txaws licence available at /LICENSE in the txaws source. |
80 | 3 | 6 | ||
81 | 4 | from datetime import datetime | 7 | from datetime import datetime |
82 | @@ -9,173 +12,10 @@ | |||
83 | 9 | from txaws.credentials import AWSCredentials | 12 | from txaws.credentials import AWSCredentials |
84 | 10 | from txaws.ec2 import client | 13 | from txaws.ec2 import client |
85 | 11 | from txaws.service import AWSServiceEndpoint, EC2_ENDPOINT_US | 14 | from txaws.service import AWSServiceEndpoint, EC2_ENDPOINT_US |
86 | 15 | from txaws.testing import payload | ||
87 | 12 | from txaws.testing.base import TXAWSTestCase | 16 | from txaws.testing.base import TXAWSTestCase |
88 | 13 | 17 | ||
89 | 14 | 18 | ||
90 | 15 | sample_describe_instances_result = """<?xml version="1.0"?> | ||
91 | 16 | <DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2008-12-01/"> | ||
92 | 17 | <requestId>52b4c730-f29f-498d-94c1-91efb75994cc</requestId> | ||
93 | 18 | <reservationSet> | ||
94 | 19 | <item> | ||
95 | 20 | <reservationId>r-cf24b1a6</reservationId> | ||
96 | 21 | <ownerId>123456789012</ownerId> | ||
97 | 22 | <groupSet> | ||
98 | 23 | <item> | ||
99 | 24 | <groupId>default</groupId> | ||
100 | 25 | </item> | ||
101 | 26 | </groupSet> | ||
102 | 27 | <instancesSet> | ||
103 | 28 | <item> | ||
104 | 29 | <instanceId>i-abcdef01</instanceId> | ||
105 | 30 | <imageId>ami-12345678</imageId> | ||
106 | 31 | <instanceState> | ||
107 | 32 | <code>16</code> | ||
108 | 33 | <name>running</name> | ||
109 | 34 | </instanceState> | ||
110 | 35 | <privateDnsName>domU-12-31-39-03-15-11.compute-1.internal</privateDnsName> | ||
111 | 36 | <dnsName>ec2-75-101-245-65.compute-1.amazonaws.com</dnsName> | ||
112 | 37 | <reason/> | ||
113 | 38 | <keyName>keyname</keyName> | ||
114 | 39 | <amiLaunchIndex>0</amiLaunchIndex> | ||
115 | 40 | <productCodesSet> | ||
116 | 41 | <item> | ||
117 | 42 | <productCode>774F4FF8</productCode> | ||
118 | 43 | </item> | ||
119 | 44 | </productCodesSet> | ||
120 | 45 | |||
121 | 46 | <instanceType>c1.xlarge</instanceType> | ||
122 | 47 | <launchTime>2009-04-27T02:23:18.000Z</launchTime> | ||
123 | 48 | <placement> | ||
124 | 49 | <availabilityZone>us-east-1c</availabilityZone> | ||
125 | 50 | </placement> | ||
126 | 51 | <kernelId>aki-b51cf9dc</kernelId> | ||
127 | 52 | <ramdiskId>ari-b31cf9da</ramdiskId> | ||
128 | 53 | </item> | ||
129 | 54 | </instancesSet> | ||
130 | 55 | </item> | ||
131 | 56 | </reservationSet> | ||
132 | 57 | </DescribeInstancesResponse> | ||
133 | 58 | """ | ||
134 | 59 | |||
135 | 60 | |||
136 | 61 | sample_terminate_instances_result = """<?xml version="1.0"?> | ||
137 | 62 | <TerminateInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2008-12-01/"> | ||
138 | 63 | <instancesSet> | ||
139 | 64 | <item> | ||
140 | 65 | <instanceId>i-1234</instanceId> | ||
141 | 66 | <shutdownState> | ||
142 | 67 | <code>32</code> | ||
143 | 68 | <name>shutting-down</name> | ||
144 | 69 | </shutdownState> | ||
145 | 70 | <previousState> | ||
146 | 71 | <code>16</code> | ||
147 | 72 | <name>running</name> | ||
148 | 73 | </previousState> | ||
149 | 74 | </item> | ||
150 | 75 | <item> | ||
151 | 76 | <instanceId>i-5678</instanceId> | ||
152 | 77 | <shutdownState> | ||
153 | 78 | <code>32</code> | ||
154 | 79 | <name>shutting-down</name> | ||
155 | 80 | </shutdownState> | ||
156 | 81 | <previousState> | ||
157 | 82 | <code>32</code> | ||
158 | 83 | <name>shutting-down</name> | ||
159 | 84 | </previousState> | ||
160 | 85 | </item> | ||
161 | 86 | </instancesSet> | ||
162 | 87 | </TerminateInstancesResponse> | ||
163 | 88 | """ | ||
164 | 89 | |||
165 | 90 | |||
166 | 91 | sample_describe_volumes_result = """<?xml version="1.0"?> | ||
167 | 92 | <DescribeVolumesResponse xmlns="http://ec2.amazonaws.com/doc/2008-12-01/"> | ||
168 | 93 | <volumeSet> | ||
169 | 94 | <item> | ||
170 | 95 | <volumeId>vol-4282672b</volumeId> | ||
171 | 96 | <size>800</size> | ||
172 | 97 | <status>in-use</status> | ||
173 | 98 | <createTime>2008-05-07T11:51:50.000Z</createTime> | ||
174 | 99 | <attachmentSet> | ||
175 | 100 | <item> | ||
176 | 101 | <volumeId>vol-4282672b</volumeId> | ||
177 | 102 | <instanceId>i-6058a509</instanceId> | ||
178 | 103 | <size>800</size> | ||
179 | 104 | <snapshotId>snap-12345678</snapshotId> | ||
180 | 105 | <availabilityZone>us-east-1a</availabilityZone> | ||
181 | 106 | <status>attached</status> | ||
182 | 107 | <attachTime>2008-05-07T12:51:50.000Z</attachTime> | ||
183 | 108 | </item> | ||
184 | 109 | </attachmentSet> | ||
185 | 110 | </item> | ||
186 | 111 | </volumeSet> | ||
187 | 112 | </DescribeVolumesResponse> | ||
188 | 113 | """ | ||
189 | 114 | |||
190 | 115 | |||
191 | 116 | sample_describe_snapshots_result = """<?xml version="1.0"?> | ||
192 | 117 | <DescribeSnapshotsResponse xmlns="http://ec2.amazonaws.com/doc/2008-12-01"> | ||
193 | 118 | <snapshotSet> | ||
194 | 119 | <item> | ||
195 | 120 | <snapshotId>snap-78a54011</snapshotId> | ||
196 | 121 | <volumeId>vol-4d826724</volumeId> | ||
197 | 122 | <status>pending</status> | ||
198 | 123 | <startTime>2008-05-07T12:51:50.000Z</startTime> | ||
199 | 124 | <progress>80%</progress> | ||
200 | 125 | </item> | ||
201 | 126 | </snapshotSet> | ||
202 | 127 | </DescribeSnapshotsResponse> | ||
203 | 128 | """ | ||
204 | 129 | |||
205 | 130 | |||
206 | 131 | sample_create_volume_result = """<?xml version="1.0"?> | ||
207 | 132 | <CreateVolumeResponse xmlns="http://ec2.amazonaws.com/doc/2008-12-01"> | ||
208 | 133 | <volumeId>vol-4d826724</volumeId> | ||
209 | 134 | <size>800</size> | ||
210 | 135 | <status>creating</status> | ||
211 | 136 | <createTime>2008-05-07T11:51:50.000Z</createTime> | ||
212 | 137 | <availabilityZone>us-east-1a</availabilityZone> | ||
213 | 138 | <snapshotId></snapshotId> | ||
214 | 139 | </CreateVolumeResponse> | ||
215 | 140 | """ | ||
216 | 141 | |||
217 | 142 | |||
218 | 143 | sample_delete_volume_result = """<?xml version="1.0"?> | ||
219 | 144 | <DeleteVolumeResponse xmlns="http://ec2.amazonaws.com/doc/2008-12-01"> | ||
220 | 145 | <return>true</return> | ||
221 | 146 | </DeleteVolumeResponse> | ||
222 | 147 | """ | ||
223 | 148 | |||
224 | 149 | |||
225 | 150 | sample_create_snapshot_result = """<?xml version="1.0"?> | ||
226 | 151 | <CreateSnapshotResponse xmlns="http://ec2.amazonaws.com/doc/2008-12-01"> | ||
227 | 152 | <snapshotId>snap-78a54011</snapshotId> | ||
228 | 153 | <volumeId>vol-4d826724</volumeId> | ||
229 | 154 | <status>pending</status> | ||
230 | 155 | <startTime>2008-05-07T12:51:50.000Z</startTime> | ||
231 | 156 | <progress></progress> | ||
232 | 157 | </CreateSnapshotResponse> | ||
233 | 158 | """ | ||
234 | 159 | |||
235 | 160 | |||
236 | 161 | sample_delete_snapshot_result = """<?xml version="1.0"?> | ||
237 | 162 | <DeleteSnapshotResponse xmlns="http://ec2.amazonaws.com/doc/2008-12-01"> | ||
238 | 163 | <return>true</return> | ||
239 | 164 | </DeleteSnapshotResponse> | ||
240 | 165 | """ | ||
241 | 166 | |||
242 | 167 | |||
243 | 168 | sample_attach_volume_result = """<?xml version="1.0"?> | ||
244 | 169 | <AttachVolumeResponse xmlns="http://ec2.amazonaws.com/doc/2008-12-01"> | ||
245 | 170 | <volumeId>vol-4d826724</volumeId> | ||
246 | 171 | <instanceId>i-6058a509</instanceId> | ||
247 | 172 | <device>/dev/sdh</device> | ||
248 | 173 | <status>attaching</status> | ||
249 | 174 | <attachTime>2008-05-07T11:51:50.000Z</attachTime> | ||
250 | 175 | </AttachVolumeResponse> | ||
251 | 176 | """ | ||
252 | 177 | |||
253 | 178 | |||
254 | 179 | class ReservationTestCase(TXAWSTestCase): | 19 | class ReservationTestCase(TXAWSTestCase): |
255 | 180 | 20 | ||
256 | 181 | def test_reservation_creation(self): | 21 | def test_reservation_creation(self): |
257 | @@ -251,10 +91,39 @@ | |||
258 | 251 | self.assertEquals(instance.kernel_id, "aki-b51cf9dc") | 91 | self.assertEquals(instance.kernel_id, "aki-b51cf9dc") |
259 | 252 | self.assertEquals(instance.ramdisk_id, "ari-b31cf9da") | 92 | self.assertEquals(instance.ramdisk_id, "ari-b31cf9da") |
260 | 253 | 93 | ||
261 | 94 | def check_parsed_instances_required(self, results): | ||
262 | 95 | instance = results[0] | ||
263 | 96 | # check reservations | ||
264 | 97 | reservation = instance.reservation | ||
265 | 98 | self.assertEquals(reservation.reservation_id, "r-cf24b1a6") | ||
266 | 99 | self.assertEquals(reservation.owner_id, "123456789012") | ||
267 | 100 | # check groups | ||
268 | 101 | group = reservation.groups[0] | ||
269 | 102 | self.assertEquals(group, "default") | ||
270 | 103 | # check instance | ||
271 | 104 | self.assertEquals(instance.instance_id, "i-abcdef01") | ||
272 | 105 | self.assertEquals(instance.instance_state, "running") | ||
273 | 106 | self.assertEquals(instance.instance_type, "c1.xlarge") | ||
274 | 107 | self.assertEquals(instance.image_id, "ami-12345678") | ||
275 | 108 | self.assertEquals( | ||
276 | 109 | instance.private_dns_name, | ||
277 | 110 | "domU-12-31-39-03-15-11.compute-1.internal") | ||
278 | 111 | self.assertEquals( | ||
279 | 112 | instance.dns_name, | ||
280 | 113 | "ec2-75-101-245-65.compute-1.amazonaws.com") | ||
281 | 114 | self.assertEquals(instance.key_name, None) | ||
282 | 115 | self.assertEquals(instance.ami_launch_index, None) | ||
283 | 116 | self.assertEquals(instance.launch_time, "2009-04-27T02:23:18.000Z") | ||
284 | 117 | self.assertEquals(instance.placement, "us-east-1c") | ||
285 | 118 | self.assertEquals(instance.product_codes, []) | ||
286 | 119 | self.assertEquals(instance.kernel_id, None) | ||
287 | 120 | self.assertEquals(instance.ramdisk_id, None) | ||
288 | 121 | |||
289 | 254 | def test_parse_reservation(self): | 122 | def test_parse_reservation(self): |
290 | 255 | creds = AWSCredentials("foo", "bar") | 123 | creds = AWSCredentials("foo", "bar") |
291 | 256 | ec2 = client.EC2Client(creds=creds) | 124 | ec2 = client.EC2Client(creds=creds) |
293 | 257 | results = ec2._parse_instances(sample_describe_instances_result) | 125 | results = ec2._parse_instances( |
294 | 126 | payload.sample_describe_instances_result) | ||
295 | 258 | self.check_parsed_instances(results) | 127 | self.check_parsed_instances(results) |
296 | 259 | 128 | ||
297 | 260 | def test_describe_instances(self): | 129 | def test_describe_instances(self): |
298 | @@ -264,13 +133,28 @@ | |||
299 | 264 | self.assertEqual(creds.access_key, "foo") | 133 | self.assertEqual(creds.access_key, "foo") |
300 | 265 | self.assertEqual(creds.secret_key, "bar") | 134 | self.assertEqual(creds.secret_key, "bar") |
301 | 266 | def submit(self): | 135 | def submit(self): |
303 | 267 | return succeed(sample_describe_instances_result) | 136 | return succeed(payload.sample_describe_instances_result) |
304 | 268 | creds = AWSCredentials("foo", "bar") | 137 | creds = AWSCredentials("foo", "bar") |
305 | 269 | ec2 = client.EC2Client(creds, query_factory=StubQuery) | 138 | ec2 = client.EC2Client(creds, query_factory=StubQuery) |
306 | 270 | d = ec2.describe_instances() | 139 | d = ec2.describe_instances() |
307 | 271 | d.addCallback(self.check_parsed_instances) | 140 | d.addCallback(self.check_parsed_instances) |
308 | 272 | return d | 141 | return d |
309 | 273 | 142 | ||
310 | 143 | def test_describe_instances_required(self): | ||
311 | 144 | class StubQuery(object): | ||
312 | 145 | def __init__(stub, action, creds, endpoint): | ||
313 | 146 | self.assertEqual(action, 'DescribeInstances') | ||
314 | 147 | self.assertEqual(creds.access_key, "foo") | ||
315 | 148 | self.assertEqual(creds.secret_key, "bar") | ||
316 | 149 | def submit(self): | ||
317 | 150 | return succeed( | ||
318 | 151 | payload.sample_required_describe_instances_result) | ||
319 | 152 | creds = AWSCredentials("foo", "bar") | ||
320 | 153 | ec2 = client.EC2Client(creds, query_factory=StubQuery) | ||
321 | 154 | d = ec2.describe_instances() | ||
322 | 155 | d.addCallback(self.check_parsed_instances_required) | ||
323 | 156 | return d | ||
324 | 157 | |||
325 | 274 | def test_terminate_instances(self): | 158 | def test_terminate_instances(self): |
326 | 275 | class StubQuery(object): | 159 | class StubQuery(object): |
327 | 276 | def __init__(stub, action, creds, endpoint, other_params): | 160 | def __init__(stub, action, creds, endpoint, other_params): |
328 | @@ -281,7 +165,7 @@ | |||
329 | 281 | {'InstanceId.1': 'i-1234', 'InstanceId.2': 'i-5678'}, | 165 | {'InstanceId.1': 'i-1234', 'InstanceId.2': 'i-5678'}, |
330 | 282 | other_params) | 166 | other_params) |
331 | 283 | def submit(self): | 167 | def submit(self): |
333 | 284 | return succeed(sample_terminate_instances_result) | 168 | return succeed(payload.sample_terminate_instances_result) |
334 | 285 | creds = AWSCredentials("foo", "bar") | 169 | creds = AWSCredentials("foo", "bar") |
335 | 286 | endpoint = AWSServiceEndpoint(uri=EC2_ENDPOINT_US) | 170 | endpoint = AWSServiceEndpoint(uri=EC2_ENDPOINT_US) |
336 | 287 | ec2 = client.EC2Client(creds=creds, endpoint=endpoint, | 171 | ec2 = client.EC2Client(creds=creds, endpoint=endpoint, |
337 | @@ -414,7 +298,7 @@ | |||
338 | 414 | self.assertEquals(params, {}) | 298 | self.assertEquals(params, {}) |
339 | 415 | 299 | ||
340 | 416 | def submit(self): | 300 | def submit(self): |
342 | 417 | return succeed(sample_describe_volumes_result) | 301 | return succeed(payload.sample_describe_volumes_result) |
343 | 418 | 302 | ||
344 | 419 | ec2 = client.EC2Client(creds="foo", query_factory=StubQuery) | 303 | ec2 = client.EC2Client(creds="foo", query_factory=StubQuery) |
345 | 420 | d = ec2.describe_volumes() | 304 | d = ec2.describe_volumes() |
346 | @@ -432,7 +316,7 @@ | |||
347 | 432 | {"VolumeId.1": "vol-4282672b"}) | 316 | {"VolumeId.1": "vol-4282672b"}) |
348 | 433 | 317 | ||
349 | 434 | def submit(self): | 318 | def submit(self): |
351 | 435 | return succeed(sample_describe_volumes_result) | 319 | return succeed(payload.sample_describe_volumes_result) |
352 | 436 | 320 | ||
353 | 437 | ec2 = client.EC2Client(creds="foo", query_factory=StubQuery) | 321 | ec2 = client.EC2Client(creds="foo", query_factory=StubQuery) |
354 | 438 | d = ec2.describe_volumes("vol-4282672b") | 322 | d = ec2.describe_volumes("vol-4282672b") |
355 | @@ -458,7 +342,7 @@ | |||
356 | 458 | self.assertEquals(params, {}) | 342 | self.assertEquals(params, {}) |
357 | 459 | 343 | ||
358 | 460 | def submit(self): | 344 | def submit(self): |
360 | 461 | return succeed(sample_describe_snapshots_result) | 345 | return succeed(payload.sample_describe_snapshots_result) |
361 | 462 | 346 | ||
362 | 463 | ec2 = client.EC2Client(creds="foo", query_factory=StubQuery) | 347 | ec2 = client.EC2Client(creds="foo", query_factory=StubQuery) |
363 | 464 | d = ec2.describe_snapshots() | 348 | d = ec2.describe_snapshots() |
364 | @@ -476,7 +360,7 @@ | |||
365 | 476 | {"SnapshotId.1": "snap-78a54011"}) | 360 | {"SnapshotId.1": "snap-78a54011"}) |
366 | 477 | 361 | ||
367 | 478 | def submit(self): | 362 | def submit(self): |
369 | 479 | return succeed(sample_describe_snapshots_result) | 363 | return succeed(payload.sample_describe_snapshots_result) |
370 | 480 | 364 | ||
371 | 481 | ec2 = client.EC2Client(creds="foo", query_factory=StubQuery) | 365 | ec2 = client.EC2Client(creds="foo", query_factory=StubQuery) |
372 | 482 | d = ec2.describe_snapshots("snap-78a54011") | 366 | d = ec2.describe_snapshots("snap-78a54011") |
373 | @@ -494,7 +378,7 @@ | |||
374 | 494 | params) | 378 | params) |
375 | 495 | 379 | ||
376 | 496 | def submit(self): | 380 | def submit(self): |
378 | 497 | return succeed(sample_create_volume_result) | 381 | return succeed(payload.sample_create_volume_result) |
379 | 498 | 382 | ||
380 | 499 | def check_parsed_volume(volume): | 383 | def check_parsed_volume(volume): |
381 | 500 | self.assertEquals(volume.id, "vol-4d826724") | 384 | self.assertEquals(volume.id, "vol-4d826724") |
382 | @@ -519,7 +403,7 @@ | |||
383 | 519 | params) | 403 | params) |
384 | 520 | 404 | ||
385 | 521 | def submit(self): | 405 | def submit(self): |
387 | 522 | return succeed(sample_create_volume_result) | 406 | return succeed(payload.sample_create_volume_result) |
388 | 523 | 407 | ||
389 | 524 | def check_parsed_volume(volume): | 408 | def check_parsed_volume(volume): |
390 | 525 | self.assertEquals(volume.id, "vol-4d826724") | 409 | self.assertEquals(volume.id, "vol-4d826724") |
391 | @@ -558,7 +442,7 @@ | |||
392 | 558 | params) | 442 | params) |
393 | 559 | 443 | ||
394 | 560 | def submit(self): | 444 | def submit(self): |
396 | 561 | return succeed(sample_delete_volume_result) | 445 | return succeed(payload.sample_delete_volume_result) |
397 | 562 | 446 | ||
398 | 563 | ec2 = client.EC2Client(creds="foo", query_factory=StubQuery) | 447 | ec2 = client.EC2Client(creds="foo", query_factory=StubQuery) |
399 | 564 | d = ec2.delete_volume("vol-4282672b") | 448 | d = ec2.delete_volume("vol-4282672b") |
400 | @@ -576,7 +460,7 @@ | |||
401 | 576 | params) | 460 | params) |
402 | 577 | 461 | ||
403 | 578 | def submit(self): | 462 | def submit(self): |
405 | 579 | return succeed(sample_create_snapshot_result) | 463 | return succeed(payload.sample_create_snapshot_result) |
406 | 580 | 464 | ||
407 | 581 | def check_parsed_snapshot(snapshot): | 465 | def check_parsed_snapshot(snapshot): |
408 | 582 | self.assertEquals(snapshot.id, "snap-78a54011") | 466 | self.assertEquals(snapshot.id, "snap-78a54011") |
409 | @@ -602,7 +486,7 @@ | |||
410 | 602 | params) | 486 | params) |
411 | 603 | 487 | ||
412 | 604 | def submit(self): | 488 | def submit(self): |
414 | 605 | return succeed(sample_delete_snapshot_result) | 489 | return succeed(payload.sample_delete_snapshot_result) |
415 | 606 | 490 | ||
416 | 607 | ec2 = client.EC2Client(creds="foo", query_factory=StubQuery) | 491 | ec2 = client.EC2Client(creds="foo", query_factory=StubQuery) |
417 | 608 | d = ec2.delete_snapshot("snap-78a54011") | 492 | d = ec2.delete_snapshot("snap-78a54011") |
418 | @@ -621,7 +505,7 @@ | |||
419 | 621 | params) | 505 | params) |
420 | 622 | 506 | ||
421 | 623 | def submit(self): | 507 | def submit(self): |
423 | 624 | return succeed(sample_attach_volume_result) | 508 | return succeed(payload.sample_attach_volume_result) |
424 | 625 | 509 | ||
425 | 626 | def check_parsed_response(response): | 510 | def check_parsed_response(response): |
426 | 627 | self.assertEquals( | 511 | self.assertEquals( |
427 | 628 | 512 | ||
428 | === added file 'txaws/testing/payload.py' | |||
429 | --- txaws/testing/payload.py 1970-01-01 00:00:00 +0000 | |||
430 | +++ txaws/testing/payload.py 2009-08-31 20:07:58 +0000 | |||
431 | @@ -0,0 +1,198 @@ | |||
432 | 1 | from txaws.version import aws_api | ||
433 | 2 | |||
434 | 3 | |||
435 | 4 | sample_required_describe_instances_result = """<?xml version="1.0"?> | ||
436 | 5 | <DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/""" + aws_api + """/"> | ||
437 | 6 | <requestId>52b4c730-f29f-498d-94c1-91efb75994cc</requestId> | ||
438 | 7 | <reservationSet> | ||
439 | 8 | <item> | ||
440 | 9 | <reservationId>r-cf24b1a6</reservationId> | ||
441 | 10 | <ownerId>123456789012</ownerId> | ||
442 | 11 | <groupSet> | ||
443 | 12 | <item> | ||
444 | 13 | <groupId>default</groupId> | ||
445 | 14 | </item> | ||
446 | 15 | </groupSet> | ||
447 | 16 | <instancesSet> | ||
448 | 17 | <item> | ||
449 | 18 | <instanceId>i-abcdef01</instanceId> | ||
450 | 19 | <imageId>ami-12345678</imageId> | ||
451 | 20 | <instanceState> | ||
452 | 21 | <code>16</code> | ||
453 | 22 | <name>running</name> | ||
454 | 23 | </instanceState> | ||
455 | 24 | <privateDnsName>domU-12-31-39-03-15-11.compute-1.internal</privateDnsName> | ||
456 | 25 | <dnsName>ec2-75-101-245-65.compute-1.amazonaws.com</dnsName> | ||
457 | 26 | <instanceType>c1.xlarge</instanceType> | ||
458 | 27 | <launchTime>2009-04-27T02:23:18.000Z</launchTime> | ||
459 | 28 | <placement> | ||
460 | 29 | <availabilityZone>us-east-1c</availabilityZone> | ||
461 | 30 | </placement> | ||
462 | 31 | </item> | ||
463 | 32 | </instancesSet> | ||
464 | 33 | </item> | ||
465 | 34 | </reservationSet> | ||
466 | 35 | </DescribeInstancesResponse> | ||
467 | 36 | """ | ||
468 | 37 | |||
469 | 38 | |||
470 | 39 | sample_describe_instances_result = """<?xml version="1.0"?> | ||
471 | 40 | <DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/""" + aws_api + """/"> | ||
472 | 41 | <requestId>52b4c730-f29f-498d-94c1-91efb75994cc</requestId> | ||
473 | 42 | <reservationSet> | ||
474 | 43 | <item> | ||
475 | 44 | <reservationId>r-cf24b1a6</reservationId> | ||
476 | 45 | <ownerId>123456789012</ownerId> | ||
477 | 46 | <groupSet> | ||
478 | 47 | <item> | ||
479 | 48 | <groupId>default</groupId> | ||
480 | 49 | </item> | ||
481 | 50 | </groupSet> | ||
482 | 51 | <instancesSet> | ||
483 | 52 | <item> | ||
484 | 53 | <instanceId>i-abcdef01</instanceId> | ||
485 | 54 | <imageId>ami-12345678</imageId> | ||
486 | 55 | <instanceState> | ||
487 | 56 | <code>16</code> | ||
488 | 57 | <name>running</name> | ||
489 | 58 | </instanceState> | ||
490 | 59 | <privateDnsName>domU-12-31-39-03-15-11.compute-1.internal</privateDnsName> | ||
491 | 60 | <dnsName>ec2-75-101-245-65.compute-1.amazonaws.com</dnsName> | ||
492 | 61 | <reason/> | ||
493 | 62 | <keyName>keyname</keyName> | ||
494 | 63 | <amiLaunchIndex>0</amiLaunchIndex> | ||
495 | 64 | <productCodes> | ||
496 | 65 | <productCode>774F4FF8</productCode> | ||
497 | 66 | </productCodes> | ||
498 | 67 | |||
499 | 68 | <instanceType>c1.xlarge</instanceType> | ||
500 | 69 | <launchTime>2009-04-27T02:23:18.000Z</launchTime> | ||
501 | 70 | <placement> | ||
502 | 71 | <availabilityZone>us-east-1c</availabilityZone> | ||
503 | 72 | </placement> | ||
504 | 73 | <kernelId>aki-b51cf9dc</kernelId> | ||
505 | 74 | <ramdiskId>ari-b31cf9da</ramdiskId> | ||
506 | 75 | </item> | ||
507 | 76 | </instancesSet> | ||
508 | 77 | </item> | ||
509 | 78 | </reservationSet> | ||
510 | 79 | </DescribeInstancesResponse> | ||
511 | 80 | """ | ||
512 | 81 | |||
513 | 82 | |||
514 | 83 | sample_terminate_instances_result = """<?xml version="1.0"?> | ||
515 | 84 | <TerminateInstancesResponse xmlns="http://ec2.amazonaws.com/doc/""" + aws_api + """/"> | ||
516 | 85 | <instancesSet> | ||
517 | 86 | <item> | ||
518 | 87 | <instanceId>i-1234</instanceId> | ||
519 | 88 | <shutdownState> | ||
520 | 89 | <code>32</code> | ||
521 | 90 | <name>shutting-down</name> | ||
522 | 91 | </shutdownState> | ||
523 | 92 | <previousState> | ||
524 | 93 | <code>16</code> | ||
525 | 94 | <name>running</name> | ||
526 | 95 | </previousState> | ||
527 | 96 | </item> | ||
528 | 97 | <item> | ||
529 | 98 | <instanceId>i-5678</instanceId> | ||
530 | 99 | <shutdownState> | ||
531 | 100 | <code>32</code> | ||
532 | 101 | <name>shutting-down</name> | ||
533 | 102 | </shutdownState> | ||
534 | 103 | <previousState> | ||
535 | 104 | <code>32</code> | ||
536 | 105 | <name>shutting-down</name> | ||
537 | 106 | </previousState> | ||
538 | 107 | </item> | ||
539 | 108 | </instancesSet> | ||
540 | 109 | </TerminateInstancesResponse> | ||
541 | 110 | """ | ||
542 | 111 | |||
543 | 112 | |||
544 | 113 | sample_describe_volumes_result = """<?xml version="1.0"?> | ||
545 | 114 | <DescribeVolumesResponse xmlns="http://ec2.amazonaws.com/doc/""" + aws_api + """/"> | ||
546 | 115 | <volumeSet> | ||
547 | 116 | <item> | ||
548 | 117 | <volumeId>vol-4282672b</volumeId> | ||
549 | 118 | <size>800</size> | ||
550 | 119 | <status>in-use</status> | ||
551 | 120 | <createTime>2008-05-07T11:51:50.000Z</createTime> | ||
552 | 121 | <attachmentSet> | ||
553 | 122 | <item> | ||
554 | 123 | <volumeId>vol-4282672b</volumeId> | ||
555 | 124 | <instanceId>i-6058a509</instanceId> | ||
556 | 125 | <size>800</size> | ||
557 | 126 | <snapshotId>snap-12345678</snapshotId> | ||
558 | 127 | <availabilityZone>us-east-1a</availabilityZone> | ||
559 | 128 | <status>attached</status> | ||
560 | 129 | <attachTime>2008-05-07T12:51:50.000Z</attachTime> | ||
561 | 130 | </item> | ||
562 | 131 | </attachmentSet> | ||
563 | 132 | </item> | ||
564 | 133 | </volumeSet> | ||
565 | 134 | </DescribeVolumesResponse> | ||
566 | 135 | """ | ||
567 | 136 | |||
568 | 137 | |||
569 | 138 | sample_describe_snapshots_result = """<?xml version="1.0"?> | ||
570 | 139 | <DescribeSnapshotsResponse xmlns="http://ec2.amazonaws.com/doc/""" + aws_api + """/"> | ||
571 | 140 | <snapshotSet> | ||
572 | 141 | <item> | ||
573 | 142 | <snapshotId>snap-78a54011</snapshotId> | ||
574 | 143 | <volumeId>vol-4d826724</volumeId> | ||
575 | 144 | <status>pending</status> | ||
576 | 145 | <startTime>2008-05-07T12:51:50.000Z</startTime> | ||
577 | 146 | <progress>80%</progress> | ||
578 | 147 | </item> | ||
579 | 148 | </snapshotSet> | ||
580 | 149 | </DescribeSnapshotsResponse> | ||
581 | 150 | """ | ||
582 | 151 | |||
583 | 152 | |||
584 | 153 | sample_create_volume_result = """<?xml version="1.0"?> | ||
585 | 154 | <CreateVolumeResponse xmlns="http://ec2.amazonaws.com/doc/""" + aws_api + """/"> | ||
586 | 155 | <volumeId>vol-4d826724</volumeId> | ||
587 | 156 | <size>800</size> | ||
588 | 157 | <status>creating</status> | ||
589 | 158 | <createTime>2008-05-07T11:51:50.000Z</createTime> | ||
590 | 159 | <availabilityZone>us-east-1a</availabilityZone> | ||
591 | 160 | <snapshotId></snapshotId> | ||
592 | 161 | </CreateVolumeResponse> | ||
593 | 162 | """ | ||
594 | 163 | |||
595 | 164 | |||
596 | 165 | sample_delete_volume_result = """<?xml version="1.0"?> | ||
597 | 166 | <DeleteVolumeResponse xmlns="http://ec2.amazonaws.com/doc/""" + aws_api + """/"> | ||
598 | 167 | <return>true</return> | ||
599 | 168 | </DeleteVolumeResponse> | ||
600 | 169 | """ | ||
601 | 170 | |||
602 | 171 | |||
603 | 172 | sample_create_snapshot_result = """<?xml version="1.0"?> | ||
604 | 173 | <CreateSnapshotResponse xmlns="http://ec2.amazonaws.com/doc/""" + aws_api + """/"> | ||
605 | 174 | <snapshotId>snap-78a54011</snapshotId> | ||
606 | 175 | <volumeId>vol-4d826724</volumeId> | ||
607 | 176 | <status>pending</status> | ||
608 | 177 | <startTime>2008-05-07T12:51:50.000Z</startTime> | ||
609 | 178 | <progress></progress> | ||
610 | 179 | </CreateSnapshotResponse> | ||
611 | 180 | """ | ||
612 | 181 | |||
613 | 182 | |||
614 | 183 | sample_delete_snapshot_result = """<?xml version="1.0"?> | ||
615 | 184 | <DeleteSnapshotResponse xmlns="http://ec2.amazonaws.com/doc/""" + aws_api + """/"> | ||
616 | 185 | <return>true</return> | ||
617 | 186 | </DeleteSnapshotResponse> | ||
618 | 187 | """ | ||
619 | 188 | |||
620 | 189 | |||
621 | 190 | sample_attach_volume_result = """<?xml version="1.0"?> | ||
622 | 191 | <AttachVolumeResponse xmlns="http://ec2.amazonaws.com/doc/""" + aws_api + """/"> | ||
623 | 192 | <volumeId>vol-4d826724</volumeId> | ||
624 | 193 | <instanceId>i-6058a509</instanceId> | ||
625 | 194 | <device>/dev/sdh</device> | ||
626 | 195 | <status>attaching</status> | ||
627 | 196 | <attachTime>2008-05-07T11:51:50.000Z</attachTime> | ||
628 | 197 | </AttachVolumeResponse> | ||
629 | 198 | """ | ||
630 | 0 | 199 | ||
631 | === added file 'txaws/version.py' | |||
632 | --- txaws/version.py 1970-01-01 00:00:00 +0000 | |||
633 | +++ txaws/version.py 2009-08-31 20:07:58 +0000 | |||
634 | @@ -0,0 +1,2 @@ | |||
635 | 1 | txaws = "0.0.1" | ||
636 | 2 | aws_api = "2008-12-01" |
Ready for review!