From 0451e0e0cbeed9cdf8c23e3aadd59987764c010e Mon Sep 17 00:00:00 2001 From: aad1tyaaaaa Date: Fri, 27 Nov 2026 20:14:31 +0530 Subject: [PATCH 1/2] [CloudSigma] Report IPv6 addresses of NICs instead of a second copy of the IPv4 address --- CHANGES.rst | 5 +++++ libcloud/compute/drivers/cloudsigma.py | 14 +++++++++++--- libcloud/test/compute/test_cloudsigma_v2_0.py | 19 +++++++++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 048d163435..0ba044fe4b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -53,6 +53,11 @@ Common Compute ~~~~~~~ +- [CloudSigma] Report the IPv6 address of a NIC instead of its IPv4 address + a second time, and stop raising ``TypeError`` for a NIC with only an IPv6 + address. IPv6 unique local addresses are reported as private. + [@aad1tyaaaaa] + - [OVH] Remove the static location mapping and use the location code returned by the API as both the location ID and name, avoiding failures for codes not known to Libcloud. diff --git a/libcloud/compute/drivers/cloudsigma.py b/libcloud/compute/drivers/cloudsigma.py index 0bb2b48371..f94a2da7cb 100644 --- a/libcloud/compute/drivers/cloudsigma.py +++ b/libcloud/compute/drivers/cloudsigma.py @@ -22,6 +22,7 @@ import time import base64 import hashlib +import ipaddress from libcloud.utils.py3 import b, httplib from libcloud.utils.misc import dict2str, str2list, str2dicts, get_secure_random_string @@ -2269,7 +2270,7 @@ def _parse_ips_from_nic(self, nic): ip_v6 = ipv6_conf["ip"] if ipv6_conf else None ipv4 = ip_v4["uuid"] if ip_v4 else None - ipv6 = ip_v4["uuid"] if ip_v6 else None + ipv6 = ip_v6["uuid"] if ip_v6 else None ips = [] @@ -2285,7 +2286,7 @@ def _parse_ips_from_nic(self, nic): ip_v6 = runtime["ip_v6"] if nic["runtime"] else None ipv4 = ip_v4["uuid"] if ip_v4 else None - ipv6 = ip_v4["uuid"] if ip_v6 else None + ipv6 = ip_v6["uuid"] if ip_v6 else None if ipv4: ips.append(ipv4) @@ -2296,7 +2297,14 @@ def _parse_ips_from_nic(self, nic): ips = set(ips) for ip in ips: - if is_private_subnet(ip): + if ":" in ip: + # is_private_subnet only handles IPv4; unique local addresses + # (RFC 4193) are the IPv6 counterpart of the private ranges + is_private = ipaddress.ip_address(ip) in ipaddress.ip_network("fc00::/7") + else: + is_private = is_private_subnet(ip) + + if is_private: private_ips.append(ip) else: public_ips.append(ip) diff --git a/libcloud/test/compute/test_cloudsigma_v2_0.py b/libcloud/test/compute/test_cloudsigma_v2_0.py index a7eb489b07..dbf36f168c 100644 --- a/libcloud/test/compute/test_cloudsigma_v2_0.py +++ b/libcloud/test/compute/test_cloudsigma_v2_0.py @@ -514,6 +514,25 @@ def test_delete_key_pair(self): response = self.driver.delete_key_pair(key) self.assertTrue(response) + def test_parse_ips_from_nic_ipv6(self): + def nic(ipv4, ipv6): + return { + "ip_v4_conf": {"conf": "static", "ip": {"uuid": ipv4}} if ipv4 else None, + "ip_v6_conf": {"conf": "static", "ip": {"uuid": ipv6}} if ipv6 else None, + "runtime": None, + } + + public_ips, private_ips = self.driver._parse_ips_from_nic( + nic("185.12.5.10", "2a00:c31:1:2::10") + ) + self.assertEqual(sorted(public_ips), ["185.12.5.10", "2a00:c31:1:2::10"]) + self.assertEqual(private_ips, []) + + # An IPv6-only NIC + public_ips, private_ips = self.driver._parse_ips_from_nic(nic(None, "fd00::10")) + self.assertEqual(public_ips, []) + self.assertEqual(private_ips, ["fd00::10"]) + class CloudSigmaAPI20DirectTestCase(CloudSigmaAPI20BaseTestCase, unittest.TestCase): driver_klass = CloudSigma_2_0_NodeDriver From 1c32d3fb2ac7bf0f1bc5e46314ad8784087c2d32 Mon Sep 17 00:00:00 2001 From: aad1tyaaaaa Date: Fri, 27 Nov 2026 20:14:48 +0530 Subject: [PATCH 2/2] Add the PR number to the changelog entry --- CHANGES.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.rst b/CHANGES.rst index 0ba044fe4b..28c7025ce1 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -56,6 +56,7 @@ Compute - [CloudSigma] Report the IPv6 address of a NIC instead of its IPv4 address a second time, and stop raising ``TypeError`` for a NIC with only an IPv6 address. IPv6 unique local addresses are reported as private. + (#2244) [@aad1tyaaaaa] - [OVH] Remove the static location mapping and use the location code returned