summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorubansal <ubansal@redhat.com>2020-06-10 13:32:12 +0530
committerBala Konda Reddy M <bala12352@gmail.com>2020-06-10 11:12:20 +0000
commitc61b7880800f5204766690c796fc5c8ccfe2d3e9 (patch)
tree45100c0ff4974e4de2f426207ea08e5b46e13005
parentf1dd941986a8a8e31b76d9ae79841f1deede11ea (diff)
[Lib] Add Lib to open FD
Opens a FD to a file , waits and then writes to the file Change-Id: Ib993b646ba45d2b05a5765e02b6b1b7b2869ecd3 Signed-off-by: ubansal <ubansal@redhat.com>
-rwxr-xr-xglustolibs-io/glustolibs/io/utils.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/glustolibs-io/glustolibs/io/utils.py b/glustolibs-io/glustolibs/io/utils.py
index 67b3fe2d1..2a2dff189 100755
--- a/glustolibs-io/glustolibs/io/utils.py
+++ b/glustolibs-io/glustolibs/io/utils.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2015-2016 Red Hat, Inc. <http://www.redhat.com>
+# Copyright (C) 2015-2020 Red Hat, Inc. <http://www.redhat.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -983,3 +983,21 @@ def upload_file_dir_ops(clients):
g.log.info("Successfully uploaded IO scripts to clients %s",
clients)
return True
+
+
+def open_file_fd(mountpoint, time, client):
+ """Open FD for a file and write to file.
+
+ Args:
+ mountpoint(str): The mount point where the FD of file is to
+ be opened.
+ time(int): The time to wait after opening an FD.
+ client(str): The client from which FD is to be opened.
+
+ Returns:
+ proc(object): Returns a process object
+ """
+ cmd = ("cd {}; exec 30<> file_openfd ; sleep {};"
+ "echo 'xyz' >&30".format(mountpoint, time))
+ proc = g.run_async(client, cmd)
+ return proc