From 8256852de570a0c6b237c75abd134ddbafee5c1f Mon Sep 17 00:00:00 2001 From: Eduardo Otubo Date: Thu, 3 Dec 2020 12:31:50 +0100 Subject: [PATCH] Do not write NM_CONTROLLED=no in generated interface config files Conflicts 20.3: - Not appplying patch on cloudinit/net/sysconfig.py since it now has a mechanism to identify if cloud-init is running on RHEL, having the correct settings for NM_CONTROLLED. X-downstream-only: true Signed-off-by: Eduardo Otubo Signed-off-by: Ryan McCabe --- cloudinit/net/sysconfig.py | 2 +- .../unittests/test_distros/test_netconfig.py | 8 --- tests/unittests/test_net.py | 49 ------------------- 3 files changed, 1 insertion(+), 58 deletions(-) diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py index ef4543b..13c6ad7 100644 --- a/cloudinit/net/sysconfig.py +++ b/cloudinit/net/sysconfig.py @@ -290,7 +290,7 @@ class Renderer(renderer.Renderer): # details about this) iface_defaults = { - 'rhel': {'ONBOOT': True, 'USERCTL': False, 'NM_CONTROLLED': False, + 'rhel': {'ONBOOT': True, 'USERCTL': False, 'BOOTPROTO': 'none'}, 'suse': {'BOOTPROTO': 'static', 'STARTMODE': 'auto'}, } diff --git a/tests/unittests/test_distros/test_netconfig.py b/tests/unittests/test_distros/test_netconfig.py index d09e46a..3f01c99 100644 --- a/tests/unittests/test_distros/test_netconfig.py +++ b/tests/unittests/test_distros/test_netconfig.py @@ -503,7 +503,6 @@ class TestNetCfgDistroRedhat(TestNetCfgDistroBase): GATEWAY=192.168.1.254 IPADDR=192.168.1.5 NETMASK=255.255.255.0 - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -511,7 +510,6 @@ class TestNetCfgDistroRedhat(TestNetCfgDistroBase): self.ifcfg_path('eth1'): dedent("""\ BOOTPROTO=dhcp DEVICE=eth1 - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -536,7 +534,6 @@ class TestNetCfgDistroRedhat(TestNetCfgDistroBase): IPV6_AUTOCONF=no IPV6_DEFAULTGW=2607:f0d0:1002:0011::1 IPV6_FORCE_ACCEPT_RA=no - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -544,7 +541,6 @@ class TestNetCfgDistroRedhat(TestNetCfgDistroBase): self.ifcfg_path('eth1'): dedent("""\ BOOTPROTO=dhcp DEVICE=eth1 - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -578,7 +574,6 @@ class TestNetCfgDistroRedhat(TestNetCfgDistroBase): HWADDR=00:16:3e:60:7c:df IPADDR=192.10.1.2 NETMASK=255.255.255.0 - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -588,7 +583,6 @@ class TestNetCfgDistroRedhat(TestNetCfgDistroBase): DEVICE=infra0 IPADDR=10.0.1.2 NETMASK=255.255.0.0 - NM_CONTROLLED=no ONBOOT=yes PHYSDEV=eth0 USERCTL=no @@ -617,7 +611,6 @@ class TestNetCfgDistroRedhat(TestNetCfgDistroBase): DEVICE=eth0 IPADDR=192.10.1.2 NETMASK=255.255.255.0 - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -627,7 +620,6 @@ class TestNetCfgDistroRedhat(TestNetCfgDistroBase): DEVICE=eth0.1001 IPADDR=10.0.1.2 NETMASK=255.255.0.0 - NM_CONTROLLED=no ONBOOT=yes PHYSDEV=eth0 USERCTL=no diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py index 094450b..6294f4b 100644 --- a/tests/unittests/test_net.py +++ b/tests/unittests/test_net.py @@ -535,7 +535,6 @@ GATEWAY=172.19.3.254 HWADDR=fa:16:3e:ed:9a:59 IPADDR=172.19.1.34 NETMASK=255.255.252.0 -NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -633,7 +632,6 @@ IPADDR=172.19.1.34 IPADDR1=10.0.0.10 NETMASK=255.255.252.0 NETMASK1=255.255.255.0 -NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -756,7 +754,6 @@ IPV6_AUTOCONF=no IPV6_DEFAULTGW=2001:DB8::1 IPV6_FORCE_ACCEPT_RA=no NETMASK=255.255.252.0 -NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -910,7 +907,6 @@ NETWORK_CONFIGS = { BOOTPROTO=none DEVICE=eth1 HWADDR=cf:d6:af:48:e8:80 - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no"""), @@ -927,7 +923,6 @@ NETWORK_CONFIGS = { IPADDR=192.168.21.3 NETMASK=255.255.255.0 METRIC=10000 - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no"""), @@ -1075,7 +1070,6 @@ NETWORK_CONFIGS = { IPV6_AUTOCONF=no IPV6_FORCE_ACCEPT_RA=no NETMASK=255.255.255.0 - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -1144,7 +1138,6 @@ NETWORK_CONFIGS = { DHCPV6C=yes IPV6INIT=yes DEVICE=iface0 - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -1199,7 +1192,6 @@ NETWORK_CONFIGS = { IPV6INIT=yes IPV6_FORCE_ACCEPT_RA=yes DEVICE=iface0 - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -1261,7 +1253,6 @@ NETWORK_CONFIGS = { IPV6INIT=yes IPV6_FORCE_ACCEPT_RA=no DEVICE=iface0 - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -1313,7 +1304,6 @@ NETWORK_CONFIGS = { IPV6_AUTOCONF=yes IPV6INIT=yes DEVICE=iface0 - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -1340,7 +1330,6 @@ NETWORK_CONFIGS = { IPV6_AUTOCONF=no IPV6_FORCE_ACCEPT_RA=no DEVICE=iface0 - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -1387,7 +1376,6 @@ NETWORK_CONFIGS = { IPV6_AUTOCONF=yes IPV6INIT=yes DEVICE=iface0 - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -1435,7 +1423,6 @@ NETWORK_CONFIGS = { IPV6_AUTOCONF=no IPV6_FORCE_ACCEPT_RA=yes DEVICE=iface0 - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -1468,7 +1455,6 @@ NETWORK_CONFIGS = { 'ifcfg-iface0': textwrap.dedent("""\ BOOTPROTO=dhcp DEVICE=iface0 - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -1511,7 +1497,6 @@ NETWORK_CONFIGS = { BOOTPROTO=dhcp DEVICE=iface0 ETHTOOL_OPTS="wol g" - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -1800,7 +1785,6 @@ pre-down route del -net 10.0.0.0/8 gw 11.0.0.1 metric 3 || true DHCPV6C=yes IPV6INIT=yes MACADDR=aa:bb:cc:dd:ee:ff - NM_CONTROLLED=no ONBOOT=yes TYPE=Bond USERCTL=no"""), @@ -1808,7 +1792,6 @@ pre-down route del -net 10.0.0.0/8 gw 11.0.0.1 metric 3 || true BOOTPROTO=dhcp DEVICE=bond0.200 DHCLIENT_SET_DEFAULT_ROUTE=no - NM_CONTROLLED=no ONBOOT=yes PHYSDEV=bond0 USERCTL=no @@ -1826,7 +1809,6 @@ pre-down route del -net 10.0.0.0/8 gw 11.0.0.1 metric 3 || true IPV6_DEFAULTGW=2001:4800:78ff:1b::1 MACADDR=bb:bb:bb:bb:bb:aa NETMASK=255.255.255.0 - NM_CONTROLLED=no ONBOOT=yes PRIO=22 STP=no @@ -1836,7 +1818,6 @@ pre-down route del -net 10.0.0.0/8 gw 11.0.0.1 metric 3 || true BOOTPROTO=none DEVICE=eth0 HWADDR=c0:d6:9f:2c:e8:80 - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no"""), @@ -1853,7 +1834,6 @@ pre-down route del -net 10.0.0.0/8 gw 11.0.0.1 metric 3 || true MTU=1500 NETMASK=255.255.255.0 NETMASK1=255.255.255.0 - NM_CONTROLLED=no ONBOOT=yes PHYSDEV=eth0 USERCTL=no @@ -1863,7 +1843,6 @@ pre-down route del -net 10.0.0.0/8 gw 11.0.0.1 metric 3 || true DEVICE=eth1 HWADDR=aa:d6:9f:2c:e8:80 MASTER=bond0 - NM_CONTROLLED=no ONBOOT=yes SLAVE=yes TYPE=Ethernet @@ -1873,7 +1852,6 @@ pre-down route del -net 10.0.0.0/8 gw 11.0.0.1 metric 3 || true DEVICE=eth2 HWADDR=c0:bb:9f:2c:e8:80 MASTER=bond0 - NM_CONTROLLED=no ONBOOT=yes SLAVE=yes TYPE=Ethernet @@ -1883,7 +1861,6 @@ pre-down route del -net 10.0.0.0/8 gw 11.0.0.1 metric 3 || true BRIDGE=br0 DEVICE=eth3 HWADDR=66:bb:9f:2c:e8:80 - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no"""), @@ -1892,7 +1869,6 @@ pre-down route del -net 10.0.0.0/8 gw 11.0.0.1 metric 3 || true BRIDGE=br0 DEVICE=eth4 HWADDR=98:bb:9f:2c:e8:80 - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no"""), @@ -1901,7 +1877,6 @@ pre-down route del -net 10.0.0.0/8 gw 11.0.0.1 metric 3 || true DEVICE=eth5 DHCLIENT_SET_DEFAULT_ROUTE=no HWADDR=98:bb:9f:2c:e8:8a - NM_CONTROLLED=no ONBOOT=no TYPE=Ethernet USERCTL=no"""), @@ -1912,7 +1887,6 @@ pre-down route del -net 10.0.0.0/8 gw 11.0.0.1 metric 3 || true IPADDR=192.168.200.7 MTU=9000 NETMASK=255.255.255.0 - NM_CONTROLLED=no ONBOOT=yes TYPE=InfiniBand USERCTL=no"""), @@ -2357,7 +2331,6 @@ iface bond0 inet6 static MTU=9000 NETMASK=255.255.255.0 NETMASK1=255.255.255.0 - NM_CONTROLLED=no ONBOOT=yes TYPE=Bond USERCTL=no @@ -2367,7 +2340,6 @@ iface bond0 inet6 static DEVICE=bond0s0 HWADDR=aa:bb:cc:dd:e8:00 MASTER=bond0 - NM_CONTROLLED=no ONBOOT=yes SLAVE=yes TYPE=Ethernet @@ -2389,7 +2361,6 @@ iface bond0 inet6 static DEVICE=bond0s1 HWADDR=aa:bb:cc:dd:e8:01 MASTER=bond0 - NM_CONTROLLED=no ONBOOT=yes SLAVE=yes TYPE=Ethernet @@ -2446,7 +2417,6 @@ iface bond0 inet6 static BOOTPROTO=none DEVICE=en0 HWADDR=aa:bb:cc:dd:e8:00 - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no"""), @@ -2465,7 +2435,6 @@ iface bond0 inet6 static MTU=2222 NETMASK=255.255.255.0 NETMASK1=255.255.255.0 - NM_CONTROLLED=no ONBOOT=yes PHYSDEV=en0 USERCTL=no @@ -2530,7 +2499,6 @@ iface bond0 inet6 static DEVICE=br0 IPADDR=192.168.2.2 NETMASK=255.255.255.0 - NM_CONTROLLED=no ONBOOT=yes PRIO=22 STP=no @@ -2546,7 +2514,6 @@ iface bond0 inet6 static IPV6INIT=yes IPV6_AUTOCONF=no IPV6_FORCE_ACCEPT_RA=no - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -2560,7 +2527,6 @@ iface bond0 inet6 static IPV6INIT=yes IPV6_AUTOCONF=no IPV6_FORCE_ACCEPT_RA=no - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -2654,7 +2620,6 @@ iface bond0 inet6 static HWADDR=52:54:00:12:34:00 IPADDR=192.168.1.2 NETMASK=255.255.255.0 - NM_CONTROLLED=no ONBOOT=no TYPE=Ethernet USERCTL=no @@ -2664,7 +2629,6 @@ iface bond0 inet6 static DEVICE=eth1 HWADDR=52:54:00:12:34:aa MTU=1480 - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -2673,7 +2637,6 @@ iface bond0 inet6 static BOOTPROTO=none DEVICE=eth2 HWADDR=52:54:00:12:34:ff - NM_CONTROLLED=no ONBOOT=no TYPE=Ethernet USERCTL=no @@ -3094,7 +3057,6 @@ class TestRhelSysConfigRendering(CiTestCase): BOOTPROTO=dhcp DEVICE=eth1000 HWADDR=07-1c-c6-75-a4-be -NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -3215,7 +3177,6 @@ GATEWAY=10.0.2.2 HWADDR=52:54:00:12:34:00 IPADDR=10.0.2.15 NETMASK=255.255.255.0 -NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -3246,7 +3207,6 @@ HWADDR=fa:16:3e:25:b4:59 IPADDR=51.68.89.122 MTU=1500 NETMASK=255.255.240.0 -NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -3260,7 +3220,6 @@ DEVICE=eth1 DHCLIENT_SET_DEFAULT_ROUTE=no HWADDR=fa:16:3e:b1:ca:29 MTU=9000 -NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -3285,7 +3244,6 @@ USERCTL=no # BOOTPROTO=dhcp DEVICE=eth0 -NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -3560,7 +3518,6 @@ USERCTL=no IPV6_FORCE_ACCEPT_RA=no IPV6_DEFAULTGW=2001:db8::1 NETMASK=255.255.255.0 - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -3585,7 +3542,6 @@ USERCTL=no 'ifcfg-eno1': textwrap.dedent("""\ BOOTPROTO=none DEVICE=eno1 - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no @@ -3596,7 +3552,6 @@ USERCTL=no IPADDR=192.6.1.9 MTU=1495 NETMASK=255.255.255.0 - NM_CONTROLLED=no ONBOOT=yes PHYSDEV=eno1 USERCTL=no @@ -3626,7 +3581,6 @@ USERCTL=no IPADDR=10.101.8.65 MTU=1334 NETMASK=255.255.255.192 - NM_CONTROLLED=no ONBOOT=yes TYPE=Bond USERCTL=no @@ -3636,7 +3590,6 @@ USERCTL=no BOOTPROTO=none DEVICE=enp0s0 MASTER=bond0 - NM_CONTROLLED=no ONBOOT=yes SLAVE=yes TYPE=Bond @@ -3647,7 +3600,6 @@ USERCTL=no BOOTPROTO=none DEVICE=enp0s1 MASTER=bond0 - NM_CONTROLLED=no ONBOOT=yes SLAVE=yes TYPE=Bond @@ -3671,7 +3623,6 @@ USERCTL=no DEVICE=eno1 HWADDR=07-1c-c6-75-a4-be METRIC=100 - NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet USERCTL=no -- 1.8.3.1