vswitch: Improve add_phy_port error messages 15/50115/2
authorMartin Klozik <martinx.klozik@intel.com>
Fri, 5 Jan 2018 13:24:09 +0000 (13:24 +0000)
committerMartin Klozik <martinx.klozik@intel.com>
Fri, 5 Jan 2018 14:16:00 +0000 (14:16 +0000)
In case that vSwitch can't add required number of physical
ports, then error message should be printed. Previous implementation
was not consistent. Thus error handling has been united across
all vswitches and message explicitly states the cause of the failure.

NOTE: A better solution would be a refactoring of all vSwitch
classes to follow VPP port handling and to move port related
structures and physical port check into parent vswitch class.

JIRA: VSPERF-555

Change-Id: Id09a61432ea93e261f563254829348ac61f5dc8a
Signed-off-by: Martin Klozik <martinx.klozik@intel.com>
Reviewed-by: Jose Lausuch <jalausuch@suse.com>
Reviewed-by: Al Morton <acmorton@att.com>
Reviewed-by: Christian Trautman <ctrautma@redhat.com>
Reviewed-by: Sridhar Rao <sridhar.rao@spirent.com>
Reviewed-by: Trevor Cooper <trevor.cooper@intel.com>
testcases/testcase.py
vswitches/ovs_dpdk_vhost.py
vswitches/ovs_vanilla.py
vswitches/vpp_dpdk_vhost.py

index b3300b8..cf71d59 100644 (file)
@@ -169,7 +169,7 @@ class TestCase(object):
                 self._traffic['l3'] = S.getValue(self._tunnel_type.upper() + '_FRAME_L3')
                 self._traffic['l4'] = S.getValue(self._tunnel_type.upper() + '_FRAME_L4')
                 self._traffic['l2']['dstmac'] = S.getValue('NICS')[1]['mac']
-        elif len(S.getValue('NICS')) and \
+        elif len(S.getValue('NICS')) >= 2 and \
              (S.getValue('NICS')[0]['type'] == 'vf' or
               S.getValue('NICS')[1]['type'] == 'vf'):
             mac1 = S.getValue('NICS')[0]['mac']
index 11b32c8..6deb0c2 100644 (file)
@@ -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
index 942ddd4..83c5205 100644 (file)
@@ -75,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)
index c62e28d..58d6bf5 100644 (file)
@@ -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: