summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stf
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2016-04-21 11:14:52 +0300
committerYaroslav Brustinov <ybrustin@cisco.com>2016-04-21 11:14:52 +0300
commitd42a2a5567958ea052aac0ab0dc291876f97f4e2 (patch)
tree75e0365169ce029656d3b09f8e2a6015c057e6c0 /scripts/automation/trex_control_plane/stf
parentf0d4ff5c450489c3ec6adb7f79896df75df2bd6b (diff)
regression: fix functional filters test path
stateful API: add get_files, get_files_list
Diffstat (limited to 'scripts/automation/trex_control_plane/stf')
-rwxr-xr-xscripts/automation/trex_control_plane/stf/trex_stf_lib/trex_client.py53
1 files changed, 51 insertions, 2 deletions
diff --git a/scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_client.py b/scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_client.py
index 4fd1e4c7..412f52d4 100755
--- a/scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_client.py
+++ b/scripts/automation/trex_control_plane/stf/trex_stf_lib/trex_client.py
@@ -725,7 +725,56 @@ class CTRexClient(object):
raise
finally:
self.prompt_verbose_data()
-
+
+ def get_files_list (self, path):
+ """
+ Gets a tuple (dirs, files) with lists of dirs and files from given path.
+ Path is limited to /tmp/trex_files or TRex directory (can be used relative path)
+
+ :return:
+ Tuple: list of dirs and list of files in given path
+
+ :raises:
+ + :exc:`trex_exceptions.TRexRequestDenied`, in case TRex is reserved for another user than the one trying to cancel the reservation.
+ + ProtocolError, in case of error in JSON-RPC protocol.
+
+ """
+
+ try:
+ return self.server.get_files_list(path)
+ except AppError as err:
+ self._handle_AppError_exception(err.args[0])
+ except ProtocolError:
+ raise
+ finally:
+ self.prompt_verbose_data()
+
+ def get_file(self, filepath):
+ """
+ Gets a file from /tmp/trex_files or TRex server directory.
+
+ :parameters:
+ filepath : str
+ a path to a file at server.
+ it can be either relative to TRex server or absolute path starting with /tmp/trex_files
+
+ :return:
+ Content of the file
+
+ :raises:
+ + :exc:`trex_exceptions.TRexRequestDenied`, in case TRex is reserved for another user than the one trying to cancel the reservation.
+ + ProtocolError, in case of error in JSON-RPC protocol.
+ """
+
+ try:
+ return binascii.a2b_base64(self.server.get_file(filepath))
+ except AppError as err:
+ self._handle_AppError_exception(err.args[0])
+ except ProtocolError:
+ raise
+ finally:
+ self.prompt_verbose_data()
+
def push_files (self, filepaths):
"""
Pushes a file (or a list of files) to store locally on server.
@@ -761,7 +810,7 @@ class CTRexClient(object):
filename = os.path.basename(filepath)
with open(filepath, 'rb') as f:
file_content = f.read()
- self.server.push_file(filename, binascii.b2a_base64(file_content))
+ self.server.push_file(filename, binascii.b2a_base64(file_content).decode())
finally:
self.prompt_verbose_data()
return True