diff options
author | Deepak S <deepak.s@linux.intel.com> | 2017-09-26 02:40:56 -0700 |
---|---|---|
committer | Ross Brattain <ross.b.brattain@intel.com> | 2017-09-30 01:23:07 -0700 |
commit | 8aaa7d27cd491e8a78421ffcf0af01e6101a0bf4 (patch) | |
tree | 75587038eb443aced7071cb970de17730e932ae2 /yardstick/network_services/traffic_profile | |
parent | 139480d2265d23729162054812988b0d9eca94d9 (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/traffic_profile')
-rw-r--r-- | yardstick/network_services/traffic_profile/ixia_rfc2544.py | 91 |
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): |