From 88c3ec3bf4a8d374bdfcbec44d2f7d726c705da3 Mon Sep 17 00:00:00 2001 From: "jinkangkang.jkk" Date: Tue, 15 Oct 2024 17:30:13 +0800 Subject: [PATCH] fix: Add check if the data source supports IPv6 when perform dhcp --- cloudinit/sources/DataSourceEc2.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cloudinit/sources/DataSourceEc2.py b/cloudinit/sources/DataSourceEc2.py index 10837df6a0e..b68f4a6994e 100644 --- a/cloudinit/sources/DataSourceEc2.py +++ b/cloudinit/sources/DataSourceEc2.py @@ -15,6 +15,7 @@ import uuid from contextlib import suppress from typing import Dict, List +from urllib.parse import urlparse from cloudinit import dmi, net, sources from cloudinit import url_helper as uhelp @@ -158,7 +159,7 @@ def _get_data(self): self.distro, self.distro.fallback_interface, ipv4=True, - ipv6=True, + ipv6=any([net.is_ipv6_address(urlparse(url).netloc.strip("[]")) for url in self.metadata_urls]), ) as netw: self._crawled_metadata = self.crawl_metadata() LOG.debug(