~ubuntu-branches/ubuntu/oneiric/txaws/oneiric-201109300905

« back to all changes in this revision

Viewing changes to debian/patches/fix-handling-nova-securitygroups.patch

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2011-09-15 13:13:16 UTC
  • Revision ID: package-import@ubuntu.com-20110915131316-3bdz2ip8x71tmbyr
Tags: 0.2-0ubuntu3
debian/patches/fix-handling-nova-securitygroups.patch,
debian/patches/fix-s3-alternate-port.patch: Fix txaws compatibility
with OpenStack Nova. (LP: #829609 , LP: #824403)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
4
Forwarded: yes
 
5
Origin: https://code.launchpad.net/~hazmat/txaws/fix-s3-port-and-bucket-op/+merge/73293
 
6
 
 
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
 
10
@@ -658,9 +658,20 @@
 
11
             if ip_permissions is None:
 
12
                 ip_permissions = ()
 
13
             for ip_permission in ip_permissions:
 
14
+
 
15
+                # openstack doesn't handle self authorized groups properly
 
16
+                # XXX this is an upstream problem and should be addressed there
 
17
+                # lp bug #829609
 
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")
 
23
+
 
24
+                if from_port:
 
25
+                    from_port = int(from_port)
 
26
+
 
27
+                if to_port:
 
28
+                    to_port = int(to_port)
 
29
+
 
30
                 for groups in ip_permission.findall("groups/item") or ():
 
31
                     user_id = groups.findtext("userId")
 
32
                     group_name = groups.findtext("groupName")
 
33
 
 
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
 
37
@@ -522,6 +522,38 @@
 
38
         d = ec2.describe_security_groups("WebServers")
 
39
         return d.addCallback(check_result)
 
40
 
 
41
+    def test_describe_security_groups_with_openstack(self):
 
42
+        """
 
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
 
47
+        #829609.
 
48
+        """
 
49
+        class StubQuery(object):
 
50
+
 
51
+            def __init__(stub, action="", creds=None, endpoint=None,
 
52
+                         other_params={}):
 
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"})
 
57
+
 
58
+            def submit(self):
 
59
+                return succeed(
 
60
+                    payload.sample_describe_security_groups_with_openstack)
 
61
+
 
62
+        def check_result(security_groups):
 
63
+            [security_group] = security_groups
 
64
+            self.assertEquals(security_group.name, "WebServers")
 
65
+            self.assertEqual(
 
66
+                security_group.allowed_groups[0].group_name, "WebServers")
 
67
+
 
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)
 
72
+
 
73
     def test_create_security_group(self):
 
74
         """
 
75
         L{EC2Client.create_security_group} returns a C{Deferred} that
 
76
 
 
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
 
80
@@ -54,6 +54,8 @@
 
81
             if not self.object_name.startswith("/"):
 
82
                 path += "/"
 
83
             path += self.object_name
 
84
+        elif self.bucket is not None and not path.endswith("/"):
 
85
+            path += "/"
 
86
         return path
 
87
 
 
88
     def get_url(self):
 
89
 
 
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
 
93
@@ -34,7 +34,7 @@
 
94
 
 
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/")
 
99
 
 
100
     def test_get_path_with_bucket_and_object(self):
 
101
         url_context = client.URLContext(
 
102
 
 
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
 
106
@@ -178,6 +178,43 @@
 
107
 """ % (version.ec2_api,)
 
108
 
 
109
 
 
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>
 
115
+    <item>
 
116
+      <ipPermissions>
 
117
+        <item>
 
118
+          <toPort>22</toPort>
 
119
+          <ipProtocol>tcp</ipProtocol>
 
120
+          <ipRanges>
 
121
+             <item><cidrIp>0.0.0.0/0</cidrIp></item>
 
122
+          </ipRanges>
 
123
+          <groups/>
 
124
+          <fromPort>22</fromPort>
 
125
+        </item>
 
126
+        <item>
 
127
+         <toPort/>
 
128
+         <ipProtocol/>
 
129
+         <ipRanges/>
 
130
+         <groups>
 
131
+            <item>
 
132
+              <groupName>WebServers</groupName>
 
133
+              <userId>UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM</userId>
 
134
+            </item>
 
135
+         </groups>
 
136
+         <fromPort/>
 
137
+        </item>
 
138
+      </ipPermissions>
 
139
+      <groupName>WebServers</groupName>
 
140
+      <groupDescription>Web servers</groupDescription>
 
141
+      <ownerId>UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM</ownerId>
 
142
+    </item>
 
143
+  </securityGroupInfo>
 
144
+</DescribeSecurityGroupsResponse>
 
145
+""" % (version.ec2_api,)
 
146
+
 
147
 sample_describe_security_groups_result = """\
 
148
 <?xml version="1.0"?>
 
149
 <DescribeSecurityGroupsResponse xmlns="http://ec2.amazonaws.com/doc/%s/">
 
150