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_restart_children_on_change(self): # setup and apply a bridge interface = objects.Interface('em1') bridge = objects.OvsBridge('br-ctlplane', use_dhcp=True, members=[interface]) self.provider.add_interface(interface) self.provider.add_bridge(bridge) self.provider.apply() self.assertIn('em1', 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=[interface]) 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 = [] interface1 = objects.Interface('em1') interface2 = objects.Interface('em2') bond = objects.OvsBond('bond0', members=[interface1, interface2]) bridge = objects.OvsBridge('br-ctlplane', use_dhcp=True, members=[bond]) self.provider.add_interface(interface1) self.provider.add_interface(interface2) self.provider.add_bond(bond) self.provider.add_bridge(bridge) self.provider.apply() # changing the bridge should restart everything self.ifup_interface_names = [] bridge = objects.OvsBridge('br-ctlplane', use_dhcp=False, members=[bond]) self.provider.add_interface(interface1) self.provider.add_interface(interface2) self.provider.add_bond(bond) self.provider.add_bridge(bridge) self.provider.apply() self.assertIn('br-ctlplane', self.ifup_interface_names) self.assertIn('bond0', self.ifup_interface_names) self.assertIn('em1', self.ifup_interface_names) self.assertIn('em2', self.ifup_interface_names)
def test_ib_interface_addresses(self): v4_addr = objects.Address('192.168.1.1/24') v6_addr = objects.Address('2001:abc:a::/64') ib_interface = objects.IbInterface('foo', addresses=[v4_addr, v6_addr]) self.assertEqual("192.168.1.1", ib_interface.v4_addresses()[0].ip) self.assertEqual("2001:abc:a::", ib_interface.v6_addresses()[0].ip)