From 62b990ba1fd454459b30bbaa400eed00762b8b30 Mon Sep 17 00:00:00 2001 From: sayaleeraut Date: Wed, 24 Jun 2020 10:33:19 +0530 Subject: [LibFix] Add kwargs start_range and end_range Adding the kwargs start_range and end_range to the method open_file_fd() so that FD can be opened for multiple files if required. Change-Id: Ia6d78941935c7fb26045d000c428aba9b9f2425b Signed-off-by: sayaleeraut --- glustolibs-io/glustolibs/io/utils.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/glustolibs-io/glustolibs/io/utils.py b/glustolibs-io/glustolibs/io/utils.py index e4bb53b4f..a0c1701e1 100755 --- a/glustolibs-io/glustolibs/io/utils.py +++ b/glustolibs-io/glustolibs/io/utils.py @@ -989,7 +989,8 @@ def upload_file_dir_ops(clients): return True -def open_file_fd(mountpoint, time, client): +def open_file_fd(mountpoint, time, client, start_range=0, + end_range=0): """Open FD for a file and write to file. Args: @@ -998,10 +999,27 @@ def open_file_fd(mountpoint, time, client): time(int): The time to wait after opening an FD. client(str): The client from which FD is to be opened. + Kwargs: + start_range(int): The start range of the open FD. + (Default: 0) + end_range(int): The end range of the open FD. + (Default: 0) + Returns: proc(object): Returns a process object + + NOTE: + Before opening FD, check the currently used fds on the + system as only a limited number of fds can be opened on + a system at a given time for each process. """ - cmd = ("cd {}; exec 30<> file_openfd ; sleep {};" - "echo 'xyz' >&30".format(mountpoint, time)) + if not (start_range and end_range): + cmd = ("cd {}; exec 30<> file_openfd ; sleep {};" + "echo 'xyz' >&30".format(mountpoint, time)) + else: + cmd = ('cd {}; for i in `seq {} {}`;' + ' do eval "exec $i<>file_openfd$i"; sleep {};' + ' echo "Write to open FD" >&$i; done'.format( + mountpoint, start_range, end_range, time)) proc = g.run_async(client, cmd) return proc -- cgit