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
=== modified file 'src/provisioningserver/rpc/clusterservice.py'
--- src/provisioningserver/rpc/clusterservice.py 2014-10-02 00:23:16 +0000
+++ src/provisioningserver/rpc/clusterservice.py 2014-10-03 10:47:21 +0000
@@ -455,7 +455,7 @@
455 if '[' in netloc:455 if '[' in netloc:
456 # IPv6 address. This is complicated.456 # IPv6 address. This is complicated.
457 parsed_netloc = re.match(457 parsed_netloc = re.match(
458 '(?P<host>\\[[0-9A-Fa-f:.]+\\])([:](?P<port>[0-9]+))?$',458 '\\[(?P<host>[0-9A-Fa-f:.]+)\\]([:](?P<port>[0-9]+))?$',
459 netloc)459 netloc)
460 host, port = parsed_netloc.group('host', 'port')460 host, port = parsed_netloc.group('host', 'port')
461 elif ':' in netloc:461 elif ':' in netloc:
462462
=== modified file 'src/provisioningserver/rpc/tests/test_clusterservice.py'
--- src/provisioningserver/rpc/tests/test_clusterservice.py 2014-10-02 00:24:18 +0000
+++ src/provisioningserver/rpc/tests/test_clusterservice.py 2014-10-03 10:47:21 +0000
@@ -380,7 +380,7 @@
380 ip = factory.make_ipv6_address().encode('ascii')380 ip = factory.make_ipv6_address().encode('ascii')
381 path = factory.make_name('path').encode('ascii')381 path = factory.make_name('path').encode('ascii')
382 uri = PatchedURI.fromBytes(b'http://[%s]/%s' % (ip, path))382 uri = PatchedURI.fromBytes(b'http://[%s]/%s' % (ip, path))
383 self.expectThat(uri.host, Equals(b'[%s]' % ip))383 self.expectThat(uri.host, Equals(b'%s' % ip))
384 self.expectThat(uri.path, Equals(b'/%s' % path))384 self.expectThat(uri.path, Equals(b'/%s' % path))
385 self.expectThat(uri.port, Equals(80))385 self.expectThat(uri.port, Equals(80))
386386
@@ -389,7 +389,7 @@
389 port = factory.pick_port()389 port = factory.pick_port()
390 path = factory.make_name('path').encode('ascii')390 path = factory.make_name('path').encode('ascii')
391 uri = PatchedURI.fromBytes(b'http://[%s]:%d/%s' % (ip, port, path))391 uri = PatchedURI.fromBytes(b'http://[%s]:%d/%s' % (ip, port, path))
392 self.expectThat(uri.host, Equals(b'[%s]' % ip))392 self.expectThat(uri.host, Equals(b'%s' % ip))
393 self.expectThat(uri.path, Equals(b'/%s' % path))393 self.expectThat(uri.path, Equals(b'/%s' % path))
394 self.expectThat(uri.port, Equals(port))394 self.expectThat(uri.port, Equals(port))
395395