aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py')
-rw-r--r--yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py108
1 files changed, 103 insertions, 5 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 eb958abef..1f465bde5 100644
--- a/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py
+++ b/yardstick/network_services/libs/ixia_libs/ixnet/ixnet_api.py
@@ -44,6 +44,9 @@ ETHER_TYPE_802_1ad = '0x88a8'
TRAFFIC_STATUS_STARTED = 'started'
TRAFFIC_STATUS_STOPPED = 'stopped'
+PROTOCOL_STATUS_UP = 'up'
+PROTOCOL_STATUS_DOWN = ['down', 'notStarted']
+
SUPPORTED_PROTO = [PROTO_UDP]
@@ -66,6 +69,7 @@ class IxNextgen(object): # pragma: no cover
PORT_STATS_NAME_MAP = {
"stat_name": 'Stat Name',
+ "port_name": 'Port Name',
"Frames_Tx": 'Frames Tx.',
"Valid_Frames_Rx": 'Valid Frames Rx.',
"Frames_Tx_Rate": 'Frames Tx. Rate',
@@ -82,6 +86,18 @@ class IxNextgen(object): # pragma: no cover
"Store-Forward_Max_latency_ns": 'Store-Forward Max Latency (ns)',
}
+ PPPOX_CLIENT_PER_PORT_NAME_MAP = {
+ 'subs_port': 'Port',
+ 'Sessions_Up': 'Sessions Up',
+ 'Sessions_Down': 'Sessions Down',
+ 'Sessions_Not_Started': 'Sessions Not Started',
+ 'Sessions_Total': 'Sessions Total'
+ }
+
+ PORT_STATISTICS = '::ixNet::OBJ-/statistics/view:"Port Statistics"'
+ FLOW_STATISTICS = '::ixNet::OBJ-/statistics/view:"Flow Statistics"'
+ PPPOX_CLIENT_PER_PORT = '::ixNet::OBJ-/statistics/view:"PPPoX Client Per Port"'
+
@staticmethod
def get_config(tg_cfg):
card = []
@@ -177,6 +193,15 @@ class IxNextgen(object): # pragma: no cover
return self.ixnet.getAttribute(self.ixnet.getRoot() + 'traffic',
'-state')
+ def _get_protocol_status(self, proto):
+ """Get protocol status
+
+ :param proto: IxNet protocol str representation, e.g.:
+ '::ixNet::OBJ-/topology:2/deviceGroup:1/ethernet:1/ipv4:L14'
+ :return: (str) protocol status: 'up', 'down' or 'notStarted'
+ """
+ return self.ixnet.getAttribute(proto, '-sessionStatus')[0]
+
def is_traffic_running(self):
"""Returns true if traffic state == TRAFFIC_STATUS_STARTED"""
return self._get_traffic_state() == TRAFFIC_STATUS_STARTED
@@ -185,6 +210,28 @@ class IxNextgen(object): # pragma: no cover
"""Returns true if traffic state == TRAFFIC_STATUS_STOPPED"""
return self._get_traffic_state() == TRAFFIC_STATUS_STOPPED
+ def is_protocols_running(self, protocols):
+ """Returns true if all protocols statuses are PROTOCOL_STATUS_UP
+
+ :param protocols: list of protocols str representations, e.g.:
+ ['::ixNet::OBJ-/topology:2/deviceGroup:1/ethernet:1/ipv4:L14', ...]
+ :return: (bool) True if all protocols status is 'up', False if any
+ protocol status is 'down' or 'notStarted'
+ """
+ return all(self._get_protocol_status(proto) == PROTOCOL_STATUS_UP
+ for proto in protocols)
+
+ def is_protocols_stopped(self, protocols):
+ """Returns true if all protocols statuses are in PROTOCOL_STATUS_DOWN
+
+ :param protocols: list of protocols str representations, e.g.:
+ ['::ixNet::OBJ-/topology:2/deviceGroup:1/ethernet:1/ipv4:L14', ...]
+ :return: (bool) True if all protocols status is 'down' or 'notStarted',
+ False if any protocol status is 'up'
+ """
+ return all(self._get_protocol_status(proto) in PROTOCOL_STATUS_DOWN
+ for proto in protocols)
+
@staticmethod
def _parse_framesize(framesize):
"""Parse "framesize" config param. to return a list of weighted pairs
@@ -657,6 +704,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
@@ -666,12 +746,30 @@ class IxNextgen(object): # pragma: no cover
:return: dictionary with the statistics; the keys of this dictionary
are PORT_STATS_NAME_MAP and LATENCY_NAME_MAP keys.
"""
- port_statistics = '::ixNet::OBJ-/statistics/view:"Port Statistics"'
- flow_statistics = '::ixNet::OBJ-/statistics/view:"Flow Statistics"'
- stats = self._build_stats_map(port_statistics,
+ stats = self._build_stats_map(self.PORT_STATISTICS,
+ self.PORT_STATS_NAME_MAP)
+ stats.update(self._build_stats_map(self.FLOW_STATISTICS,
+ self.LATENCY_NAME_MAP))
+ return stats
+
+ def get_pppoe_scenario_statistics(self):
+ """Retrieve port, flow and PPPoE subscribers statistics
+
+ "Port Statistics" parameters are stored in self.PORT_STATS_NAME_MAP.
+ "Flow Statistics" parameters are stored in self.LATENCY_NAME_MAP.
+ "PPPoX Client Per Port" parameters are stored in
+ self.PPPOE_CLIENT_PER_PORT_NAME_MAP
+
+ :return: dictionary with the statistics; the keys of this dictionary
+ are PORT_STATS_NAME_MAP, LATENCY_NAME_MAP and
+ PPPOE_CLIENT_PER_PORT_NAME_MAP keys.
+ """
+ stats = self._build_stats_map(self.PORT_STATISTICS,
self.PORT_STATS_NAME_MAP)
- stats.update(self._build_stats_map(flow_statistics,
- self.LATENCY_NAME_MAP))
+ stats.update(self._build_stats_map(self.FLOW_STATISTICS,
+ self.LATENCY_NAME_MAP))
+ stats.update(self._build_stats_map(self.PPPOX_CLIENT_PER_PORT,
+ self.PPPOX_CLIENT_PER_PORT_NAME_MAP))
return stats
def start_protocols(self):