Merge lp:~jtv/maas/bug-1372944 into lp:~maas-committers/maas/trunk

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Jeroen T. Vermeulen
Approved revision: no longer in the source branch.
Merged at revision: 3192
Proposed branch: lp:~jtv/maas/bug-1372944
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 33 lines (+3/-3)
2 files modified
src/provisioningserver/rpc/clusterservice.py (+1/-1)
src/provisioningserver/rpc/tests/test_clusterservice.py (+2/-2)
To merge this branch: bzr merge lp:~jtv/maas/bug-1372944
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+237038@code.launchpad.net

Commit message

Make our monkey patch to support IPv6 URLs in the Twisted web client strip the brackets from an IPv6 host address. It won't have all the information to reconstruct its original URL, but the class seems to be used only for its host and port. They need to be something that the connectTCP/connectSSL can connect to.

Description of the change

In other words, the parser used to return the host portion of the URL, but what it should return is the hostname as found in the URL. There is no difference with hostnames or IPv4 addresses, but IPv6 addresses have brackets around them in URLs.

Jeroen

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/provisioningserver/rpc/clusterservice.py'
2--- src/provisioningserver/rpc/clusterservice.py 2014-10-02 00:23:16 +0000
3+++ src/provisioningserver/rpc/clusterservice.py 2014-10-03 10:47:21 +0000
4@@ -455,7 +455,7 @@
5 if '[' in netloc:
6 # IPv6 address. This is complicated.
7 parsed_netloc = re.match(
8- '(?P<host>\\[[0-9A-Fa-f:.]+\\])([:](?P<port>[0-9]+))?$',
9+ '\\[(?P<host>[0-9A-Fa-f:.]+)\\]([:](?P<port>[0-9]+))?$',
10 netloc)
11 host, port = parsed_netloc.group('host', 'port')
12 elif ':' in netloc:
13
14=== modified file 'src/provisioningserver/rpc/tests/test_clusterservice.py'
15--- src/provisioningserver/rpc/tests/test_clusterservice.py 2014-10-02 00:24:18 +0000
16+++ src/provisioningserver/rpc/tests/test_clusterservice.py 2014-10-03 10:47:21 +0000
17@@ -380,7 +380,7 @@
18 ip = factory.make_ipv6_address().encode('ascii')
19 path = factory.make_name('path').encode('ascii')
20 uri = PatchedURI.fromBytes(b'http://[%s]/%s' % (ip, path))
21- self.expectThat(uri.host, Equals(b'[%s]' % ip))
22+ self.expectThat(uri.host, Equals(b'%s' % ip))
23 self.expectThat(uri.path, Equals(b'/%s' % path))
24 self.expectThat(uri.port, Equals(80))
25
26@@ -389,7 +389,7 @@
27 port = factory.pick_port()
28 path = factory.make_name('path').encode('ascii')
29 uri = PatchedURI.fromBytes(b'http://[%s]:%d/%s' % (ip, port, path))
30- self.expectThat(uri.host, Equals(b'[%s]' % ip))
31+ self.expectThat(uri.host, Equals(b'%s' % ip))
32 self.expectThat(uri.path, Equals(b'/%s' % path))
33 self.expectThat(uri.port, Equals(port))
34