summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAbhijit Sinha <abhijit.sinha@intel.com>2018-11-01 13:31:52 +0000
committerGerrit Code Review <gerrit@opnfv.org>2018-11-01 13:31:52 +0000
commit61942da1ebc55893a139d34ae03244a2e776fcbd (patch)
tree2d80448ae62a8c214e0f5d235d612b08bcf9caf0
parent8c02887dd246870b8b8fbffe67cfef0f4548ee73 (diff)
parentde0843e22ff93762f9aea47746bbf40780515b1c (diff)
Merge "Add IxNextgen API for setting tracking options"
-rw-r--r--yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py33
-rw-r--r--yardstick/tests/unit/network_services/libs/ixia_libs/test_ixnet_api.py20
2 files changed, 53 insertions, 0 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 017b4b66d..556682b29 100644
--- a/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py
+++ b/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py
@@ -639,6 +639,39 @@ class IxNextgen(object): # pragma: no cover
'getColumnValues', view_obj, data_ixia)
for data_yardstick, data_ixia in name_map.items()}
+ def _set_egress_flow_tracking(self, encapsulation, offset):
+ """Set egress flow tracking options
+
+ :param encapsulation: encapsulation type
+ :type encapsulation: str, e.g. 'Ethernet'
+ :param offset: offset type
+ :type offset: str, e.g. 'IPv4 TOS Precedence (3 bits)'
+ """
+ traffic_item = self.ixnet.getList(self.ixnet.getRoot() + '/traffic',
+ 'trafficItem')[0]
+ # Enable Egress Tracking
+ self.ixnet.setAttribute(traffic_item, '-egressEnabled', True)
+ self.ixnet.commit()
+
+ # Set encapsulation type
+ enc_obj = self.ixnet.getList(traffic_item, 'egressTracking')[0]
+ self.ixnet.setAttribute(enc_obj, '-encapsulation', encapsulation)
+
+ # Set offset
+ self.ixnet.setAttribute(enc_obj, '-offset', offset)
+ self.ixnet.commit()
+
+ def _set_flow_tracking(self, track_by):
+ """Set flow tracking options
+
+ :param track_by: list of tracking fields
+ :type track_by: list, e.g. ['vlanVlanId0','ipv4Precedence0']
+ """
+ traffic_item = self.ixnet.getList(self.ixnet.getRoot() + '/traffic',
+ 'trafficItem')[0]
+ self.ixnet.setAttribute(traffic_item + '/tracking', '-trackBy', track_by)
+ self.ixnet.commit()
+
def get_statistics(self):
"""Retrieve port and flow statistics
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 821da32ed..c80cbbe77 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
@@ -592,6 +592,26 @@ class TestIxNextgen(unittest.TestCase):
mock.call(port_statistics, self.ixnet_gen.PORT_STATS_NAME_MAP),
mock.call(flow_statistics, self.ixnet_gen.LATENCY_NAME_MAP)])
+ def test__set_flow_tracking(self):
+ self.ixnet_gen._ixnet.getList.return_value = ['traffic_item']
+ self.ixnet_gen._set_flow_tracking(track_by=['vlanVlanId0'])
+ self.ixnet_gen.ixnet.setAttribute.assert_called_once_with(
+ 'traffic_item/tracking', '-trackBy', ['vlanVlanId0'])
+ self.assertEqual(self.ixnet.commit.call_count, 1)
+
+ def test__set_egress_flow_tracking(self):
+ self.ixnet_gen._ixnet.getList.side_effect = [['traffic_item'],
+ ['encapsulation']]
+ self.ixnet_gen._set_egress_flow_tracking(encapsulation='Ethernet',
+ offset='IPv4 TOS Precedence')
+ self.ixnet_gen.ixnet.setAttribute.assert_any_call(
+ 'traffic_item', '-egressEnabled', True)
+ self.ixnet_gen.ixnet.setAttribute.assert_any_call(
+ 'encapsulation', '-encapsulation', 'Ethernet')
+ self.ixnet_gen.ixnet.setAttribute.assert_any_call(
+ 'encapsulation', '-offset', 'IPv4 TOS Precedence')
+ self.assertEqual(self.ixnet.commit.call_count, 2)
+
def test__update_ipv4_address(self):
with mock.patch.object(self.ixnet_gen, '_get_field_in_stack_item',
return_value='field_desc'):