summaryrefslogtreecommitdiff
path: root/cloudinit/net/network_state.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/net/network_state.py')
-rw-r--r--cloudinit/net/network_state.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/cloudinit/net/network_state.py b/cloudinit/net/network_state.py
index dd2ff489..f88b1321 100644
--- a/cloudinit/net/network_state.py
+++ b/cloudinit/net/network_state.py
@@ -83,6 +83,16 @@ NET_CONFIG_TO_V2: Dict[str, Dict[str, Any]] = {
}
+def warn_deprecated_all_devices(dikt: dict) -> None:
+ """Warn about deprecations of v2 properties for all devices"""
+ if "gateway4" in dikt or "gateway6" in dikt:
+ LOG.warning(
+ "DEPRECATED: The use of `gateway4` and `gateway6` is"
+ " deprecated. For more info check out: "
+ "https://cloudinit.readthedocs.io/en/latest/topics/network-config-format-v2.html" # noqa: E501
+ )
+
+
def from_state_file(state_file):
state = util.read_conf(state_file)
nsi = NetworkStateInterpreter()
@@ -241,7 +251,7 @@ class NetworkStateInterpreter(metaclass=CommandHandlerMeta):
self,
version=NETWORK_STATE_VERSION,
config=None,
- renderer=None, # type: Optional[Renderer]
+ renderer: "Optional[Renderer]" = None,
):
self._version = version
self._config = config
@@ -750,6 +760,8 @@ class NetworkStateInterpreter(metaclass=CommandHandlerMeta):
if key in cfg:
phy_cmd[key] = cfg[key]
+ warn_deprecated_all_devices(cfg)
+
subnets = self._v2_to_v1_ipcfg(cfg)
if len(subnets) > 0:
phy_cmd.update({"subnets": subnets})
@@ -784,6 +796,7 @@ class NetworkStateInterpreter(metaclass=CommandHandlerMeta):
}
if "mtu" in cfg:
vlan_cmd["mtu"] = cfg["mtu"]
+ warn_deprecated_all_devices(cfg)
subnets = self._v2_to_v1_ipcfg(cfg)
if len(subnets) > 0:
vlan_cmd.update({"subnets": subnets})
@@ -852,6 +865,8 @@ class NetworkStateInterpreter(metaclass=CommandHandlerMeta):
}
if "mtu" in item_cfg:
v1_cmd["mtu"] = item_cfg["mtu"]
+
+ warn_deprecated_all_devices(item_cfg)
subnets = self._v2_to_v1_ipcfg(item_cfg)
if len(subnets) > 0:
v1_cmd.update({"subnets": subnets})
@@ -974,7 +989,7 @@ def _normalize_net_keys(network, address_keys=()):
@returns: A dict containing normalized prefix and matching addr_key.
"""
- net = dict((k, v) for k, v in network.items() if v)
+ net = {k: v for k, v in network.items() if v or v == 0}
addr_key = None
for key in address_keys:
if net.get(key):