diff options
-rw-r--r-- | yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py | 33 | ||||
-rw-r--r-- | yardstick/tests/unit/network_services/libs/ixia_libs/test_ixnet_api.py | 20 |
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 d4f75babb..8b69a8848 100644 --- a/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py +++ b/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py @@ -608,6 +608,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 66fed81f1..2179a7d46 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'): |