From 1f691d47a6916a0b7b031cc2674d47824d3f8de0 Mon Sep 17 00:00:00 2001 From: Bob Fournier Date: Wed, 13 Jun 2018 16:14:09 -0400 Subject: [PATCH] Restore the order of params in ifcfg file that was inadvertently changed This change to os-net-config in Queens changed the order of the ONBOOT parameter in the ifcg files created by os-net-config - https://review.openstack.org/#/c/485132/. When upgrading a diff is done between the existing ifcfg files and new data to write. Since the order is different, the ifcg files will be detected as different and interfaces, bridges, etc. will be restarted. Change the order back to avoid this from happening. Change-Id: I77162d28b1dc173e3a90cb385a3af92e21c71574 --- os_net_config/impl_ifcfg.py | 8 +-- os_net_config/tests/test_impl_ifcfg.py | 90 +++++++++++++------------- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/os_net_config/impl_ifcfg.py b/os_net_config/impl_ifcfg.py index 4a0af863..64bec0a7 100644 --- a/os_net_config/impl_ifcfg.py +++ b/os_net_config/impl_ifcfg.py @@ -143,14 +143,14 @@ class IfcfgNetConfig(os_net_config.NetConfig): data = "# This file is autogenerated by os-net-config\n" data += "DEVICE=%s\n" % base_opt.name - if isinstance(base_opt, objects.Interface) and base_opt.hotplug: - data += "HOTPLUG=yes\n" - else: - data += "HOTPLUG=no\n" if base_opt.onboot: data += "ONBOOT=yes\n" else: data += "ONBOOT=no\n" + if isinstance(base_opt, objects.Interface) and base_opt.hotplug: + data += "HOTPLUG=yes\n" + else: + data += "HOTPLUG=no\n" if base_opt.nm_controlled: data += "NM_CONTROLLED=yes\n" else: diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py index f9a46ed2..0df9ad76 100644 --- a/os_net_config/tests/test_impl_ifcfg.py +++ b/os_net_config/tests/test_impl_ifcfg.py @@ -28,24 +28,24 @@ from os_net_config import utils _BASE_IFCFG = """# This file is autogenerated by os-net-config DEVICE=em1 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no """ _BASE_IFCFG_NETWORKMANAGER = """# This file is autogenerated by os-net-config DEVICE=em1 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=yes PEERDNS=no """ _HOTPLUG = """# This file is autogenerated by os-net-config DEVICE=em1 -HOTPLUG=yes ONBOOT=yes +HOTPLUG=yes NM_CONTROLLED=no PEERDNS=no BOOTPROTO=none @@ -53,8 +53,8 @@ BOOTPROTO=none _ONBOOT = """# This file is autogenerated by os-net-config DEVICE=em1 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no BOOTPROTO=none @@ -77,8 +77,8 @@ IPV6ADDR=2001:abc:a::/64 _IFCFG_VLAN = """# This file is autogenerated by os-net-config DEVICE=em1.120 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no VLAN=yes @@ -90,8 +90,8 @@ _V4_IFCFG_MAPPED = _V4_IFCFG.replace('em1', 'nic1') + "HWADDR=a1:b2:c3:d4:e5\n" _BASE_IB_IFCFG = """# This file is autogenerated by os-net-config DEVICE=ib0 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no TYPE=Infiniband @@ -126,8 +126,8 @@ _OVS_IFCFG = _BASE_IFCFG + "DEVICETYPE=ovs\nBOOTPROTO=none\n" _OVS_IFCFG_TUNNEL = """# This file is autogenerated by os-net-config DEVICE=tun0 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no DEVICETYPE=ovs @@ -161,8 +161,8 @@ BOOTPROTO=none _OVS_BRIDGE_DHCP = """# This file is autogenerated by os-net-config DEVICE=br-ctlplane -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no DEVICETYPE=ovs TYPE=OVSBridge @@ -177,8 +177,8 @@ BOOTPROTO=none _NM_CONTROLLED_BOND = """# This file is autogenerated by os-net-config DEVICE=bond1 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=yes PEERDNS=no """ @@ -193,8 +193,8 @@ _OVS_BRIDGE_DHCP_SECURE = _OVS_BRIDGE_DHCP + \ _LINUX_BRIDGE_DHCP = """# This file is autogenerated by os-net-config DEVICE=br-ctlplane -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no TYPE=Bridge DELAY=0 @@ -203,8 +203,8 @@ BOOTPROTO=dhcp _OVS_BRIDGE_STATIC = """# This file is autogenerated by os-net-config DEVICE=br-ctlplane -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no DEVICETYPE=ovs @@ -216,8 +216,8 @@ NETMASK=255.255.255.0 _LINUX_BRIDGE_STATIC = """# This file is autogenerated by os-net-config DEVICE=br-ctlplane -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no TYPE=Bridge @@ -238,8 +238,8 @@ _OVS_BRIDGE_DHCP_OVS_EXTRA = _OVS_BRIDGE_DHCP + \ _BASE_VLAN = """# This file is autogenerated by os-net-config DEVICE=vlan5 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no VLAN=yes @@ -249,8 +249,8 @@ PHYSDEV=em1 # vlans on an OVS bridge do not set VLAN=yes or PHYSDEV _BASE_VLAN_OVS = """# This file is autogenerated by os-net-config DEVICE=vlan5 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no """ @@ -276,8 +276,8 @@ BOOTPROTO=none _OVS_BOND_DHCP = """# This file is autogenerated by os-net-config DEVICE=bond0 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no DEVICETYPE=ovs TYPE=OVSBond @@ -287,8 +287,8 @@ BOND_IFACES="em1 em2" _LINUX_BOND_DHCP = """# This file is autogenerated by os-net-config DEVICE=bond0 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no BOOTPROTO=dhcp """ @@ -296,8 +296,8 @@ BOOTPROTO=dhcp _LINUX_TEAM_DHCP = """# This file is autogenerated by os-net-config DEVICE=team0 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no BOOTPROTO=dhcp DEVICETYPE=Team @@ -315,8 +315,8 @@ BOOTPROTO=none _IVS_UPLINK = """# This file is autogenerated by os-net-config DEVICE=em1 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no DEVICETYPE=ivs @@ -326,8 +326,8 @@ BOOTPROTO=none _IVS_INTERFACE = """# This file is autogenerated by os-net-config DEVICE=storage5 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no TYPE=IVSIntPort @@ -344,8 +344,8 @@ _IVS_CONFIG = ('DAEMON_ARGS=\"--hitless --certificate /etc/ivs ' _NFVSWITCH_INTERFACE = """# This file is autogenerated by os-net-config DEVICE=em1 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no DEVICETYPE=nfvswitch @@ -355,8 +355,8 @@ BOOTPROTO=none _NFVSWITCH_INTERNAL = """# This file is autogenerated by os-net-config DEVICE=storage5 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no TYPE=NFVSWITCHIntPort @@ -372,8 +372,8 @@ _NFVSWITCH_CONFIG = ('SETUP_ARGS=\"-c 2,3,4,5 -u em1 -m storage5\"') _OVS_IFCFG_PATCH_PORT = """# This file is autogenerated by os-net-config DEVICE=br-pub-patch -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no DEVICETYPE=ovs @@ -384,8 +384,8 @@ OVS_PATCH_PEER=br-ex-patch _LINUX_TEAM_PRIMARY_IFACE = """# This file is autogenerated by os-net-config DEVICE=em1 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no TEAM_MASTER=team1 @@ -395,8 +395,8 @@ BOOTPROTO=none _CONTRAIL_VROUTER_IFACE = """# This file is autogenerated by os-net-config DEVICE=vhost0 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no BOOTPROTO=static @@ -409,8 +409,8 @@ BIND_INT=em3 _CONTRAIL_VROUTER_DPDK_IFACE = """# This file is autogenerated by os-net-config DEVICE=vhost0 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no BOOTPROTO=static @@ -426,8 +426,8 @@ CPU_LIST=0-31 _CONTRAIL_VROUTER_DPDK_IFACE_CUST_DRIVER = """# This file is autogenerated by \ os-net-config DEVICE=vhost0 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no BOOTPROTO=static @@ -443,8 +443,8 @@ CPU_LIST=0-31 _CONTRAIL_VROUTER_DPDK_BOND_IFACE = """# This file is autogenerated by \ os-net-config DEVICE=vhost0 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no BOOTPROTO=static @@ -947,8 +947,8 @@ class TestIfcfgNetConfig(base.TestCase): em2_config = """# This file is autogenerated by os-net-config DEVICE=em2 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no BOOTPROTO=none @@ -990,16 +990,16 @@ BOOTPROTO=none self.provider.add_interface(interface2) em1_config = """# This file is autogenerated by os-net-config DEVICE=em1 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no BOOTPROTO=none """ em2_config = """# This file is autogenerated by os-net-config DEVICE=em2 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no BOOTPROTO=none @@ -1013,8 +1013,8 @@ DEFROUTE=no self.provider.add_interface(interface1) em1_config = """# This file is autogenerated by os-net-config DEVICE=em1 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no BOOTPROTO=none @@ -1028,8 +1028,8 @@ DHCLIENTARGS=--foobar self.provider.add_interface(interface1) em1_config = """# This file is autogenerated by os-net-config DEVICE=em1 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no BOOTPROTO=none @@ -1042,8 +1042,8 @@ ETHTOOL_OPTS=\"speed 1000 duplex full\" self.provider.add_interface(interface1) em1_config = """# This file is autogenerated by os-net-config DEVICE=em1 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no BOOTPROTO=none DNS1=1.2.3.4 @@ -1056,8 +1056,8 @@ DNS1=1.2.3.4 self.provider.add_interface(interface1) em1_config = """# This file is autogenerated by os-net-config DEVICE=em1 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no BOOTPROTO=none DNS1=1.2.3.4 @@ -1072,8 +1072,8 @@ DNS2=5.6.7.8 self.provider.add_interface(interface1) em1_config = """# This file is autogenerated by os-net-config DEVICE=em1 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no BOOTPROTO=none DNS1=1.2.3.4 @@ -1110,8 +1110,8 @@ DNS2=5.6.7.8 self.provider.add_sriov_vf(vf) vf_config = """# This file is autogenerated by os-net-config DEVICE=eth2_7 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no BOOTPROTO=static @@ -1134,8 +1134,8 @@ NETMASK=255.255.255.0 self.provider.add_sriov_pf(pf) pf_config = """# This file is autogenerated by os-net-config DEVICE=eth2 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no BOOTPROTO=none @@ -1162,8 +1162,8 @@ BOOTPROTO=none self.provider.add_ovs_user_bridge(bridge) br_link_config = """# This file is autogenerated by os-net-config DEVICE=br-link -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no DEVICETYPE=ovs @@ -1171,8 +1171,8 @@ TYPE=OVSUserBridge """ dpdk0_config = """# This file is autogenerated by os-net-config DEVICE=dpdk0 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no DEVICETYPE=ovs @@ -1205,8 +1205,8 @@ OVS_EXTRA="set Interface $DEVICE options:dpdk-devargs=0000:00:09.0" self.provider.add_ovs_user_bridge(bridge) br_link_config = """# This file is autogenerated by os-net-config DEVICE=br-link -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no DEVICETYPE=ovs @@ -1214,8 +1214,8 @@ TYPE=OVSUserBridge """ dpdk0_config = """# This file is autogenerated by os-net-config DEVICE=dpdk0 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no DEVICETYPE=ovs @@ -1255,8 +1255,8 @@ OVS_EXTRA="set Interface $DEVICE options:dpdk-devargs=0000:00:09.0 \ dpdk_bond_config = """# This file is autogenerated by os-net-config DEVICE=dpdkbond0 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no DEVICETYPE=ovs @@ -1294,8 +1294,8 @@ OVS_EXTRA="set Interface dpdk0 options:dpdk-devargs=0000:00:08.0 \ dpdk_bond_config = """# This file is autogenerated by os-net-config DEVICE=dpdkbond0 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no DEVICETYPE=ovs @@ -1336,8 +1336,8 @@ OVS_EXTRA="set Interface dpdk0 options:dpdk-devargs=0000:00:08.0 \ dpdk_bond_config = """# This file is autogenerated by os-net-config DEVICE=dpdkbond0 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no DEVICETYPE=ovs @@ -1378,8 +1378,8 @@ OVS_EXTRA="set Interface dpdk0 options:dpdk-devargs=0000:00:08.0 \ dpdk_bond_config = """# This file is autogenerated by os-net-config DEVICE=dpdkbond0 -HOTPLUG=no ONBOOT=yes +HOTPLUG=no NM_CONTROLLED=no PEERDNS=no DEVICETYPE=ovs