return item_field[index]
except IndexError:
raise ChainException("List %s is too short for chain index %d" %
- (str(item_field), index))
+ (str(item_field), index)) from IndexError
# single value is configured
if auto_index:
return item_field + index
self.vlans = [self._check_list('vlans[0]', self.config.vlans[0], re_vlan),
self._check_list('vlans[1]', self.config.vlans[1], re_vlan)]
except IndexError:
- raise ChainException('vlans parameter is mandatory. Set valid value in config file')
+ raise ChainException(
+ 'vlans parameter is mandatory. Set valid value in config file') from IndexError
def _get_dest_macs_from_config(self):
re_mac = "[0-9a-fA-F]{2}([-:])[0-9a-fA-F]{2}(\\1[0-9a-fA-F]{2}){4}$"
except IOError:
raise Exception("Configuration file at '{}' was not found. Please use correct path "
"and verify it is visible to container if you run nfvbench in container."
- .format(file_name))
+ .format(file_name)) from IOError
if from_cfg:
if not whitelist_keys:
LOG.error("String %s is not well formatted. Please verify your yaml/json string. "
"If string is a file path, file was not found. Please use correct path and "
"verify it is visible to container if you run nfvbench in container.", cfg_text)
- raise Exception(e)
+ raise Exception(e) from e
if from_cfg:
if not whitelist_keys:
whitelist_keys = []
factory = getattr(factory_module, config['factory_class'])()
except AttributeError:
raise Exception("Requested factory module '{m}' or class '{c}' was not found."
- .format(m=config['factory_module'], c=config['factory_class']))
+ .format(m=config['factory_module'],
+ c=config['factory_class'])) from AttributeError
# create config plugin for this platform
config_plugin = factory.get_config_plugin_class()(config)
config = config_plugin.get_config()
value = int((ip_size / step)) + 1
return value
except ZeroDivisionError:
- raise ZeroDivisionError("step can't be zero !")
+ raise ZeroDivisionError("step can't be zero !") from ZeroDivisionError
def set_mac(self, mac):
"""Set the local MAC for this port device."""
if server_ip == '127.0.0.1':
self.__start_local_server()
else:
- raise TrafficGeneratorException(e.message)
+ raise TrafficGeneratorException(e.message) from e
ports = list(self.generator_config.ports)
self.port_handle = ports
message = f.read()
else:
message = e.message
- raise TrafficGeneratorException(message)
+ raise TrafficGeneratorException(message) from e
def __start_server(self):
server = TRexTrafficServer()
try:
flow_count = int(flow_count)
except ValueError:
- raise Exception("Unknown flow count format '{}'".format(input_fc))
+ raise Exception("Unknown flow count format '{}'".format(input_fc)) from ValueError
return flow_count * multiplier
try:
self._fd = os.open(self._path, os.O_CREAT)
fcntl.flock(self._fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
- except (OSError, IOError):
- raise Exception('Other NFVbench process is running. Please wait')
+ except (OSError, IOError) as e:
+ raise Exception('Other NFVbench process is running. Please wait') from e
def __exit__(self, *args):
fcntl.flock(self._fd, fcntl.LOCK_UN)