aboutsummaryrefslogtreecommitdiffstats
path: root/os_net_config/tests/test_impl_ifcfg.py
diff options
context:
space:
mode:
authorDan Sneddon <dsneddon@redhat.com>2017-03-10 13:19:06 -0800
committerDan Sneddon <dsneddon@redhat.com>2017-03-10 14:32:43 -0800
commit5f0145b88571b945b633f999c0d767ccefdce86b (patch)
tree8a75cb10820479d5d54a387ab499f4743b5dac65 /os_net_config/tests/test_impl_ifcfg.py
parentab0e0d433fb363f6a01b7c8305771f2bde47930e (diff)
Allow setting NM_CONTROLLED=yes in os-net-config ifcfg files
This change adds a flag to the base interface type, nm_controlled. If this flag is true, the ifcfg file will contain NM_CONTROLLED=yes. Since this flag is applied at the base it applies to any interface type. Note that not all interface types are supported by NetworkManager at this time, so this option should be used with caution. A demonstration of the usage is included in the linux_bond_networkmanager.yaml file in the sample directory. Change-Id: I2df6ce5b4bdb04651f27fc5daa64aa752e47f3b1 Closes-Bug: 1671888
Diffstat (limited to 'os_net_config/tests/test_impl_ifcfg.py')
-rw-r--r--os_net_config/tests/test_impl_ifcfg.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py
index 6576cef..82ca116 100644
--- a/os_net_config/tests/test_impl_ifcfg.py
+++ b/os_net_config/tests/test_impl_ifcfg.py
@@ -34,6 +34,14 @@ NM_CONTROLLED=no
PEERDNS=no
"""
+_BASE_IFCFG_NETWORKMANAGER = """# This file is autogenerated by os-net-config
+DEVICE=em1
+ONBOOT=yes
+HOTPLUG=no
+NM_CONTROLLED=yes
+PEERDNS=no
+"""
+
_HOTPLUG = """# This file is autogenerated by os-net-config
DEVICE=em1
ONBOOT=yes
@@ -153,6 +161,19 @@ OVSBOOTPROTO=dhcp
OVSDHCPINTERFACES="em1"
"""
+_NM_CONTROLLED_INTERFACE = _BASE_IFCFG_NETWORKMANAGER + """MASTER=bond1
+SLAVE=yes
+BOOTPROTO=none
+"""
+
+_NM_CONTROLLED_BOND = """# This file is autogenerated by os-net-config
+DEVICE=bond1
+ONBOOT=yes
+HOTPLUG=no
+NM_CONTROLLED=yes
+PEERDNS=no
+"""
+
_OVS_BRIDGE_DHCP_STANDALONE = _OVS_BRIDGE_DHCP + \
"OVS_EXTRA=\"set bridge br-ctlplane fail_mode=standalone\"\n"
@@ -845,6 +866,20 @@ DNS2=5.6.7.8
"""
self.assertEqual(em1_config, self.get_interface_config('em1'))
+ def test_nm_controlled(self):
+ interface1 = objects.Interface('em1', nm_controlled=True)
+ interface2 = objects.Interface('em2', nm_controlled=True)
+ bond = objects.LinuxBond('bond1', nm_controlled=True,
+ members=[interface1, interface2])
+ self.provider.add_linux_bond(bond)
+ self.provider.add_interface(interface1)
+ self.provider.add_interface(interface2)
+
+ ifcfg_data = self.get_interface_config('em1')
+ self.assertEqual(_NM_CONTROLLED_INTERFACE, ifcfg_data)
+ bond_data = self.get_linux_bond_config('bond1')
+ self.assertEqual(_NM_CONTROLLED_BOND, bond_data)
+
def test_network_ovs_dpdk_bridge_and_port(self):
nic_mapping = {'nic1': 'eth0', 'nic2': 'eth1', 'nic3': 'eth2'}
self.stubbed_mapped_nics = nic_mapping
@@ -924,6 +959,7 @@ class TestIfcfgNetConfigApply(base.TestCase):
def setUp(self):
super(TestIfcfgNetConfigApply, self).setUp()
self.temp_ifcfg_file = tempfile.NamedTemporaryFile()
+ self.temp_bond_file = tempfile.NamedTemporaryFile()
self.temp_route_file = tempfile.NamedTemporaryFile()
self.temp_route6_file = tempfile.NamedTemporaryFile()
self.temp_bridge_file = tempfile.NamedTemporaryFile()