Supporting numbered nics for DPDK Port and DPDK Bond

Modified the sample code to use numbered nics instead of physical
device name and added test code for testing the numbered nic usecases.

Implements: blueprint tripleo-ovs-dpdk
Depends-On: If1c91402d2d393140dc1b4a678e68a1bcdbe81e4

Change-Id: Ifadb495be57fcef56a97250de0c52fd03f2dd817
This commit is contained in:
Saravanan KR 2016-08-24 11:41:18 +05:30
parent 9108fcb7bb
commit f79d534c3e
7 changed files with 45 additions and 19 deletions

View File

@ -10,7 +10,7 @@
"members": [
{
"type": "interface",
"name": "eth1",
"name": "nic2",
}
]
}

View File

@ -16,6 +16,4 @@ network_config:
driver: igb_uio
members:
- type: interface
# nic style number does not work as of now. real interface name has
# to be provided here.
name: eth1
name: nic2

View File

@ -13,7 +13,7 @@
"members": [
{
"type": "interface",
"name": "eth1"
"name": "nic2"
}
]
},
@ -23,7 +23,7 @@
"members": [
{
"type": "interface",
"name": "eth2"
"name": "nic3"
}
]
},

View File

@ -20,14 +20,14 @@ network_config:
members:
-
type: interface
name: eth1
name: nic2
-
type: ovs_dpdk_port
name: dpdk1
members:
-
type: interface
name: eth2
name: nic3
-
type: vlan
vlan_id: 16

View File

@ -1060,7 +1060,7 @@ class OvsDpdkBond(_BaseOpts):
if isinstance(obj, OvsDpdkPort):
members.append(obj)
else:
msg = 'Membrs must be of type ovs_dpdk_port'
msg = 'Members must be of type ovs_dpdk_port'
raise InvalidConfigException(msg)
else:
msg = 'Members must be a list.'

View File

@ -759,12 +759,21 @@ DNS2=5.6.7.8
self.assertEqual(em1_config, self.get_interface_config('em1'))
def test_network_ovs_dpdk_bridge_and_port(self):
interface = objects.Interface(name='eth1')
nic_mapping = {'nic1': 'eth0', 'nic2': 'eth1', 'nic3': 'eth2'}
self.stubbed_mapped_nics = nic_mapping
interface = objects.Interface(name='nic3')
dpdk_port = objects.OvsDpdkPort(name='dpdk0', members=[interface])
bridge = objects.OvsUserBridge('br-link', members=[dpdk_port])
self.provider.add_interface(interface)
self.provider.add_interface(dpdk_port)
self.provider.add_bridge(bridge)
def test_bind_dpdk_interfaces(ifname, driver, noop):
self.assertEqual(ifname, 'eth2')
self.assertEqual(driver, 'vfio-pci')
self.stubs.Set(utils, 'bind_dpdk_interfaces',
test_bind_dpdk_interfaces)
self.provider.add_ovs_dpdk_port(dpdk_port)
self.provider.add_ovs_user_bridge(bridge)
br_link_config = """# This file is autogenerated by os-net-config
DEVICE=br-link
ONBOOT=yes
@ -789,14 +798,24 @@ OVS_BRIDGE=br-link
self.assertEqual(dpdk0_config, self.get_interface_config('dpdk0'))
def test_network_ovs_dpdk_bond(self):
iface0 = objects.Interface(name='eth1')
nic_mapping = {'nic1': 'eth0', 'nic2': 'eth1', 'nic3': 'eth2'}
self.stubbed_mapped_nics = nic_mapping
iface0 = objects.Interface(name='nic2')
dpdk0 = objects.OvsDpdkPort(name='dpdk0', members=[iface0])
iface1 = objects.Interface(name='eth2')
iface1 = objects.Interface(name='nic3')
dpdk1 = objects.OvsDpdkPort(name='dpdk1', members=[iface1])
bond = objects.OvsDpdkBond('dpdkbond0', members=[dpdk0, dpdk1])
bridge = objects.OvsUserBridge('br-link', members=[bond])
self.provider.add_bond(bond)
self.provider.add_bridge(bridge)
def test_bind_dpdk_interfaces(ifname, driver, noop):
self.assertIn(ifname, ['eth1', 'eth2'])
self.assertEqual(driver, 'vfio-pci')
self.stubs.Set(utils, 'bind_dpdk_interfaces',
test_bind_dpdk_interfaces)
self.provider.add_ovs_dpdk_bond(bond)
self.provider.add_ovs_user_bridge(bridge)
dpdk_bond_config = """# This file is autogenerated by os-net-config
DEVICE=dpdkbond0

View File

@ -834,7 +834,16 @@ class TestNicMapping(base.TestCase):
class TestOvsDpdkBond(base.TestCase):
# We want to test the function, not the dummy..
stub_mapped_nics = False
def _stub_active_nics(self, nics):
def dummy_ordered_active_nics():
return nics
self.stubs.Set(utils, 'ordered_active_nics', dummy_ordered_active_nics)
def test_from_json_dhcp(self):
self._stub_active_nics(['eth0', 'eth1', 'eth2'])
data = """{
"type": "ovs_dpdk_bond",
"name": "dpdkbond0",
@ -846,7 +855,7 @@ class TestOvsDpdkBond(base.TestCase):
"members": [
{
"type": "interface",
"name": "eth1"
"name": "nic2"
}
]
},
@ -856,7 +865,7 @@ class TestOvsDpdkBond(base.TestCase):
"members": [
{
"type": "interface",
"name": "eth2"
"name": "nic3"
}
]
}