summaryrefslogtreecommitdiffstats
path: root/glustolibs-io/glustolibs/io/utils.py
diff options
context:
space:
mode:
authorsayaleeraut <saraut@redhat.com>2020-06-24 10:33:19 +0530
committerArthy Loganathan <aloganat@redhat.com>2020-06-24 11:47:50 +0000
commit62b990ba1fd454459b30bbaa400eed00762b8b30 (patch)
tree2e8e9ff65e7c59fd3d1c2a0b38e46070248d8c02 /glustolibs-io/glustolibs/io/utils.py
parent3f5e3553cebceb95e8d051e27f18a26f9c8f725d (diff)
[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 <saraut@redhat.com>
Diffstat (limited to 'glustolibs-io/glustolibs/io/utils.py')
-rwxr-xr-xglustolibs-io/glustolibs/io/utils.py24
1 files 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