diff --git a/cloudinit/sources/DataSourceOracle.py b/cloudinit/sources/DataSourceOracle.py index 3b7c345d353..520655bc5bb 100644 --- a/cloudinit/sources/DataSourceOracle.py +++ b/cloudinit/sources/DataSourceOracle.py @@ -182,37 +182,40 @@ def ds_detect() -> bool: def _get_data(self): self.system_uuid = _read_system_uuid() - nic_name = net.find_fallback_nic() # Test against both v1 and v2 metadata URLs connectivity_urls_data = [ { "url": IPV4_METADATA_PATTERN.format( - version=1, path="instance" + version=2, path="instance" ), + "headers": V2_HEADERS, }, { "url": IPV4_METADATA_PATTERN.format( - version=2, path="instance" + version=1, path="instance" ), - "headers": V2_HEADERS, }, ] + ipv6_url_that_worked = check_ipv6_connectivity() + if ipv6_url_that_worked: + md_patterns = [IPV6_METADATA_PATTERN] + else: + md_patterns = [IPV4_METADATA_PATTERN] + # if we have connectivity to imds, then skip ephemeral network setup - if self.perform_dhcp_setup: # and not available_urls: - # TODO: ask james: this obviously fails on ipv6 single stack only - # is there a way to detect when we need this? - # would this only work/be needed if isci is being used? - # if so, could we just check for iscsi root and then do this? + if self.perform_dhcp_setup and not ipv6_url_that_worked: + + nic_name = net.find_fallback_nic() try: network_context = ephemeral.EphemeralIPNetwork( distro=self.distro, interface=nic_name, - ipv6=True, + ipv6=False, ipv4=True, connectivity_urls_data=connectivity_urls_data, - ipv6_connectivity_check_callback=check_ipv6_connectivity, + ipv6_connectivity_check_callback=None, ) except Exception: network_context = util.nullcontext() @@ -225,10 +228,6 @@ def _get_data(self): ) with network_context: - if network_context.ipv6_reached_at_url: - md_patterns = [IPV6_METADATA_PATTERN] - else: - md_patterns = [IPV4_METADATA_PATTERN] fetched_metadata, url_that_worked = read_opc_metadata( fetch_vnics_data=fetch_primary_nic or fetch_secondary_nics, max_wait=self.url_max_wait,