aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAbhijit Sinha <abhijit.sinha@intel.com>2018-10-12 15:16:55 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-10-12 15:16:55 +0000
commit26fa6904c58b9f748507876db1bdae2b864268e6 (patch)
treec8474c1c071948e5c4ceef3769389258a36e27dc
parent2f3b65755d896fc9b7a7b248ba4de550696b1a6e (diff)
parent55cac65a67e463b565ee4f55d7d73f5d171f916e (diff)
Merge "Modify handling Ixia traffic profile parameters"
-rw-r--r--yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py85
-rw-r--r--yardstick/network_services/traffic_profile/ixia_rfc2544.py133
-rw-r--r--yardstick/tests/unit/network_services/libs/ixia_libs/test_ixnet_api.py3
3 files changed, 127 insertions, 94 deletions
diff --git a/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py b/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py
index feff32156..d4f75babb 100644
--- a/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py
+++ b/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py
@@ -406,16 +406,15 @@ class IxNextgen(object): # pragma: no cover
raise exceptions.IxNetworkFlowNotPresent(flow_group=fg_id)
type = traffic_param.get('traffic_type', 'fixedDuration')
- rate = traffic_param['rate']
rate_unit = (
'framesPerSecond' if traffic_param['rate_unit'] ==
tp_base.TrafficProfileConfig.RATE_FPS else 'percentLineRate')
weighted_range_pairs = self._parse_framesize(
- traffic_param['outer_l2']['framesize'])
+ traffic_param['outer_l2'].get('framesize', {}))
srcmac = str(traffic_param['outer_l2'].get('srcmac', '00:00:00:00:00:01'))
dstmac = str(traffic_param['outer_l2'].get('dstmac', '00:00:00:00:00:02'))
- if traffic_param['outer_l2']['QinQ']:
+ if traffic_param['outer_l2'].get('QinQ'):
s_vlan = traffic_param['outer_l2']['QinQ']['S-VLAN']
c_vlan = traffic_param['outer_l2']['QinQ']['C-VLAN']
@@ -440,21 +439,27 @@ class IxNextgen(object): # pragma: no cover
self.ixnet.setMultiAttribute(
config_element + '/transmissionControl',
'-type', type, '-duration', duration)
+
self.ixnet.setMultiAttribute(
config_element + '/frameRate',
- '-rate', rate, '-type', rate_unit)
- self.ixnet.setMultiAttribute(
- config_element + '/frameSize',
- '-type', 'weightedPairs',
- '-weightedRangePairs', weighted_range_pairs)
+ '-rate', traffic_param['rate'], '-type', rate_unit)
+
+ if len(weighted_range_pairs):
+ self.ixnet.setMultiAttribute(
+ config_element + '/frameSize',
+ '-type', 'weightedPairs',
+ '-weightedRangePairs', weighted_range_pairs)
+
self.ixnet.commit()
- self._update_frame_mac(
- self._get_stack_item(fg_id, PROTO_ETHERNET)[0],
- 'destinationAddress', dstmac)
- self._update_frame_mac(
- self._get_stack_item(fg_id, PROTO_ETHERNET)[0],
- 'sourceAddress', srcmac)
+ if dstmac:
+ self._update_frame_mac(
+ self._get_stack_item(fg_id, PROTO_ETHERNET)[0],
+ 'destinationAddress', dstmac)
+ if srcmac:
+ self._update_frame_mac(
+ self._get_stack_item(fg_id, PROTO_ETHERNET)[0],
+ 'sourceAddress', srcmac)
def _update_vlan_tag(self, fg_id, params, vlan=0):
field_to_param_map = {
@@ -514,20 +519,24 @@ class IxNextgen(object): # pragma: no cover
if not self._get_config_element_by_flow_group_name(fg_id):
raise exceptions.IxNetworkFlowNotPresent(flow_group=fg_id)
- count = traffic_param['outer_l3']['count']
- srcip = str(traffic_param['outer_l3']['srcip'])
- dstip = str(traffic_param['outer_l3']['dstip'])
- srcseed = traffic_param['outer_l3']['srcseed']
- dstseed = traffic_param['outer_l3']['dstseed']
- srcmask = traffic_param['outer_l3']['srcmask'] or IP_VERSION_4_MASK
- dstmask = traffic_param['outer_l3']['dstmask'] or IP_VERSION_4_MASK
-
- self._update_ipv4_address(
- self._get_stack_item(fg_id, PROTO_IPV4)[0],
- 'srcIp', srcip, srcseed, srcmask, count)
- self._update_ipv4_address(
- self._get_stack_item(fg_id, PROTO_IPV4)[0],
- 'dstIp', dstip, dstseed, dstmask, count)
+ if traffic_param['outer_l3']:
+ count = traffic_param['outer_l3']['count']
+ srcip = traffic_param['outer_l3']['srcip']
+ dstip = traffic_param['outer_l3']['dstip']
+ srcseed = traffic_param['outer_l3']['srcseed']
+ dstseed = traffic_param['outer_l3']['dstseed']
+ srcmask = traffic_param['outer_l3']['srcmask'] \
+ or IP_VERSION_4_MASK
+ dstmask = traffic_param['outer_l3']['dstmask'] \
+ or IP_VERSION_4_MASK
+ if srcip:
+ self._update_ipv4_address(
+ self._get_stack_item(fg_id, PROTO_IPV4)[0],
+ 'srcIp', str(srcip), srcseed, srcmask, count)
+ if dstip:
+ self._update_ipv4_address(
+ self._get_stack_item(fg_id, PROTO_IPV4)[0],
+ 'dstIp', str(dstip), dstseed, dstmask, count)
def update_l4(self, traffic):
"""Update the L4 headers
@@ -541,7 +550,10 @@ class IxNextgen(object): # pragma: no cover
if not self._get_config_element_by_flow_group_name(fg_id):
raise exceptions.IxNetworkFlowNotPresent(flow_group=fg_id)
- proto = traffic_param['outer_l3']['proto']
+ proto = traffic_param['outer_l3'].get('proto')
+ if not (proto and traffic_param['outer_l4']):
+ continue
+
if proto not in SUPPORTED_PROTO:
raise exceptions.IXIAUnsupportedProtocol(protocol=proto)
@@ -554,12 +566,15 @@ class IxNextgen(object): # pragma: no cover
dstport = traffic_param['outer_l4']['dstport']
dstmask = traffic_param['outer_l4']['dstportmask']
- if proto in SUPPORTED_PROTO:
- self._update_udp_port(self._get_stack_item(fg_id, proto)[0],
- 'srcPort', srcport, seed, srcmask, count)
-
- self._update_udp_port(self._get_stack_item(fg_id, proto)[0],
- 'dstPort', dstport, seed, dstmask, count)
+ if proto == PROTO_UDP:
+ if srcport:
+ self._update_udp_port(
+ self._get_stack_item(fg_id, proto)[0],
+ 'srcPort', srcport, seed, srcmask, count)
+ if dstport:
+ self._update_udp_port(
+ self._get_stack_item(fg_id, proto)[0],
+ 'dstPort', dstport, seed, dstmask, count)
def _update_udp_port(self, descriptor, field, value,
seed=1, mask=0, count=1):
diff --git a/yardstick/network_services/traffic_profile/ixia_rfc2544.py b/yardstick/network_services/traffic_profile/ixia_rfc2544.py
index 44bf2eafc..b8aa78d80 100644
--- a/yardstick/network_services/traffic_profile/ixia_rfc2544.py
+++ b/yardstick/network_services/traffic_profile/ixia_rfc2544.py
@@ -56,68 +56,83 @@ class IXIARFC2544Profile(trex_traffic_profile.TrexProfile):
if not traffickey.startswith((self.UPLINK, self.DOWNLINK)):
continue
+ # values should be single-item dict, so just grab the first item
try:
- # 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
-
- if value.get('outer_l3v4'):
- ip = value['outer_l3v4']
- src_key, dst_key = 'srcip4', 'dstip4'
- else:
- ip = value['outer_l3v6']
- src_key, dst_key = 'srcip6', 'dstip6'
-
- srcip, srcmask = self._get_ip_and_mask(ip[src_key])
- dstip, dstmask = self._get_ip_and_mask(ip[dst_key])
-
- outer_l4 = value.get('outer_l4')
- src_port, src_port_mask = self._get_fixed_and_mask(outer_l4['srcport'])
- dst_port, dst_port_mask = self._get_fixed_and_mask(outer_l4['dstport'])
- result[traffickey] = {
- 'bidir': False,
- 'id': port_id,
- 'rate': self.rate,
- 'rate_unit': self.rate_unit,
- 'outer_l2': {
- 'framesize': value['outer_l2']['framesize'],
- 'framesPerSecond': True,
- 'QinQ': value['outer_l2'].get('QinQ'),
- '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'],
- 'srcseed': ip.get('srcseed', 1),
- 'dstseed': ip.get('dstseed', 1),
- 'srcip': srcip,
- 'dstip': dstip,
- 'srcmask': srcmask,
- 'dstmask': dstmask,
- 'type': key,
- 'proto': ip['proto'],
- },
- 'outer_l4': {
- 'srcport': src_port,
- 'dstport': dst_port,
- 'srcportmask': src_port_mask,
- 'dstportmask': dst_port_mask,
- 'count': outer_l4['count'],
- 'seed': outer_l4.get('seed', 1)
- }
-
- }
- except KeyError:
+ key, value = next(iter(values.items()))
+ except StopIteration:
+ result[traffickey] = {}
continue
+ port_id = value.get('id', 1)
+ port_index = port_id - 1
+
+ result[traffickey] = {
+ 'bidir': False,
+ 'id': port_id,
+ 'rate': self.rate,
+ 'rate_unit': self.rate_unit,
+ 'outer_l2': {},
+ 'outer_l3': {},
+ 'outer_l4': {},
+ }
+
+ outer_l2 = value.get('outer_l2')
+ if outer_l2:
+ result[traffickey]['outer_l2'].update({
+ 'framesize': outer_l2.get('framesize'),
+ 'framesPerSecond': True,
+ 'QinQ': outer_l2.get('QinQ'),
+ 'srcmac': mac.get('src_mac_{}'.format(port_index)),
+ 'dstmac': mac.get('dst_mac_{}'.format(port_index)),
+ })
+
+ if value.get('outer_l3v4'):
+ outer_l3 = value['outer_l3v4']
+ src_key, dst_key = 'srcip4', 'dstip4'
+ else:
+ outer_l3 = value.get('outer_l3v6')
+ src_key, dst_key = 'srcip6', 'dstip6'
+ if outer_l3:
+ srcip = srcmask = dstip = dstmask = None
+ if outer_l3.get(src_key):
+ srcip, srcmask = self._get_ip_and_mask(outer_l3[src_key])
+ if outer_l3.get(dst_key):
+ dstip, dstmask = self._get_ip_and_mask(outer_l3[dst_key])
+
+ result[traffickey]['outer_l3'].update({
+ 'count': outer_l3.get('count', 1),
+ 'dscp': outer_l3.get('dscp'),
+ 'ttl': outer_l3.get('ttl'),
+ 'srcseed': outer_l3.get('srcseed', 1),
+ 'dstseed': outer_l3.get('dstseed', 1),
+ 'srcip': srcip,
+ 'dstip': dstip,
+ 'srcmask': srcmask,
+ 'dstmask': dstmask,
+ 'type': key,
+ 'proto': outer_l3.get('proto'),
+ })
+
+ outer_l4 = value.get('outer_l4')
+ if outer_l4:
+ src_port = src_port_mask = dst_port = dst_port_mask = None
+ if outer_l4.get('srcport'):
+ src_port, src_port_mask = (
+ self._get_fixed_and_mask(outer_l4['srcport']))
+
+ if outer_l4.get('dstport'):
+ dst_port, dst_port_mask = (
+ self._get_fixed_and_mask(outer_l4['dstport']))
+
+ result[traffickey]['outer_l4'].update({
+ 'srcport': src_port,
+ 'dstport': dst_port,
+ 'srcportmask': src_port_mask,
+ 'dstportmask': dst_port_mask,
+ 'count': outer_l4.get('count', 1),
+ 'seed': outer_l4.get('seed', 1),
+ })
+
return result
def _ixia_traffic_generate(self, traffic, ixia_obj):
diff --git a/yardstick/tests/unit/network_services/libs/ixia_libs/test_ixnet_api.py b/yardstick/tests/unit/network_services/libs/ixia_libs/test_ixnet_api.py
index dd66f5fd0..66fed81f1 100644
--- a/yardstick/tests/unit/network_services/libs/ixia_libs/test_ixnet_api.py
+++ b/yardstick/tests/unit/network_services/libs/ixia_libs/test_ixnet_api.py
@@ -658,6 +658,9 @@ class TestIxNextgen(unittest.TestCase):
'outer_l3': {
'proto': 'unsupported',
},
+ 'outer_l4': {
+ 'seed': 1
+ }
},
}
with mock.patch.object(self.ixnet_gen,