aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/scenarios/networking
diff options
context:
space:
mode:
authorDeepak S <deepak.s@linux.intel.com>2017-08-13 19:15:55 -0700
committerRoss Brattain <ross.b.brattain@intel.com>2017-08-21 19:36:41 -0700
commit952defd326974e7ae74ce366c6b5d32793d8d70c (patch)
tree4fb1d20e9a43ddc27e1d841b289162b4e10b8ef8 /yardstick/benchmark/scenarios/networking
parent4de16cbc3c7a4e03542c6256f3aeda79dbf49b62 (diff)
Re-define the framesize and flow dynamic define in testcase
This patch adds the framesize and flow into test option instead of adding a seperate file to avoid the multiple file update incase of ip change. Change-Id: Ic473c73773ad36422ecc02618b8c646a5336b70a Signed-off-by: Deepak S <deepak.s@linux.intel.com>
Diffstat (limited to 'yardstick/benchmark/scenarios/networking')
-rw-r--r--yardstick/benchmark/scenarios/networking/vnf_generic.py49
1 files changed, 42 insertions, 7 deletions
diff --git a/yardstick/benchmark/scenarios/networking/vnf_generic.py b/yardstick/benchmark/scenarios/networking/vnf_generic.py
index 9f8efa6dc..55fdadea8 100644
--- a/yardstick/benchmark/scenarios/networking/vnf_generic.py
+++ b/yardstick/benchmark/scenarios/networking/vnf_generic.py
@@ -17,10 +17,14 @@ from __future__ import absolute_import
import logging
import errno
+
+import ipaddress
import os
import re
from itertools import chain
+
+import six
from operator import itemgetter
from collections import defaultdict
@@ -126,19 +130,50 @@ class NetworkServiceTestCase(base.Scenario):
self.collector = None
self.traffic_profile = None
+ def _get_ip_flow_range(self, ip_start_range):
+
+ node_name, range_or_interface = next(iter(ip_start_range.items()), (None, '0.0.0.0'))
+ if node_name is not None:
+ node = self.context_cfg["nodes"].get(node_name, {})
+ try:
+ # the ip_range is the interface name
+ interface = node.get("interfaces", {})[range_or_interface]
+ except KeyError:
+ ip = "0.0.0.0"
+ mask = "255.255.255.0"
+ else:
+ ip = interface["local_ip"]
+ # we can't default these values, they must both exist to be valid
+ mask = interface["netmask"]
+
+ ipaddr = ipaddress.ip_network(six.text_type('{}/{}'.format(ip, mask)), strict=False)
+ hosts = list(ipaddr.hosts())
+ ip_addr_range = "{}-{}".format(hosts[0], hosts[-1])
+ else:
+ # we are manually specifying the range
+ ip_addr_range = range_or_interface
+ return ip_addr_range
+
def _get_traffic_flow(self):
+ flow = {}
try:
- with open(self.scenario_cfg["traffic_options"]["flow"]) as fflow:
- flow = yaml_load(fflow)
- except (KeyError, IOError, OSError):
+ fflow = self.scenario_cfg["options"]["flow"]
+ for index, src in enumerate(fflow.get("src_ip", [])):
+ flow["src_ip{}".format(index)] = self._get_ip_flow_range(src)
+
+ for index, dst in enumerate(fflow.get("dst_ip", [])):
+ flow["dst_ip{}".format(index)] = self._get_ip_flow_range(dst)
+
+ for index, publicip in enumerate(fflow.get("publicip", [])):
+ flow["public_ip{}".format(index)] = publicip
+ except KeyError:
flow = {}
- return flow
+ return {"flow": flow}
def _get_traffic_imix(self):
try:
- with open(self.scenario_cfg["traffic_options"]["imix"]) as fimix:
- imix = yaml_load(fimix)
- except (KeyError, IOError, OSError):
+ imix = {"imix": self.scenario_cfg['options']['framesize']}
+ except KeyError:
imix = {}
return imix