1
From: Kapil Thangavelu <kapil.thangavelu@canonical.com>
2
Description: Fixes incompatibilities in txaws when asking for group perms from OpenStack nova
3
Bug: http://pad.lv/829609
5
Origin: https://code.launchpad.net/~hazmat/txaws/fix-s3-port-and-bucket-op/+merge/73293
7
=== modified file 'txaws/ec2/client.py'
8
--- a/txaws/ec2/client.py 2011-05-12 14:48:26 +0000
9
+++ b/txaws/ec2/client.py 2011-08-29 20:27:23 +0000
11
if ip_permissions is None:
13
for ip_permission in ip_permissions:
15
+ # openstack doesn't handle self authorized groups properly
16
+ # XXX this is an upstream problem and should be addressed there
18
ip_protocol = ip_permission.findtext("ipProtocol")
19
- from_port = int(ip_permission.findtext("fromPort"))
20
- to_port = int(ip_permission.findtext("toPort"))
21
+ from_port = ip_permission.findtext("fromPort")
22
+ to_port = ip_permission.findtext("toPort")
25
+ from_port = int(from_port)
28
+ to_port = int(to_port)
30
for groups in ip_permission.findall("groups/item") or ():
31
user_id = groups.findtext("userId")
32
group_name = groups.findtext("groupName")
34
=== modified file 'txaws/ec2/tests/test_client.py'
35
--- a/txaws/ec2/tests/test_client.py 2011-05-12 14:38:37 +0000
36
+++ b/txaws/ec2/tests/test_client.py 2011-08-29 20:27:23 +0000
38
d = ec2.describe_security_groups("WebServers")
39
return d.addCallback(check_result)
41
+ def test_describe_security_groups_with_openstack(self):
43
+ L{EC2Client.describe_security_groups} can work with openstack
44
+ responses, which may lack proper port information for
45
+ self-referencing group. Verifying that the response doesn't
46
+ cause an internal error, workaround for nova launchpad bug
49
+ class StubQuery(object):
51
+ def __init__(stub, action="", creds=None, endpoint=None,
53
+ self.assertEqual(action, "DescribeSecurityGroups")
54
+ self.assertEqual(creds.access_key, "foo")
55
+ self.assertEqual(creds.secret_key, "bar")
56
+ self.assertEqual(other_params, {"GroupName.1": "WebServers"})
60
+ payload.sample_describe_security_groups_with_openstack)
62
+ def check_result(security_groups):
63
+ [security_group] = security_groups
64
+ self.assertEquals(security_group.name, "WebServers")
66
+ security_group.allowed_groups[0].group_name, "WebServers")
68
+ creds = AWSCredentials("foo", "bar")
69
+ ec2 = client.EC2Client(creds, query_factory=StubQuery)
70
+ d = ec2.describe_security_groups("WebServers")
71
+ return d.addCallback(check_result)
73
def test_create_security_group(self):
75
L{EC2Client.create_security_group} returns a C{Deferred} that
77
=== modified file 'txaws/s3/client.py'
78
--- a/txaws/s3/client.py 2011-08-29 20:27:23 +0000
79
+++ b/txaws/s3/client.py 2011-08-29 20:27:23 +0000
81
if not self.object_name.startswith("/"):
83
path += self.object_name
84
+ elif self.bucket is not None and not path.endswith("/"):
90
=== modified file 'txaws/s3/tests/test_client.py'
91
--- a/txaws/s3/tests/test_client.py 2011-08-29 20:27:23 +0000
92
+++ b/txaws/s3/tests/test_client.py 2011-08-29 20:27:23 +0000
95
def test_get_path_with_bucket(self):
96
url_context = client.URLContext(self.endpoint, bucket="mystuff")
97
- self.assertEquals(url_context.get_path(), "/mystuff")
98
+ self.assertEquals(url_context.get_path(), "/mystuff/")
100
def test_get_path_with_bucket_and_object(self):
101
url_context = client.URLContext(
103
=== modified file 'txaws/testing/payload.py'
104
--- a/txaws/testing/payload.py 2011-03-26 12:40:36 +0000
105
+++ b/txaws/testing/payload.py 2011-08-29 20:27:23 +0000
107
""" % (version.ec2_api,)
110
+sample_describe_security_groups_with_openstack = """\
111
+<?xml version="1.0"?>
112
+<DescribeSecurityGroupsResponse xmlns="http://ec2.amazonaws.com/doc/%s/">
113
+ <requestId>7d4e4dbd-0a33-4d3a-864a-b5ce0f1c9cbf</requestId>
114
+ <securityGroupInfo>
118
+ <toPort>22</toPort>
119
+ <ipProtocol>tcp</ipProtocol>
121
+ <item><cidrIp>0.0.0.0/0</cidrIp></item>
124
+ <fromPort>22</fromPort>
132
+ <groupName>WebServers</groupName>
133
+ <userId>UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM</userId>
139
+ <groupName>WebServers</groupName>
140
+ <groupDescription>Web servers</groupDescription>
141
+ <ownerId>UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM</ownerId>
143
+ </securityGroupInfo>
144
+</DescribeSecurityGroupsResponse>
145
+""" % (version.ec2_api,)
147
sample_describe_security_groups_result = """\
148
<?xml version="1.0"?>
149
<DescribeSecurityGroupsResponse xmlns="http://ec2.amazonaws.com/doc/%s/">