aboutsummaryrefslogtreecommitdiffstats
path: root/os_net_config/tests
diff options
context:
space:
mode:
Diffstat (limited to 'os_net_config/tests')
-rw-r--r--os_net_config/tests/test_impl_ifcfg.py43
-rw-r--r--os_net_config/tests/test_objects.py14
2 files changed, 52 insertions, 5 deletions
diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py
index 3930709..f43faed 100644
--- a/os_net_config/tests/test_impl_ifcfg.py
+++ b/os_net_config/tests/test_impl_ifcfg.py
@@ -25,9 +25,11 @@ from os_net_config.tests import base
from os_net_config import utils
-_BASE_IFCFG = """DEVICE=em1
+_BASE_IFCFG = """# This file is autogenerated by os-net-config
+DEVICE=em1
ONBOOT=yes
HOTPLUG=no
+NM_CONTROLLED=no
"""
_NO_IP = _BASE_IFCFG + "BOOTPROTO=none\n"
@@ -60,9 +62,11 @@ OVS_BRIDGE=br-ctlplane
BOOTPROTO=none
"""
-_OVS_BRIDGE_DHCP = """DEVICE=br-ctlplane
+_OVS_BRIDGE_DHCP = """# This file is autogenerated by os-net-config
+DEVICE=br-ctlplane
ONBOOT=yes
HOTPLUG=no
+NM_CONTROLLED=no
DEVICETYPE=ovs
TYPE=OVSBridge
OVSBOOTPROTO=dhcp
@@ -78,9 +82,11 @@ _OVS_BRIDGE_DHCP_OVS_EXTRA = _OVS_BRIDGE_DHCP + \
" -- br-set-external-id br-ctlplane bridge-id br-ctlplane\"\n"
-_BASE_VLAN = """DEVICE=vlan5
+_BASE_VLAN = """# This file is autogenerated by os-net-config
+DEVICE=vlan5
ONBOOT=yes
HOTPLUG=no
+NM_CONTROLLED=no
VLAN=yes
PHYSDEV=em1
"""
@@ -100,9 +106,11 @@ BOOTPROTO=none
"""
-_OVS_BOND_DHCP = """DEVICE=bond0
+_OVS_BOND_DHCP = """# This file is autogenerated by os-net-config
+DEVICE=bond0
ONBOOT=yes
HOTPLUG=no
+NM_CONTROLLED=no
DEVICETYPE=ovs
TYPE=OVSBond
OVSBOOTPROTO=dhcp
@@ -246,15 +254,40 @@ class TestIfcfgNetConfig(base.TestCase):
self.provider.add_bond(bond)
self.assertEqual(_NO_IP, self.get_interface_config('em1'))
- em2_config = """DEVICE=em2
+ em2_config = """# This file is autogenerated by os-net-config
+DEVICE=em2
ONBOOT=yes
HOTPLUG=no
+NM_CONTROLLED=no
BOOTPROTO=none
"""
self.assertEqual(em2_config, self.get_interface_config('em2'))
self.assertEqual(_OVS_BOND_DHCP,
self.get_interface_config('bond0'))
+ def test_interface_defroute(self):
+ interface1 = objects.Interface('em1')
+ interface2 = objects.Interface('em2', defroute=False)
+ self.provider.add_interface(interface1)
+ self.provider.add_interface(interface2)
+ em1_config = """# This file is autogenerated by os-net-config
+DEVICE=em1
+ONBOOT=yes
+HOTPLUG=no
+NM_CONTROLLED=no
+BOOTPROTO=none
+"""
+ em2_config = """# This file is autogenerated by os-net-config
+DEVICE=em2
+ONBOOT=yes
+HOTPLUG=no
+NM_CONTROLLED=no
+BOOTPROTO=none
+DEFROUTE=no
+"""
+ self.assertEqual(em1_config, self.get_interface_config('em1'))
+ self.assertEqual(em2_config, self.get_interface_config('em2'))
+
class TestIfcfgNetConfigApply(base.TestCase):
diff --git a/os_net_config/tests/test_objects.py b/os_net_config/tests/test_objects.py
index 268a48b..2e545d0 100644
--- a/os_net_config/tests/test_objects.py
+++ b/os_net_config/tests/test_objects.py
@@ -94,6 +94,20 @@ class TestInterface(base.TestCase):
self.assertEqual("em1", interface.name)
self.assertEqual(True, interface.use_dhcp)
+ def test_from_json_defroute(self):
+ data = '{"type": "interface", "name": "em1", "use_dhcp": true}'
+ interface1 = objects.object_from_json(json.loads(data))
+ data = """{
+"type": "interface",
+"name": "em1",
+"use_dhcp": true,
+"defroute": false
+}
+"""
+ interface2 = objects.object_from_json(json.loads(data))
+ self.assertEqual(True, interface1.defroute)
+ self.assertEqual(False, interface2.defroute)
+
def test_from_json_dhcp_nic1(self):
def dummy_numbered_nics(nic_mapping=None):
return {"nic1": "em3"}