aboutsummaryrefslogtreecommitdiffstats
path: root/os_net_config/tests/test_impl_ifcfg.py
diff options
context:
space:
mode:
authorDan Sneddon <dsneddon@redhat.com>2016-04-13 01:17:16 -0700
committerDan Sneddon <dsneddon@redhat.com>2016-07-05 10:27:45 -0700
commit78e1b65d93a1c16d58fd72cb65f8e2adf1762854 (patch)
tree150a8e2a68c41b0bd76dc17829181e4b4842b1de /os_net_config/tests/test_impl_ifcfg.py
parent6bb8412ef3d3f163d91f2884081b743f07a78f18 (diff)
Add support for Infiniband interfaces
This patch adds support for Infiniband interfaces. The only difference between Inifiniband and regular interfaces at this time is that an interface with type "ib_interface" will have "TYPE=Infiniband" added to the ifcfg file. However, the Infiniband interface is implemented as a full new class, so in the future we can add script functions or additional config options to the Infiniband interface config if needed. Unit tests for both the object and the ifcfg implementation are included. This patch does not include an implementation for systems that use /etc/network/interfaces (Debian-based systems). Note that this change has not yet been tested on bare metal with Infiniband hardware. Fixes bug: https://bugzilla.redhat.com/show_bug.cgi?id=1326616 Change-Id: Iaeaca9cd71e2cea6147951d49aecc7458be4ca0b
Diffstat (limited to 'os_net_config/tests/test_impl_ifcfg.py')
-rw-r--r--os_net_config/tests/test_impl_ifcfg.py51
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 = []