From 98657d64a1d40769b31fcf375ebb1ea0b373350c Mon Sep 17 00:00:00 2001
From: Eduardo Otubo <otubo@redhat.com>
Date: Fri, 21 Feb 2020 11:10:09 +0100
Subject: [PATCH] Do not write NM_CONTROLLED=no in generated interface config 
 files

Signed-off-by: Eduardo Otubo <otubo@redhat.com>
---
 cloudinit/net/sysconfig.py                    |  1 -
 .../unittests/test_distros/test_netconfig.py  |  8 ---
 tests/unittests/test_net.py                   | 55 -------------------
 3 files changed, 64 deletions(-)

diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
index 310cdf01..8bd7e887 100644
--- a/cloudinit/net/sysconfig.py
+++ b/cloudinit/net/sysconfig.py
@@ -272,7 +272,6 @@ class Renderer(renderer.Renderer):
     iface_defaults = tuple([
         ('ONBOOT', True),
         ('USERCTL', False),
-        ('NM_CONTROLLED', False),
         ('BOOTPROTO', 'none'),
         ('STARTMODE', 'auto'),
     ])
diff --git a/tests/unittests/test_distros/test_netconfig.py b/tests/unittests/test_distros/test_netconfig.py
index 67209955..1df3bfb5 100644
--- a/tests/unittests/test_distros/test_netconfig.py
+++ b/tests/unittests/test_distros/test_netconfig.py
@@ -466,7 +466,6 @@ class TestNetCfgDistroRedhat(TestNetCfgDistroBase):
                 GATEWAY=192.168.1.254
                 IPADDR=192.168.1.5
                 NETMASK=255.255.255.0
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 STARTMODE=auto
                 TYPE=Ethernet
@@ -475,7 +474,6 @@ class TestNetCfgDistroRedhat(TestNetCfgDistroBase):
             self.ifcfg_path('eth1'): dedent("""\
                 BOOTPROTO=dhcp
                 DEVICE=eth1
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 STARTMODE=auto
                 TYPE=Ethernet
@@ -500,7 +498,6 @@ class TestNetCfgDistroRedhat(TestNetCfgDistroBase):
                 IPV6ADDR=2607:f0d0:1002:0011::2/64
                 IPV6INIT=yes
                 IPV6_DEFAULTGW=2607:f0d0:1002:0011::1
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 STARTMODE=auto
                 TYPE=Ethernet
@@ -509,7 +506,6 @@ class TestNetCfgDistroRedhat(TestNetCfgDistroBase):
             self.ifcfg_path('eth1'): dedent("""\
                 BOOTPROTO=dhcp
                 DEVICE=eth1
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 STARTMODE=auto
                 TYPE=Ethernet
@@ -562,7 +558,6 @@ class TestNetCfgDistroOpensuse(TestNetCfgDistroBase):
                 GATEWAY=192.168.1.254
                 IPADDR=192.168.1.5
                 NETMASK=255.255.255.0
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 STARTMODE=auto
                 TYPE=Ethernet
@@ -571,7 +566,6 @@ class TestNetCfgDistroOpensuse(TestNetCfgDistroBase):
             self.ifcfg_path('eth1'): dedent("""\
                 BOOTPROTO=dhcp
                 DEVICE=eth1
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 STARTMODE=auto
                 TYPE=Ethernet
@@ -593,7 +587,6 @@ class TestNetCfgDistroOpensuse(TestNetCfgDistroBase):
                 IPV6ADDR=2607:f0d0:1002:0011::2/64
                 IPV6INIT=yes
                 IPV6_DEFAULTGW=2607:f0d0:1002:0011::1
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 STARTMODE=auto
                 TYPE=Ethernet
@@ -602,7 +595,6 @@ class TestNetCfgDistroOpensuse(TestNetCfgDistroBase):
             self.ifcfg_path('eth1'): dedent("""\
                 BOOTPROTO=dhcp
                 DEVICE=eth1
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 STARTMODE=auto
                 TYPE=Ethernet
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
index 01119e0a..40427461 100644
--- a/tests/unittests/test_net.py
+++ b/tests/unittests/test_net.py
@@ -496,7 +496,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
 STARTMODE=auto
 TYPE=Ethernet
@@ -530,7 +529,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
 STARTMODE=auto
 TYPE=Ethernet
@@ -600,7 +598,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
 STARTMODE=auto
 TYPE=Ethernet
@@ -636,7 +633,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
 STARTMODE=auto
 TYPE=Ethernet
@@ -731,7 +727,6 @@ IPV6ADDR_SECONDARIES="2001:DB9::10/64 2001:DB10::10/64"
 IPV6INIT=yes
 IPV6_DEFAULTGW=2001:DB8::1
 NETMASK=255.255.252.0
-NM_CONTROLLED=no
 ONBOOT=yes
 STARTMODE=auto
 TYPE=Ethernet
@@ -772,7 +767,6 @@ IPV6ADDR_SECONDARIES="2001:DB9::10/64 2001:DB10::10/64"
 IPV6INIT=yes
 IPV6_DEFAULTGW=2001:DB8::1
 NETMASK=255.255.252.0
-NM_CONTROLLED=no
 ONBOOT=yes
 STARTMODE=auto
 TYPE=Ethernet
@@ -889,7 +883,6 @@ NETWORK_CONFIGS = {
                 BOOTPROTO=none
                 DEVICE=eth1
                 HWADDR=cf:d6:af:48:e8:80
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 STARTMODE=auto
                 TYPE=Ethernet
@@ -907,7 +900,6 @@ NETWORK_CONFIGS = {
                 IPADDR=192.168.21.3
                 NETMASK=255.255.255.0
                 METRIC=10000
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 STARTMODE=auto
                 TYPE=Ethernet
@@ -1022,7 +1014,6 @@ NETWORK_CONFIGS = {
                 IPV6ADDR=2001:1::1/64
                 IPV6INIT=yes
                 NETMASK=255.255.255.0
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 STARTMODE=auto
                 TYPE=Ethernet
@@ -1062,7 +1053,6 @@ NETWORK_CONFIGS = {
                 DHCPV6C=yes
                 IPV6INIT=yes
                 DEVICE=iface0
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 STARTMODE=auto
                 TYPE=Ethernet
@@ -1111,7 +1101,6 @@ NETWORK_CONFIGS = {
                 IPV6INIT=yes
                 IPV6_FORCE_ACCEPT_RA=yes
                 DEVICE=iface0
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 STARTMODE=auto
                 TYPE=Ethernet
@@ -1160,7 +1149,6 @@ NETWORK_CONFIGS = {
                 IPV6INIT=yes
                 IPV6_FORCE_ACCEPT_RA=no
                 DEVICE=iface0
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 STARTMODE=auto
                 TYPE=Ethernet
@@ -1199,7 +1187,6 @@ NETWORK_CONFIGS = {
                 IPV6_AUTOCONF=yes
                 IPV6INIT=yes
                 DEVICE=iface0
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 STARTMODE=auto
                 TYPE=Ethernet
@@ -1240,7 +1227,6 @@ NETWORK_CONFIGS = {
             IPV6_AUTOCONF=yes
             IPV6INIT=yes
             DEVICE=iface0
-            NM_CONTROLLED=no
             ONBOOT=yes
             STARTMODE=auto
             TYPE=Ethernet
@@ -1281,7 +1267,6 @@ NETWORK_CONFIGS = {
             IPV6INIT=yes
             IPV6_FORCE_ACCEPT_RA=yes
             DEVICE=iface0
-            NM_CONTROLLED=no
             ONBOOT=yes
             STARTMODE=auto
             TYPE=Ethernet
@@ -1491,7 +1476,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
                 STARTMODE=auto
                 TYPE=Bond
@@ -1500,7 +1484,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
                 STARTMODE=auto
@@ -1519,7 +1502,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
                 STARTMODE=auto
@@ -1530,7 +1512,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
                 STARTMODE=auto
                 TYPE=Ethernet
@@ -1548,7 +1529,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
                 STARTMODE=auto
@@ -1560,7 +1540,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
                 STARTMODE=auto
                 SLAVE=yes
@@ -1571,7 +1550,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
                 STARTMODE=auto
                 SLAVE=yes
@@ -1582,7 +1560,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
                 STARTMODE=auto
                 TYPE=Ethernet
@@ -1592,7 +1569,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
                 STARTMODE=auto
                 TYPE=Ethernet
@@ -1602,7 +1578,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
                 STARTMODE=manual
                 TYPE=Ethernet
@@ -1614,7 +1589,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
                 STARTMODE=auto
                 TYPE=InfiniBand
@@ -2027,7 +2001,6 @@ iface bond0 inet6 static
         MTU=9000
         NETMASK=255.255.255.0
         NETMASK1=255.255.255.0
-        NM_CONTROLLED=no
         ONBOOT=yes
         STARTMODE=auto
         TYPE=Bond
@@ -2038,7 +2011,6 @@ iface bond0 inet6 static
         DEVICE=bond0s0
         HWADDR=aa:bb:cc:dd:e8:00
         MASTER=bond0
-        NM_CONTROLLED=no
         ONBOOT=yes
         SLAVE=yes
         STARTMODE=auto
@@ -2055,7 +2027,6 @@ iface bond0 inet6 static
         DEVICE=bond0s1
         HWADDR=aa:bb:cc:dd:e8:01
         MASTER=bond0
-        NM_CONTROLLED=no
         ONBOOT=yes
         SLAVE=yes
         STARTMODE=auto
@@ -2088,7 +2059,6 @@ iface bond0 inet6 static
         MTU=9000
         NETMASK=255.255.255.0
         NETMASK1=255.255.255.0
-        NM_CONTROLLED=no
         ONBOOT=yes
         STARTMODE=auto
         TYPE=Bond
@@ -2099,7 +2069,6 @@ iface bond0 inet6 static
         DEVICE=bond0s0
         HWADDR=aa:bb:cc:dd:e8:00
         MASTER=bond0
-        NM_CONTROLLED=no
         ONBOOT=yes
         SLAVE=yes
         STARTMODE=auto
@@ -2122,7 +2091,6 @@ iface bond0 inet6 static
         DEVICE=bond0s1
         HWADDR=aa:bb:cc:dd:e8:01
         MASTER=bond0
-        NM_CONTROLLED=no
         ONBOOT=yes
         SLAVE=yes
         STARTMODE=auto
@@ -2161,7 +2129,6 @@ iface bond0 inet6 static
                 BOOTPROTO=none
                 DEVICE=en0
                 HWADDR=aa:bb:cc:dd:e8:00
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 STARTMODE=auto
                 TYPE=Ethernet
@@ -2180,7 +2147,6 @@ iface bond0 inet6 static
                 MTU=2222
                 NETMASK=255.255.255.0
                 NETMASK1=255.255.255.0
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 PHYSDEV=en0
                 STARTMODE=auto
@@ -2222,7 +2188,6 @@ iface bond0 inet6 static
                 DEVICE=br0
                 IPADDR=192.168.2.2
                 NETMASK=255.255.255.0
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 PRIO=22
                 STARTMODE=auto
@@ -2238,7 +2203,6 @@ iface bond0 inet6 static
                 IPADDR6=2001:1::100/96
                 IPV6ADDR=2001:1::100/96
                 IPV6INIT=yes
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 STARTMODE=auto
                 TYPE=Ethernet
@@ -2252,7 +2216,6 @@ iface bond0 inet6 static
                 IPADDR6=2001:1::101/96
                 IPV6ADDR=2001:1::101/96
                 IPV6INIT=yes
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 STARTMODE=auto
                 TYPE=Ethernet
@@ -2327,7 +2290,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
                 STARTMODE=manual
                 TYPE=Ethernet
@@ -2338,7 +2300,6 @@ iface bond0 inet6 static
                 DEVICE=eth1
                 HWADDR=52:54:00:12:34:aa
                 MTU=1480
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 STARTMODE=auto
                 TYPE=Ethernet
@@ -2348,7 +2309,6 @@ iface bond0 inet6 static
                 BOOTPROTO=none
                 DEVICE=eth2
                 HWADDR=52:54:00:12:34:ff
-                NM_CONTROLLED=no
                 ONBOOT=no
                 STARTMODE=manual
                 TYPE=Ethernet
@@ -2766,7 +2726,6 @@ class TestRhelSysConfigRendering(CiTestCase):
 BOOTPROTO=dhcp
 DEVICE=eth1000
 HWADDR=07-1c-c6-75-a4-be
-NM_CONTROLLED=no
 ONBOOT=yes
 STARTMODE=auto
 TYPE=Ethernet
@@ -2888,7 +2847,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
 STARTMODE=auto
 TYPE=Ethernet
@@ -2920,7 +2878,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
 STARTMODE=auto
 TYPE=Ethernet
@@ -2935,7 +2892,6 @@ DEVICE=eth1
 DHCLIENT_SET_DEFAULT_ROUTE=no
 HWADDR=fa:16:3e:b1:ca:29
 MTU=9000
-NM_CONTROLLED=no
 ONBOOT=yes
 STARTMODE=auto
 TYPE=Ethernet
@@ -2961,7 +2917,6 @@ USERCTL=no
 #
 BOOTPROTO=dhcp
 DEVICE=eth0
-NM_CONTROLLED=no
 ONBOOT=yes
 STARTMODE=auto
 TYPE=Ethernet
@@ -3168,7 +3123,6 @@ USERCTL=no
                    IPV6INIT=yes
                    IPV6_DEFAULTGW=2001:db8::1
                    NETMASK=255.255.255.0
-                   NM_CONTROLLED=no
                    ONBOOT=yes
                    STARTMODE=auto
                    TYPE=Ethernet
@@ -3194,7 +3148,6 @@ USERCTL=no
             'ifcfg-eno1': textwrap.dedent("""\
                 BOOTPROTO=none
                 DEVICE=eno1
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 STARTMODE=auto
                 TYPE=Ethernet
@@ -3206,7 +3159,6 @@ USERCTL=no
                 IPADDR=192.6.1.9
                 MTU=1495
                 NETMASK=255.255.255.0
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 PHYSDEV=eno1
                 STARTMODE=auto
@@ -3238,7 +3190,6 @@ USERCTL=no
                 IPADDR=10.101.8.65
                 MTU=1334
                 NETMASK=255.255.255.192
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 STARTMODE=auto
                 TYPE=Bond
@@ -3249,7 +3200,6 @@ USERCTL=no
                 BOOTPROTO=none
                 DEVICE=enp0s0
                 MASTER=bond0
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 SLAVE=yes
                 STARTMODE=auto
@@ -3261,7 +3211,6 @@ USERCTL=no
                 BOOTPROTO=none
                 DEVICE=enp0s1
                 MASTER=bond0
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 SLAVE=yes
                 STARTMODE=auto
@@ -3286,7 +3235,6 @@ USERCTL=no
                 DEVICE=eno1
                 HWADDR=07-1c-c6-75-a4-be
                 METRIC=100
-                NM_CONTROLLED=no
                 ONBOOT=yes
                 STARTMODE=auto
                 TYPE=Ethernet
@@ -3386,7 +3334,6 @@ class TestOpenSuseSysConfigRendering(CiTestCase):
 BOOTPROTO=dhcp
 DEVICE=eth1000
 HWADDR=07-1c-c6-75-a4-be
-NM_CONTROLLED=no
 ONBOOT=yes
 STARTMODE=auto
 TYPE=Ethernet
@@ -3508,7 +3455,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
 STARTMODE=auto
 TYPE=Ethernet
@@ -3538,7 +3484,6 @@ USERCTL=no
 #
 BOOTPROTO=dhcp
 DEVICE=eth0
-NM_CONTROLLED=no
 ONBOOT=yes
 STARTMODE=auto
 TYPE=Ethernet
-- 
2.17.2

