summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/os-net-config/samples/ovs_dpdk.json2
-rw-r--r--etc/os-net-config/samples/ovs_dpdk.yaml4
-rw-r--r--etc/os-net-config/samples/ovs_dpdk_bond.json4
-rw-r--r--etc/os-net-config/samples/ovs_dpdk_bond.yaml4
-rw-r--r--os_net_config/objects.py2
-rw-r--r--os_net_config/tests/test_impl_ifcfg.py35
-rw-r--r--os_net_config/tests/test_objects.py13
7 files changed, 45 insertions, 19 deletions
diff --git a/etc/os-net-config/samples/ovs_dpdk.json b/etc/os-net-config/samples/ovs_dpdk.json
index dc6706d..aa6a321 100644
--- a/etc/os-net-config/samples/ovs_dpdk.json
+++ b/etc/os-net-config/samples/ovs_dpdk.json
@@ -10,7 +10,7 @@
"members": [
{
"type": "interface",
- "name": "eth1",
+ "name": "nic2",
}
]
}
diff --git a/etc/os-net-config/samples/ovs_dpdk.yaml b/etc/os-net-config/samples/ovs_dpdk.yaml
index 18fee31..f5af9ce 100644
--- a/etc/os-net-config/samples/ovs_dpdk.yaml
+++ b/etc/os-net-config/samples/ovs_dpdk.yaml
@@ -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
diff --git a/etc/os-net-config/samples/ovs_dpdk_bond.json b/etc/os-net-config/samples/ovs_dpdk_bond.json
index af82e7b..176c917 100644
--- a/etc/os-net-config/samples/ovs_dpdk_bond.json
+++ b/etc/os-net-config/samples/ovs_dpdk_bond.json
@@ -13,7 +13,7 @@
"members": [
{
"type": "interface",
- "name": "eth1"
+ "name": "nic2"
}
]
},
@@ -23,7 +23,7 @@
"members": [
{
"type": "interface",
- "name": "eth2"
+ "name": "nic3"
}
]
},
diff --git a/etc/os-net-config/samples/ovs_dpdk_bond.yaml b/etc/os-net-config/samples/ovs_dpdk_bond.yaml
index d51fa4a..cc3dfe5 100644
--- a/etc/os-net-config/samples/ovs_dpdk_bond.yaml
+++ b/etc/os-net-config/samples/ovs_dpdk_bond.yaml
@@ -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
diff --git a/os_net_config/objects.py b/os_net_config/objects.py
index 154dccf..8fab1ab 100644
--- a/os_net_config/objects.py
+++ b/os_net_config/objects.py
@@ -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.'
diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py
index 74dd1f9..c3acbc8 100644
--- a/os_net_config/tests/test_impl_ifcfg.py
+++ b/os_net_config/tests/test_impl_ifcfg.py
@@ -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
diff --git a/os_net_config/tests/test_objects.py b/os_net_config/tests/test_objects.py
index 92d43b9..2e5fbe4 100644
--- a/os_net_config/tests/test_objects.py
+++ b/os_net_config/tests/test_objects.py
@@ -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"
}
]
}