aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/network_services/traffic_profile/ixia_rfc2544.py
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/network_services/traffic_profile/ixia_rfc2544.py')
-rw-r--r--yardstick/network_services/traffic_profile/ixia_rfc2544.py91
1 files changed, 45 insertions, 46 deletions
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):