diff options
author | Dan Klein <danklei@cisco.com> | 2015-09-20 23:56:04 +0300 |
---|---|---|
committer | Dan Klein <danklei@cisco.com> | 2015-09-20 23:56:04 +0300 |
commit | 20a7b8ed2a75debc3f2015d571fb4faf2cfc8b13 (patch) | |
tree | 11adec3abcb59b6126fcfd96e78b17c0777154a8 /scripts/automation | |
parent | 29de5a33617b44c79982670a984ba46ec0e3a8d8 (diff) |
minor updated to client API library, adding the CRxStats class
Diffstat (limited to 'scripts/automation')
-rw-r--r-- | scripts/automation/trex_control_plane/client/trex_stateless_client.py | 46 | ||||
-rw-r--r-- | scripts/automation/trex_control_plane/client_utils/packet_builder.py | 1 |
2 files changed, 43 insertions, 4 deletions
diff --git a/scripts/automation/trex_control_plane/client/trex_stateless_client.py b/scripts/automation/trex_control_plane/client/trex_stateless_client.py index 5513f420..a2c148ce 100644 --- a/scripts/automation/trex_control_plane/client/trex_stateless_client.py +++ b/scripts/automation/trex_control_plane/client/trex_stateless_client.py @@ -7,7 +7,8 @@ except ImportError: # support import for Python 3 import client.outer_packages from client_utils.jsonrpc_client import JsonRpcClient - +from client_utils.packet_builder import CTRexPktBuilder +import json class CTRexStatelessClient(object): @@ -16,11 +17,50 @@ class CTRexStatelessClient(object): super(CTRexStatelessClient, self).__init__() self.tx_link = CTRexStatelessClient.CTxLink(server, port, virtual) + def add_stream(self): + pass - def transmit(self, method_name, params = {}): + def transmit(self, method_name, params={}): return self.tx_link.transmit(method_name, params) + # ------ private classes ------ # + class CRxStats(object): + + def __init__(self, enabled=False, seq_enabled=False, latency_enabled=False): + self._rx_dict = {"enabled" : enabled, + "seq_enabled" : seq_enabled, + "latency_enabled" : latency_enabled} + + @property + def enabled(self): + return self._rx_dict.get("enabled") + + @enabled.setter + def enabled(self, bool_value): + self._rx_dict['enabled'] = bool_value + + @property + def seq_enabled(self): + return self._rx_dict.get("seq_enabled") + + @seq_enabled.setter + def seq_enabled(self, bool_value): + self._rx_dict['seq_enabled'] = bool_value + + @property + def latency_enabled(self): + return self._rx_dict.get("latency_enabled") + + @latency_enabled.setter + def latency_enabled(self, bool_value): + self._rx_dict['latency_enabled'] = bool_value + + def dump(self): + return json.dumps({i:self._rx_dict.get(i) + for i in self._rx_dict.keys() + if self._rx_dict.get(i) + }) class CTxLink(object): """describes the connectivity of the stateless client method""" @@ -33,7 +73,7 @@ class CTRexStatelessClient(object): if not self.virtual: self.rpc_link.connect() - def transmit(self, method_name, params = {}): + def transmit(self, method_name, params={}): if self.virtual: print "Transmitting virtually over tcp://{server}:{port}".format( server=self.server, diff --git a/scripts/automation/trex_control_plane/client_utils/packet_builder.py b/scripts/automation/trex_control_plane/client_utils/packet_builder.py index fc34d931..5ca8da93 100644 --- a/scripts/automation/trex_control_plane/client_utils/packet_builder.py +++ b/scripts/automation/trex_control_plane/client_utils/packet_builder.py @@ -302,7 +302,6 @@ class CTRexPktBuilder(object): except IOError: raise IOError(2, "The provided path could not be accessed") - # ----- useful shortcut methods ----- # def gen_dns_packet(self): pass |