141 lines
5.4 KiB
Diff
141 lines
5.4 KiB
Diff
From 6a81b1e0970f37246276009c844baca860f3f913 Mon Sep 17 00:00:00 2001
|
|
From: Darren Archibald <darren.archibald@oracle.com>
|
|
Date: Fri, 23 Feb 2024 08:04:44 -0800
|
|
Subject: [PATCH] DataSourceOracle network getdata updates
|
|
|
|
Orabug: 35950168
|
|
|
|
Signed-off-by: Darren Archibald <darren.archibald@oracle.com>
|
|
---
|
|
cloudinit/sources/DataSourceOracle.py | 78 +++++++++++++--------------
|
|
1 file changed, 39 insertions(+), 39 deletions(-)
|
|
|
|
diff -git a/cloudinit/sources/DataSourceOracle.py b/cloudinit/sources/DataSourceOracle.py
|
|
--- a/cloudinit/sources/DataSourceOracle.py 2024-04-03 15:54:08.713716247 -0700
|
|
+++ b/cloudinit/sources/DataSourceOracle.py 2024-04-03 15:53:35.426718593 -0700
|
|
@@ -20,6 +20,7 @@
|
|
import logging
|
|
from collections import namedtuple
|
|
from typing import Optional, Tuple
|
|
+from contextlib import suppress as noop
|
|
|
|
from cloudinit import atomic_helper, dmi, net, sources, util
|
|
from cloudinit.distros.networking import NetworkConfig
|
|
@@ -37,6 +38,7 @@
|
|
DRACUT_OLDTMP_PATH='/dev/.initramfs'
|
|
DRACUT_NET_IFACES='net.ifaces'
|
|
DRACUT_IBFT_PATTERN='net.*.has_ibft_config'
|
|
+ISCSI_IBFT_PATH='/sys/firmware/acpi/tables/iBFT'
|
|
|
|
BUILTIN_DS_CONFIG = {
|
|
# Don't use IMDS to configure secondary NICs by default
|
|
@@ -129,7 +131,7 @@
|
|
sources.NetworkConfigSource.INITRAMFS,
|
|
)
|
|
|
|
- _network_config: dict = {"config": [], "version": 1}
|
|
+ _network_config = sources.UNSET
|
|
|
|
def __init__(self, sys_cfg, *args, **kwargs):
|
|
super(DataSourceOracle, self).__init__(sys_cfg, *args, **kwargs)
|
|
@@ -155,14 +157,16 @@
|
|
|
|
self.system_uuid = _read_system_uuid()
|
|
|
|
- network_context = ephemeral.EphemeralDHCPv4(
|
|
- self.distro,
|
|
- iface=net.find_fallback_nic(),
|
|
- connectivity_url_data={
|
|
- "url": METADATA_PATTERN.format(version=2, path="instance"),
|
|
- "headers": V2_HEADERS,
|
|
- },
|
|
- )
|
|
+ network_context = noop()
|
|
+ if not self._is_iscsi_root():
|
|
+ network_context = ephemeral.EphemeralDHCPv4(
|
|
+ self.distro,
|
|
+ iface=net.find_fallback_nic(),
|
|
+ connectivity_url_data={
|
|
+ "url": METADATA_PATTERN.format(version=2, path="instance"),
|
|
+ "headers": V2_HEADERS,
|
|
+ },
|
|
+ )
|
|
fetch_primary_nic = not self._is_iscsi_root()
|
|
fetch_secondary_nics = self.ds_cfg.get(
|
|
"configure_secondary_nics",
|
|
@@ -222,7 +226,7 @@
|
|
|
|
def _is_iscsi_root(self) -> bool:
|
|
"""Return whether we are on a iscsi machine."""
|
|
- return self._network_config_source.is_applicable() or _is_dracut_netconfig()
|
|
+ return self._network_config_source.is_applicable() or bool(os.path.exists(ISCSI_IBFT_PATH))
|
|
|
|
def _get_iscsi_config(self) -> dict:
|
|
return self._network_config_source.render_config()
|
|
@@ -237,39 +241,36 @@
|
|
|
|
If none is present, then we fall back to fallback configuration.
|
|
"""
|
|
- if self._has_network_config():
|
|
- return self._network_config
|
|
-
|
|
set_primary = False
|
|
- # this is v1
|
|
- if self._is_iscsi_root():
|
|
- self._network_config = self._get_iscsi_config()
|
|
- if not self._has_network_config():
|
|
- LOG.warning(
|
|
- "Could not obtain network configuration from initramfs. "
|
|
- "Falling back to IMDS."
|
|
- )
|
|
- set_primary = True
|
|
|
|
- set_secondary = self.ds_cfg.get(
|
|
- "configure_secondary_nics",
|
|
- BUILTIN_DS_CONFIG["configure_secondary_nics"],
|
|
- )
|
|
- if set_primary or set_secondary:
|
|
- try:
|
|
- # Mutate self._network_config to include primary and/or
|
|
- # secondary VNICs
|
|
- self._add_network_config_from_opc_imds(set_primary)
|
|
- except Exception:
|
|
- util.logexc(
|
|
- LOG,
|
|
- "Failed to parse IMDS network configuration!",
|
|
+ if self._network_config == sources.UNSET:
|
|
+ # this is v1
|
|
+ self._network_config = cmdline.read_initramfs_config()
|
|
+
|
|
+ if not self._network_config:
|
|
+ self._network_config = self.distro.generate_fallback_config()
|
|
+ set_primary = True
|
|
+
|
|
+ set_secondary = self.ds_cfg.get(
|
|
+ "configure_secondary_nics",
|
|
+ BUILTIN_DS_CONFIG["configure_secondary_nics"],
|
|
)
|
|
|
|
- # we need to verify that the nic selected is not a netfail over
|
|
- # device and, if it is a netfail master, then we need to avoid
|
|
- # emitting any match by mac
|
|
- _ensure_netfailover_safe(self._network_config)
|
|
+ if set_primary or set_secondary:
|
|
+ try:
|
|
+ # Mutate self._network_config to include primary and/or
|
|
+ # secondary VNICs
|
|
+ self._add_network_config_from_opc_imds(set_primary)
|
|
+ except Exception:
|
|
+ util.logexc(
|
|
+ LOG,
|
|
+ "Failed to parse IMDS network configuration!",
|
|
+ )
|
|
+
|
|
+ # we need to verify that the nic selected is not a netfail over
|
|
+ # device and, if it is a netfail master, then we need to avoid
|
|
+ # emitting any match by mac
|
|
+ _ensure_netfailover_safe(self._network_config)
|
|
|
|
return self._network_config
|
|
|