From bd35300ba36bd63686715fa9661516a518781f6d Mon Sep 17 00:00:00 2001 From: Kurt Stieger Date: Mon, 4 Mar 2019 15:54:25 +0000 Subject: net: append type:dhcp[46] only if dhcp[46] is True in v2 netconfig When providing netplan configuration to cloud-init, the internal network state would enable DHCP if the 'dhcp' key was present in the source config. In netplan, dhcp[46] is a boolean and the value of the boolean should control whether DHCP is enabled rather than the presence of the key. This issue leaded to inconsistant sysconfig/network-scripts on fedora. 'BOOTPROTO' was always 'dhcp', even if the address config was static. After this change a dhcp subnet is added only if the 'dhcp' setting in source cfg dict is True. LP: #1818032 --- cloudinit/net/network_state.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cloudinit') diff --git a/cloudinit/net/network_state.py b/cloudinit/net/network_state.py index f76e508a..539b76d8 100644 --- a/cloudinit/net/network_state.py +++ b/cloudinit/net/network_state.py @@ -706,9 +706,9 @@ class NetworkStateInterpreter(object): """Common ipconfig extraction from v2 to v1 subnets array.""" subnets = [] - if 'dhcp4' in cfg: + if cfg.get('dhcp4'): subnets.append({'type': 'dhcp4'}) - if 'dhcp6' in cfg: + if cfg.get('dhcp6'): self.use_ipv6 = True subnets.append({'type': 'dhcp6'}) -- cgit v1.2.3