diff options
Diffstat (limited to 'os_net_config/tests/test_impl_ifcfg.py')
-rw-r--r-- | os_net_config/tests/test_impl_ifcfg.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py index 71ad9ae..f30eb89 100644 --- a/os_net_config/tests/test_impl_ifcfg.py +++ b/os_net_config/tests/test_impl_ifcfg.py @@ -60,12 +60,33 @@ BOOTPROTO=none _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 +ONBOOT=yes +HOTPLUG=no +NM_CONTROLLED=no +PEERDNS=no +TYPE=Infiniband +""" + +_V4_IB_IFCFG = _BASE_IB_IFCFG + """BOOTPROTO=static +IPADDR=192.168.1.2 +NETMASK=255.255.255.0 +""" + _V4_IFCFG_MULTIPLE = _V4_IFCFG + """IPADDR1=192.168.1.3 NETMASK1=255.255.255.255 IPADDR2=10.0.0.2 NETMASK2=255.0.0.0 """ +_IB_V4_IFCFG_MULTIPLE = _V4_IB_IFCFG + """IPADDR1=192.168.1.3 +NETMASK1=255.255.255.255 +IPADDR2=10.0.0.2 +NETMASK2=255.0.0.0 +""" + _V6_IFCFG = _BASE_IFCFG + """IPV6INIT=yes IPV6_AUTOCONF=no IPV6ADDR=2001:abc:a::/64 @@ -505,6 +526,16 @@ class TestIfcfgNetConfig(base.TestCase): data = self.provider.generate_ivs_config(['em1'], ['storage5']) self.assertEqual(_IVS_CONFIG, data) + def test_add_ib_interface_with_v4_multiple(self): + addresses = [objects.Address('192.168.1.2/24'), + objects.Address('192.168.1.3/32'), + objects.Address('10.0.0.2/8')] + ib_interface = objects.IbInterface('ib0', addresses=addresses) + self.provider.add_interface(ib_interface) + self.assertEqual(_IB_V4_IFCFG_MULTIPLE, + self.get_interface_config('ib0')) + self.assertEqual('', self.get_route_config()) + def test_add_vlan(self): vlan = objects.Vlan('em1', 5) self.provider.add_vlan(vlan) @@ -775,6 +806,26 @@ class TestIfcfgNetConfigApply(base.TestCase): self.provider.add_interface(interface) self.provider.add_bridge(bridge) self.provider.apply() + self.assertIn('em1', self.ifup_interface_names) + + # test infiniband interfaces act as proper bridge members + ib_interface = objects.IbInterface('ib0') + bridge = objects.OvsBridge('br-ctlplane', use_dhcp=True, + members=[ib_interface]) + self.provider.add_interface(ib_interface) + self.provider.add_bridge(bridge) + self.provider.apply() + self.assertIn('ib0', self.ifup_interface_names) + self.assertIn('br-ctlplane', self.ifup_interface_names) + + # changing the bridge should restart the interface too + self.ifup_interface_names = [] + bridge = objects.OvsBridge('br-ctlplane', use_dhcp=False, + members=[ib_interface]) + self.provider.add_interface(interface) + self.provider.add_bridge(bridge) + self.provider.apply() + self.assertIn('ib0', self.ifup_interface_names) # setup and apply a bond on a bridge self.ifup_interface_names = [] |