aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/network_services
diff options
context:
space:
mode:
authorDeepak S <deepak.s@linux.intel.com>2017-09-26 02:40:56 -0700
committerRoss Brattain <ross.b.brattain@intel.com>2017-09-29 16:41:26 -0700
commit2a02457c7b4d43e6a3d9d513023bc312a0a96ba9 (patch)
treef0afc4aa6e2eea4669f5d09eaacdff280d981c3b /yardstick/network_services
parent263a946240819fe37b19271251c288450490c58a (diff)
Auto create ixia config based on the traffic profile
Change-Id: I031cc7f24f0c0816eb577a4d1606a714f68a5f83 Signed-off-by: Deepak S <deepak.s@linux.intel.com> Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
Diffstat (limited to 'yardstick/network_services')
-rw-r--r--yardstick/network_services/libs/ixia_libs/IxNet/IxNet.py6
-rw-r--r--yardstick/network_services/traffic_profile/ixia_rfc2544.py91
-rw-r--r--yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py36
3 files changed, 61 insertions, 72 deletions
diff --git a/yardstick/network_services/libs/ixia_libs/IxNet/IxNet.py b/yardstick/network_services/libs/ixia_libs/IxNet/IxNet.py
index 358e6e761..70ce4ff03 100644
--- a/yardstick/network_services/libs/ixia_libs/IxNet/IxNet.py
+++ b/yardstick/network_services/libs/ixia_libs/IxNet/IxNet.py
@@ -254,8 +254,10 @@ class IxNextgen(object):
helper = TrafficStreamHelper(traffic_item, stream, param_id)
self.ixnet.setMultiAttribute(helper.transmissionControl,
- '-type', '{0}'.format(param['traffic_type']),
- '-duration', '{0}'.format(param['duration']))
+ '-type', '{0}'.format(param.get('traffic_type',
+ 'continuous')),
+ '-duration', '{0}'.format(param.get('duration',
+ "30")))
stream_frame_rate_path = helper.frameRate
self.ixnet.setMultiAttribute(stream_frame_rate_path, '-rate', param['iload'])
diff --git a/yardstick/network_services/traffic_profile/ixia_rfc2544.py b/yardstick/network_services/traffic_profile/ixia_rfc2544.py
index 28480b8e9..53a99bf0b 100644
--- a/yardstick/network_services/traffic_profile/ixia_rfc2544.py
+++ b/yardstick/network_services/traffic_profile/ixia_rfc2544.py
@@ -14,7 +14,6 @@
from __future__ import absolute_import
import logging
-import json
from yardstick.network_services.traffic_profile.traffic_profile import \
TrexProfile
@@ -24,60 +23,60 @@ LOG = logging.getLogger(__name__)
class IXIARFC2544Profile(TrexProfile):
+ UPLINK = 'uplink'
+ DOWNLINK = 'downlink'
+
def _get_ixia_traffic_profile(self, profile_data, mac=None, xfile=None, static_traffic=None):
if mac is None:
mac = {}
- if static_traffic is None:
- static_traffic = {}
-
result = {}
- if xfile:
- with open(xfile) as stream:
- try:
- static_traffic = json.load(stream)
- except Exception as exc:
- LOG.debug(exc)
-
- for traffickey, trafficvalue in static_traffic.items():
- traffic = static_traffic[traffickey]
- # outer_l2
- index = 0
+ for traffickey, values in profile_data.items():
+ if not traffickey.startswith((self.UPLINK, self.DOWNLINK)):
+ continue
+
try:
- for key, value in profile_data[traffickey].items():
- framesize = value['outer_l2']['framesize']
- traffic['outer_l2']['framesize'] = framesize
- traffic['framesPerSecond'] = True
- traffic['bidir'] = False
- traffic['outer_l2']['srcmac'] = \
- mac["src_mac_{}".format(traffic['id'])]
- traffic['outer_l2']['dstmac'] = \
- mac["dst_mac_{}".format(traffic['id'])]
-
- # outer_l3
- if "outer_l3v6" in list(value.keys()):
- traffic['outer_l3'] = value['outer_l3v6']
- srcip4 = value['outer_l3v6']['srcip6']
- traffic['outer_l3']['srcip4'] = srcip4.split("-")[0]
- dstip4 = value['outer_l3v6']['dstip6']
- traffic['outer_l3']['dstip4'] = dstip4.split("-")[0]
- else:
- traffic['outer_l3'] = value['outer_l3v4']
- srcip4 = value['outer_l3v4']['srcip4']
- traffic['outer_l3']['srcip4'] = srcip4.split("-")[0]
- dstip4 = value['outer_l3v4']['dstip4']
- traffic['outer_l3']['dstip4'] = dstip4.split("-")[0]
-
- traffic['outer_l3']['type'] = key
- traffic['outer_l3']['count'] = value['outer_l3v4']['count']
- # outer_l4
- traffic['outer_l4'] = value['outer_l4']
- index = index + 1
+ # values should be single-item dict, so just grab the first item
+ try:
+ key, value = next(iter(values.items()))
+ except StopIteration:
+ result[traffickey] = {}
+ continue
+
+ port_id = value.get('id', 1)
+ port_index = port_id - 1
+ try:
+ ip = value['outer_l3v6']
+ except KeyError:
+ ip = value['outer_l3v4']
+ src_key, dst_key = 'srcip4', 'dstip4'
+ else:
+ src_key, dst_key = 'srcip6', 'dstip6'
+
+ result[traffickey] = {
+ 'bidir': False,
+ 'iload': '100',
+ 'id': port_id,
+ 'outer_l2': {
+ 'framesize': value['outer_l2']['framesize'],
+ 'framesPerSecond': True,
+ 'srcmac': mac['src_mac_{}'.format(port_index)],
+ 'dstmac': mac['dst_mac_{}'.format(port_index)],
+ },
+ 'outer_l3': {
+ 'count': ip['count'],
+ 'dscp': ip['dscp'],
+ 'ttl': ip['ttl'],
+ src_key: ip[src_key],
+ dst_key: ip[dst_key],
+ 'type': key,
+ 'proto': ip['proto'],
+ },
+ 'outer_l4': value['outer_l4'],
+ }
except Exception:
continue
- result.update({traffickey: traffic})
-
return result
def _ixia_traffic_generate(self, traffic_generator, traffic, ixia_obj):
diff --git a/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py b/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py
index 22aaf6dfb..47c5a35d9 100644
--- a/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py
+++ b/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py
@@ -14,7 +14,6 @@
from __future__ import absolute_import
-import json
import time
import os
import logging
@@ -130,39 +129,28 @@ class IxiaResourceHelper(ClientResourceHelper):
self.client.ix_assign_ports()
- ixia_file = find_relative_file("ixia_traffic.cfg",
- self.scenario_helper.scenario_cfg["task_path"])
-
- static_traffic = {}
- with open(ixia_file) as stream:
- try:
- static_traffic = json.load(stream)
- except Exception:
- LOG.exception("")
mac = {}
- for vld_id, traffic in static_traffic.items():
- intfs = self.vnfd_helper.port_pairs.networks.get(vld_id, [])
- interface = next(iter(intfs), None)
- if interface:
- virt_intf = self.vnfd_helper.find_interface(name=interface)["virtual-interface"]
- # we only know static traffic id by reading the json
- # this is used by _get_ixia_traffic_profile
- mac["src_mac_{}".format(traffic["id"])] = virt_intf.get("local_mac", default)
- mac["dst_mac_{}".format(traffic["id"])] = virt_intf.get("dst_mac", default)
+ for port_name in self.vnfd_helper.port_pairs.all_ports:
+ intf = self.vnfd_helper.find_interface(name=port_name)
+ virt_intf = intf["virtual-interface"]
+ # we only know static traffic id by reading the json
+ # this is used by _get_ixia_trafficrofile
+ port_num = self.vnfd_helper.port_num(intf)
+ mac["src_mac_{}".format(port_num)] = virt_intf.get("local_mac", default)
+ mac["dst_mac_{}".format(port_num)] = virt_intf.get("dst_mac", default)
samples = {}
# Generate ixia traffic config...
try:
while not self._terminated.value:
- traffic_profile.execute_traffic(self, self.client, mac, ixia_file)
+ traffic_profile.execute_traffic(self, self.client, mac)
self.client_started.value = 1
time.sleep(WAIT_FOR_TRAFFIC)
self.client.ix_stop_traffic()
samples = self.generate_samples(traffic_profile.ports)
self._queue.put(samples)
status, samples = traffic_profile.get_drop_percentage(self, samples, min_tol,
- max_tol, self.client, mac,
- ixia_file)
+ max_tol, self.client, mac)
current = samples['CurrentDropPercentage']
if min_tol <= current <= max_tol or status == 'Completed':
@@ -175,13 +163,13 @@ class IxiaResourceHelper(ClientResourceHelper):
self._terminated.value = 1
return
- traffic_profile.execute_traffic(self, self.client, mac, ixia_file)
+ traffic_profile.execute_traffic(self, self.client, mac)
for _ in range(5):
time.sleep(self.LATENCY_TIME_SLEEP)
self.client.ix_stop_traffic()
samples = self.generate_samples(traffic_profile.ports, 'latency', {})
self._queue.put(samples)
- traffic_profile.start_ixia_latency(self, self.client, mac, ixia_file)
+ traffic_profile.start_ixia_latency(self, self.client, mac)
if self._terminated.value:
break