diff options
author | fmenguy <francoisregis.menguy@orange.com> | 2020-05-06 17:35:35 +0200 |
---|---|---|
committer | fmenguy <francoisregis.menguy@orange.com> | 2020-05-27 11:07:32 +0200 |
commit | 143c4ff68068fd704e7eb4df1c82af29f087c871 (patch) | |
tree | 969713b19beae3944d5d25beb9a3dae8ed6fcf63 /nfvbench/nfvbench.py | |
parent | caac5c7f6e80d33d5031f26e5e0f0ea6f1d3789b (diff) |
[NFVBENCH-168] Improve config properties managed after a REST call
Change-Id: I20973c1c405dec8cce58f984e1fb84e345013b25
Signed-off-by: fmenguy <francoisregis.menguy@orange.com>
Diffstat (limited to 'nfvbench/nfvbench.py')
-rw-r--r-- | nfvbench/nfvbench.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/nfvbench/nfvbench.py b/nfvbench/nfvbench.py index 50b96b6..06ca19d 100644 --- a/nfvbench/nfvbench.py +++ b/nfvbench/nfvbench.py @@ -24,6 +24,7 @@ import sys import traceback from attrdict import AttrDict +from logging import FileHandler import pbr.version from pkg_resources import resource_string @@ -173,6 +174,24 @@ class NFVBench(object): Sanity check on the config is done here as well. """ self.config = AttrDict(dict(self.base_config)) + # Update log file handler if needed after a config update (REST mode) + if 'log_file' in opts: + if opts['log_file']: + (path, _filename) = os.path.split(opts['log_file']) + if not os.path.exists(path): + LOG.warning( + 'Path %s does not exist. Please verify root path is shared with host. Path ' + 'will be created.', path) + os.makedirs(path) + LOG.info('%s is created.', path) + for h in log.getLogger().handlers: + if isinstance(h, FileHandler) and h.baseFilename != opts['log_file']: + # clean log file handler + log.getLogger().removeHandler(h) + # add handler if not existing to avoid duplicates handlers + if len(log.getLogger().handlers) == 1: + log.add_file_logger(opts['log_file']) + self.config.update(opts) config = self.config @@ -184,6 +203,15 @@ class NFVBench(object): config.service_chain = ChainType.EXT config.no_arp = True LOG.info('Running L2 loopback: using EXT chain/no ARP') + + # traffic profile override options + if 'frame_sizes' in opts: + unidir = False + if 'unidir' in opts: + unidir = opts['unidir'] + override_custom_traffic(config, opts['frame_sizes'], unidir) + LOG.info("Frame size has been set to %s for current configuration", opts['frame_sizes']) + config.flow_count = utils.parse_flow_count(config.flow_count) required_flow_count = config.service_chain_count * 2 if config.flow_count < required_flow_count: |