Merge ~lloydwaltersj/maas:ipv6-address-fail into maas:master

Proposed by Jack Lloyd-Walters
Status: Merged
Approved by: Jack Lloyd-Walters
Approved revision: b009bff52f997ec1aad74a90911972241099ab08
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~lloydwaltersj/maas:ipv6-address-fail
Merge into: maas:master
Diff against target: 35 lines (+8/-0)
2 files modified
src/maasserver/tests/test_vmhost.py (+2/-0)
src/maasserver/vmhost.py (+6/-0)
Reviewer Review Type Date Requested Status
MAAS Lander Approve
Anton Troyanov Approve
Review via email: mp+426005@code.launchpad.net

Commit message

Include extra sanitation for bracketless ipv6 in vmhost address

To post a comment you must log in.
Revision history for this message
Anton Troyanov (troyanov) :
review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b ipv6-address-fail lp:~lloydwaltersj/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: FAILED
LOG: http://maas-ci.internal:8080/job/maas/job/branch-tester/13110/console
COMMIT: b009bff52f997ec1aad74a90911972241099ab08

review: Needs Fixing
Revision history for this message
Anton Troyanov (troyanov) wrote :

jenkins: !test

Revision history for this message
MAAS Lander (maas-lander) wrote :

UNIT TESTS
-b ipv6-address-fail lp:~lloydwaltersj/maas/+git/maas into -b master lp:~maas-committers/maas

STATUS: SUCCESS
COMMIT: b009bff52f997ec1aad74a90911972241099ab08

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/maasserver/tests/test_vmhost.py b/src/maasserver/tests/test_vmhost.py
2index 408418d..cf9ea62 100644
3--- a/src/maasserver/tests/test_vmhost.py
4+++ b/src/maasserver/tests/test_vmhost.py
5@@ -282,11 +282,13 @@ class TestCleanPowerAddress(MAASServerTestCase):
6 cases = [
7 ("10.0.0.1", "10.0.0.1:8443"),
8 ("10.0.0.1:8443", "10.0.0.1:8443"),
9+ ("2001:db8::1", "[2001:db8::1]:8443"),
10 ("[2001:db8::1]", "[2001:db8::1]:8443"),
11 ("lxd-1", "lxd-1:8443"),
12 ("lxd.cluster.com", "lxd.cluster.com:8443"),
13 ("https://lxd-1", "lxd-1:8443"),
14 ("https://lxd-1:8080", "lxd-1:8080"),
15+ ("https://[2001:db8::1]", "[2001:db8::1]:8443"),
16 ("https://[2001:db8::1]:8080", "[2001:db8::1]:8080"),
17 ("qemu+ssh://10.0.0.1/system", "qemu+ssh://10.0.0.1/system"),
18 (
19diff --git a/src/maasserver/vmhost.py b/src/maasserver/vmhost.py
20index 882e533..3c50f57 100644
21--- a/src/maasserver/vmhost.py
22+++ b/src/maasserver/vmhost.py
23@@ -141,6 +141,12 @@ def _clean_power_address(vmhost_address):
24
25 # urlparse() doesn't work if scheme is missing
26 if "://" not in vmhost_address:
27+ if (
28+ vmhost_address.count(":") > 1
29+ and "[" not in vmhost_address
30+ and "]" not in vmhost_address
31+ ):
32+ vmhost_address = f"[{vmhost_address}]"
33 vmhost_address = f"{lxd_schemes[0]}://{vmhost_address}"
34
35 vmhost_url = urlparse(vmhost_address)

Subscribers

People subscribed via source and target branches