diff options
Diffstat (limited to 'vswitches')
-rw-r--r-- | vswitches/ovs_dpdk_vhost.py | 5 | ||||
-rw-r--r-- | vswitches/ovs_vanilla.py | 13 | ||||
-rw-r--r-- | vswitches/vpp_dpdk_vhost.py | 3 |
3 files changed, 14 insertions, 7 deletions
diff --git a/vswitches/ovs_dpdk_vhost.py b/vswitches/ovs_dpdk_vhost.py index 11b32c88..6deb0c25 100644 --- a/vswitches/ovs_dpdk_vhost.py +++ b/vswitches/ovs_dpdk_vhost.py @@ -114,12 +114,15 @@ class OvsDpdkVhost(IVSwitchOvs): Creates a port of type dpdk. The new port is named dpdk<n> where n is an integer starting from 0. """ + _nics = S.getValue('NICS') bridge = self._bridges[switch_name] dpdk_count = self._get_port_count('type=dpdk') + if dpdk_count == len(_nics): + raise RuntimeError("Can't add phy port! There are only {} ports defined " + "by WHITELIST_NICS parameter!".format(len(_nics))) port_name = 'dpdk' + str(dpdk_count) # PCI info. Please note there must be no blank space, eg must be # like 'options:dpdk-devargs=0000:06:00.0' - _nics = S.getValue('NICS') nic_pci = 'options:dpdk-devargs=' + _nics[dpdk_count]['pci'] params = ['--', 'set', 'Interface', port_name, 'type=dpdk', nic_pci] # multi-queue enable diff --git a/vswitches/ovs_vanilla.py b/vswitches/ovs_vanilla.py index cfde3b45..83c52050 100644 --- a/vswitches/ovs_vanilla.py +++ b/vswitches/ovs_vanilla.py @@ -16,6 +16,7 @@ """ import logging +import time from conf import settings from vswitches.ovs import IVSwitchOvs from src.ovs import DPCtl @@ -57,10 +58,14 @@ class OvsVanilla(IVSwitchOvs): tasks.run_task(tap_cmd_list, self._logger, 'Deleting ' + tapx, False) self._vport_id = 0 - super(OvsVanilla, self).stop() + # remove datapath before vswitch shutdown dpctl = DPCtl() dpctl.del_dp() + super(OvsVanilla, self).stop() + + # give vswitch time to terminate before modules are removed + time.sleep(5) self._module_manager.remove_modules() def add_phy_port(self, switch_name): @@ -70,10 +75,8 @@ class OvsVanilla(IVSwitchOvs): See IVswitch for general description """ if self._current_id == len(self._ports): - self._logger.error("Can't add port! There are only " + - len(self._ports) + " ports " + - "defined in config!") - raise RuntimeError('Failed to add phy port') + raise RuntimeError("Can't add phy port! There are only {} ports defined " + "by WHITELIST_NICS parameter!".format(len(self._ports))) if not self._ports[self._current_id]: self._logger.error("Can't detect device name for NIC %s", self._current_id) raise ValueError("Invalid device name for %s" % self._current_id) diff --git a/vswitches/vpp_dpdk_vhost.py b/vswitches/vpp_dpdk_vhost.py index c62e28d4..58d6bf51 100644 --- a/vswitches/vpp_dpdk_vhost.py +++ b/vswitches/vpp_dpdk_vhost.py @@ -225,7 +225,8 @@ class VppDpdkVhost(IVSwitch, tasks.Process): vpp_nics = self._get_nic_info(key='Pci') # check if there are any NICs left if len(self._phy_ports) >= len(S.getValue('NICS')): - raise RuntimeError('All available NICs are already configured!') + raise RuntimeError("Can't add phy port! There are only {} ports defined " + "by WHITELIST_NICS parameter!".format(len(S.getValue('NICS')))) nic = S.getValue('NICS')[len(self._phy_ports)] if not nic['pci'] in vpp_nics: |