Add infiniband support with nmstate provider
Adding support for infiniband using nmstate provider. It also includes the unit testing for the same. However its not tested end to end due to the non availability of hardware. Change-Id: Ia597bc8d4c7c5766be86b39242216d709fd581fe
This commit is contained in:
parent
d2f1423008
commit
fd91e41154
|
@ -22,6 +22,7 @@ from libnmstate.schema import BondMode
|
|||
from libnmstate.schema import DNS
|
||||
from libnmstate.schema import Ethernet
|
||||
from libnmstate.schema import Ethtool
|
||||
from libnmstate.schema import InfiniBand
|
||||
from libnmstate.schema import Interface
|
||||
from libnmstate.schema import InterfaceIPv4
|
||||
from libnmstate.schema import InterfaceIPv6
|
||||
|
@ -1479,6 +1480,44 @@ class NmstateNetConfig(os_net_config.NetConfig):
|
|||
self.add_ethtool_config(sriov_vf.name, data,
|
||||
sriov_vf.ethtool_opts)
|
||||
|
||||
def add_ib_interface(self, ib_interface):
|
||||
"""Add an InfiniBand interface object to the net config object.
|
||||
|
||||
:param ib_interface: The InfiniBand interface object to add.
|
||||
"""
|
||||
logger.info('adding ib_interface: %s' % ib_interface.name)
|
||||
data = self._add_common(ib_interface)
|
||||
logger.debug('ib_interface data: %s' % data)
|
||||
data[Interface.TYPE] = InterfaceType.INFINIBAND
|
||||
if ib_interface.ethtool_opts:
|
||||
self.add_ethtool_config(ib_interface.name, data,
|
||||
ib_interface.ethtool_opts)
|
||||
# Default mode is set to 'datagram' since 'connected' is not
|
||||
# supported in some devices
|
||||
config = {}
|
||||
config[InfiniBand.MODE] = InfiniBand.Mode.DATAGRAM
|
||||
data[InfiniBand.CONFIG_SUBTREE] = config
|
||||
self.interface_data[ib_interface.name] = data
|
||||
|
||||
def add_ib_child_interface(self, ib_child_interface):
|
||||
"""Add an InfiniBand child interface object to the net config object.
|
||||
|
||||
:param ib_child_interface: The InfiniBand child
|
||||
interface object to add.
|
||||
"""
|
||||
logger.info('adding ib_child_interface: %s' % ib_child_interface.name)
|
||||
data = self._add_common(ib_child_interface)
|
||||
logger.debug('ib_child_interface data: %s' % data)
|
||||
data[Interface.TYPE] = InterfaceType.INFINIBAND
|
||||
config = {}
|
||||
config[InfiniBand.PKEY] = ib_child_interface.pkey_id
|
||||
config[InfiniBand.BASE_IFACE] = ib_child_interface.parent
|
||||
# Default mode is set to 'datagram' since 'connected' is not
|
||||
# supported in some devices
|
||||
config[InfiniBand.MODE] = InfiniBand.Mode.DATAGRAM
|
||||
data[InfiniBand.CONFIG_SUBTREE] = config
|
||||
self.interface_data[ib_child_interface.name] = data
|
||||
|
||||
def apply(self, cleanup=False, activate=True):
|
||||
"""Apply the network configuration.
|
||||
|
||||
|
|
|
@ -1495,6 +1495,55 @@ class TestNmstateNetConfig(base.TestCase):
|
|||
self.assertEqual(yaml.safe_load(exp_bond_config),
|
||||
self.get_linuxbond_config('bond_lnx'))
|
||||
|
||||
def test_infiniband_parent(self):
|
||||
expected_ib_config = """
|
||||
ipv4:
|
||||
dhcp: False
|
||||
enabled: False
|
||||
ipv6:
|
||||
autoconf: False
|
||||
dhcp: False
|
||||
enabled: False
|
||||
mtu: 1400
|
||||
name: ib0
|
||||
state: up
|
||||
type: infiniband
|
||||
infiniband:
|
||||
mode: datagram
|
||||
"""
|
||||
|
||||
interface1 = objects.Interface('ib0', mtu=1400)
|
||||
self.provider.add_ib_interface(interface1)
|
||||
self.assertEqual(yaml.safe_load(expected_ib_config),
|
||||
self.get_interface_config('ib0'))
|
||||
|
||||
expected_ib2_config = """
|
||||
name: ib0.8064
|
||||
ipv4:
|
||||
dhcp: False
|
||||
enabled: True
|
||||
address:
|
||||
- ip: 192.168.1.2
|
||||
prefix-length: 24
|
||||
ipv6:
|
||||
autoconf: False
|
||||
dhcp: False
|
||||
enabled: False
|
||||
state: up
|
||||
type: infiniband
|
||||
infiniband:
|
||||
pkey: "0x8064"
|
||||
base-iface: ib0
|
||||
mode: datagram
|
||||
"""
|
||||
v4_addr = objects.Address('192.168.1.2/24')
|
||||
interface2 = objects.IbChildInterface(parent='ib0',
|
||||
pkey_id=100,
|
||||
addresses=[v4_addr])
|
||||
self.provider.add_ib_child_interface(interface2)
|
||||
self.assertEqual(yaml.safe_load(expected_ib2_config),
|
||||
self.get_interface_config('ib0.8064'))
|
||||
|
||||
|
||||
class TestNmstateNetConfigApply(base.TestCase):
|
||||
|
||||
|
|
Loading…
Reference in New Issue