summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--nfvbench/chain_clients.py3
-rw-r--r--nfvbench/config.py14
-rw-r--r--nfvbench/nfvbench.py16
-rw-r--r--nfvbench/traffic_client.py3
-rw-r--r--test/test_nfvbench.py14
6 files changed, 48 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index 3cc13a3..f2f94b4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,7 +6,9 @@
.eggs
venv
nfvbench.egg-info
-docs/_build
+nfvbenchvm/dib/dib-venv
+nfvbenchvm/dib/nfvbenchvm_centos-*.d/
*.qcow2
+docs/_build
docs/conf.py
docs/_static
diff --git a/nfvbench/chain_clients.py b/nfvbench/chain_clients.py
index dfd6ff2..affccc8 100644
--- a/nfvbench/chain_clients.py
+++ b/nfvbench/chain_clients.py
@@ -78,7 +78,8 @@ class BasicStageClient(object):
networks = self.neutron.list_networks(name=network_name)
return networks['networks'][0] if networks['networks'] else None
- def _create_net(self, name, subnet, cidr, network_type=None, segmentation_id=None, physical_network=None):
+ def _create_net(self, name, subnet, cidr, network_type=None,
+ segmentation_id=None, physical_network=None):
network = self._lookup_network(name)
if network:
# a network of same name already exists, we need to verify it has the same
diff --git a/nfvbench/config.py b/nfvbench/config.py
index b2972dd..2a67b7e 100644
--- a/nfvbench/config.py
+++ b/nfvbench/config.py
@@ -48,6 +48,20 @@ def config_loads(cfg_text, from_cfg=None):
return cfg
+def get_err_config(subset, superset):
+ for k, v in subset.items():
+ if k not in superset:
+ return {k: v}
+ if v is not None and superset[k] is not None:
+ if not isinstance(v, type(superset[k])):
+ return {k: v}
+ if isinstance(v, dict):
+ res = get_err_config(v, superset[k])
+ if res:
+ return {k: res}
+ return None
+
+
def test_config():
cfg = config_load('a1.yaml')
cfg = config_load('a2.yaml', cfg)
diff --git a/nfvbench/nfvbench.py b/nfvbench/nfvbench.py
index a4f9ead..5b94ce7 100644
--- a/nfvbench/nfvbench.py
+++ b/nfvbench/nfvbench.py
@@ -21,6 +21,7 @@ from chain_runner import ChainRunner
from collections import defaultdict
from config import config_load
from config import config_loads
+from config import get_err_config
import copy
import credentials
import datetime
@@ -404,10 +405,10 @@ def override_custom_traffic(config, frame_sizes, unidir):
def check_physnet(name, netattrs):
if not netattrs.physical_network:
raise Exception("SRIOV requires physical_network to be specified for the {n} network"
- .format(n=name))
+ .format(n=name))
if not netattrs.segmentation_id:
raise Exception("SRIOV requires segmentation_id to be specified for the {n} network"
- .format(n=name))
+ .format(n=name))
def main():
try:
@@ -455,6 +456,13 @@ def main():
LOG.info('Loading configuration string: ' + opts.config)
config = config_loads(opts.config, config)
+ # Making sure no unknown option is given
+ err_config = get_err_config(config, default_cfg)
+ if err_config:
+ err_msg = 'Unknown options found in config file/string: ' + err_config
+ LOG.error(err_msg)
+ raise Exception(err_msg)
+
# traffic profile override options
override_custom_traffic(config, opts.frame_sizes, opts.unidir)
@@ -504,7 +512,9 @@ def main():
else:
with utils.RunLock():
if unknown_opts:
- LOG.warning('Unknown options: ' + ' '.join(unknown_opts))
+ err_msg = 'Unknown options: ' + ' '.join(unknown_opts)
+ LOG.error(err_msg)
+ raise Exception(err_msg)
# remove unfilled values
opts = {k: v for k, v in vars(opts).iteritems() if v is not None}
diff --git a/nfvbench/traffic_client.py b/nfvbench/traffic_client.py
index 319dc0b..7c8367a 100644
--- a/nfvbench/traffic_client.py
+++ b/nfvbench/traffic_client.py
@@ -609,7 +609,8 @@ class TrafficClient(object):
indicating the rate to send on each interface
right the right side of the range to search as a % of line rate
indicating the rate to send on each interface
- targets a dict of drop rates to search (0.1 = 0.1%), indexed by the DR name or "tag" ('ndr', 'pdr')
+ targets a dict of drop rates to search (0.1 = 0.1%), indexed by the DR name or "tag"
+ ('ndr', 'pdr')
results a dict to store results
'''
if len(targets) == 0:
diff --git a/test/test_nfvbench.py b/test/test_nfvbench.py
index be80033..a220703 100644
--- a/test/test_nfvbench.py
+++ b/test/test_nfvbench.py
@@ -15,6 +15,7 @@
#
from attrdict import AttrDict
+from nfvbench.config import get_err_config
from nfvbench.connection import SSH
from nfvbench.credentials import Credentials
from nfvbench.network import Interface
@@ -638,3 +639,16 @@ def test_no_credentials():
assert False
else:
assert True
+
+def test_config():
+ refcfg = {1: 100, 2: {21: 100, 22: 200}, 3: None}
+ assert(get_err_config({}, refcfg) is None)
+ assert(get_err_config({1: 10}, refcfg) is None)
+ assert(get_err_config({2: {21: 1000}}, refcfg) is None)
+ assert(get_err_config({3: "abc"}, refcfg) is None)
+ # correctly fails
+ assert(get_err_config({4: 0}, refcfg) == {4: 0})
+ assert(get_err_config({2: {0: 1, 1: 2}}, refcfg) == {2: {0: 1}})
+ # invalid value type
+ assert(get_err_config({1: 'abc', 2: {21: 0}}, refcfg) == {1: 'abc'})
+ assert(get_err_config({2: 100, 5: 10}, refcfg) == {2: 100})