From 97e8245f58a9caa551811fe0f4c836763315effe Mon Sep 17 00:00:00 2001 From: Mathew Meins Date: Mon, 21 Oct 2024 13:23:05 +1100 Subject: [PATCH 1/2] fix(smartos): Add `addrconf` IPv6 support SmartOS uses `addrconf` as a special value to indicate that an IPv6 address should be obtained via DHCPv6 or SLAAC. cloud-init does not know how to handle this. Added logic to DataSourceSmartOS.py to properly recognise and handle this value. --- cloudinit/sources/DataSourceSmartOS.py | 2 ++ tests/unittests/sources/test_smartos.py | 47 +++++++++++++++++++++++++ tools/.github-cla-signers | 1 + 3 files changed, 50 insertions(+) diff --git a/cloudinit/sources/DataSourceSmartOS.py b/cloudinit/sources/DataSourceSmartOS.py index 38026c69a47..fe9da48d31b 100644 --- a/cloudinit/sources/DataSourceSmartOS.py +++ b/cloudinit/sources/DataSourceSmartOS.py @@ -927,6 +927,8 @@ def is_valid_ipv6(addr): for ip in nic.get("ips", []): if ip == "dhcp": subnet = {"type": "dhcp4"} + elif ip == "addrconf": + subnet = {"type": "dhcp6"} else: routeents = [] subnet = dict( diff --git a/tests/unittests/sources/test_smartos.py b/tests/unittests/sources/test_smartos.py index b4d7dbb1945..4d413e73a95 100644 --- a/tests/unittests/sources/test_smartos.py +++ b/tests/unittests/sources/test_smartos.py @@ -327,6 +327,30 @@ """ ) +SDC_NICS_ADDRCONF = json.loads( + """ +[ + { + "gateway": "10.64.1.129", + "gateways": [ + "10.64.1.129" + ], + "interface": "net0", + "ip": "10.64.1.130", + "ips": [ + "10.64.1.130/26", + "addrconf" + ], + "mac": "e2:7f:c1:50:eb:99", + "model": "virtio", + "netmask": "255.255.255.192", + "nic_tag": "external", + "primary": true, + "vlan_id": 20 + } +] +""" +) MOCK_RETURNS = { "hostname": "test-host", @@ -1344,6 +1368,29 @@ def test_routes_on_all_nics(self): self.maxDiff = None self.assertEqual(expected, found) + def test_ipv6_addrconf(self): + expected = { + "config": [ + { + "mac_address": "e2:7f:c1:50:eb:99", + "name": "net0", + "subnets": [ + { + "address": "10.64.1.130/26", + "gateway": "10.64.1.129", + "type": "static", + }, + {"type": "dhcp6"}, + ], + "type": "physical", + } + ], + "version": 1, + } + found = convert_net(SDC_NICS_ADDRCONF) + self.maxDiff = None + self.assertEqual(expected, found) + @unittest.skipUnless( get_smartos_environ() == SMARTOS_ENV_KVM, diff --git a/tools/.github-cla-signers b/tools/.github-cla-signers index f2b19e6f979..49790ea2fbd 100644 --- a/tools/.github-cla-signers +++ b/tools/.github-cla-signers @@ -27,6 +27,7 @@ berolinux bin456789 bipinbachhao BirknerAlex +blackhelicoptersdotnet bmhughes brianphaley BrinKe-dev From aefbe150680ef788ad8ffcebbcd688fe4f0c1632 Mon Sep 17 00:00:00 2001 From: Mathew Meins <4733697+blackhelicoptersdotnet@users.noreply.github.com> Date: Mon, 21 Oct 2024 22:08:41 +0000 Subject: [PATCH 2/2] fixes for CI tabs->spaces --- tests/unittests/sources/test_smartos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unittests/sources/test_smartos.py b/tests/unittests/sources/test_smartos.py index 4d413e73a95..fbb7ee625a6 100644 --- a/tests/unittests/sources/test_smartos.py +++ b/tests/unittests/sources/test_smartos.py @@ -1384,7 +1384,7 @@ def test_ipv6_addrconf(self): ], "type": "physical", } - ], + ], "version": 1, } found = convert_net(SDC_NICS_ADDRCONF)