From: Martin Klozik Date: Thu, 18 Jan 2018 15:22:42 +0000 (+0000) Subject: ixia: Add support of LISTs in TRAFFIC X-Git-Tag: opnfv-6.0.0~27 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F79%2F50779%2F1;p=vswitchperf.git ixia: Add support of LISTs in TRAFFIC The control script for Ixia (i.e. Ixia and IxNet classes) is written in TCL and thus VSPERF must translate TRAFFIC dictionary into TCL notation. The method for data type conversion was updated to correctly process new 'capture' settings, which uses python lists for tx and rx capture ports definition. JIRA: VSPERF-556 Change-Id: I639942b11ea11ce1b443a2a2e99c3da6619ba569 Signed-off-by: Martin Klozik Reviewed-by: Al Morton Reviewed-by: Christian Trautman Reviewed-by: Sridhar Rao Reviewed-by: Trevor Cooper Reviewed-by: Richard Elias --- diff --git a/tools/pkt_gen/ixia/ixia.py b/tools/pkt_gen/ixia/ixia.py index e768be06..d4ca56f2 100755 --- a/tools/pkt_gen/ixia/ixia.py +++ b/tools/pkt_gen/ixia/ixia.py @@ -111,6 +111,11 @@ def _build_set_cmds(values, prefix='dict set'): yield subkey continue + if isinstance(value, list): + value = '{{{}}}'.format(' '.join(str(x) for x in value)) + yield ' '.join([prefix, 'set', key, value]).strip() + continue + # tcl doesn't recognise the strings "True" or "False", only "1" # or "0". Special case to convert them if isinstance(value, bool): @@ -118,6 +123,9 @@ def _build_set_cmds(values, prefix='dict set'): else: value = str(value) + if isinstance(value, str) and not value: + value = '{}' + if prefix: yield ' '.join([prefix, key, value]).strip() else: diff --git a/tools/pkt_gen/ixnet/ixnet.py b/tools/pkt_gen/ixnet/ixnet.py index b8fb1879..d1ba9096 100755 --- a/tools/pkt_gen/ixnet/ixnet.py +++ b/tools/pkt_gen/ixnet/ixnet.py @@ -127,6 +127,11 @@ def _build_set_cmds(values, prefix='dict set'): yield subkey continue + if isinstance(value, list): + value = '{{{}}}'.format(' '.join(str(x) for x in value)) + yield ' '.join([prefix, 'set', key, value]).strip() + continue + # tcl doesn't recognise the strings "True" or "False", only "1" # or "0". Special case to convert them if isinstance(value, bool): @@ -134,6 +139,9 @@ def _build_set_cmds(values, prefix='dict set'): else: value = str(value) + if isinstance(value, str) and not value: + value = '{}' + if prefix: yield ' '.join([prefix, key, value]).strip() else: