summaryrefslogtreecommitdiffstats
path: root/glustolibs-io
diff options
context:
space:
mode:
authorkshithijiyer <kshithij.ki@gmail.com>2020-07-29 13:34:09 +0530
committerArthy Loganathan <aloganat@redhat.com>2020-07-30 04:47:44 +0000
commit0db380b90b85c54fdb1d29b870380c667fc9167c (patch)
treee20a42775ab77d52f5157b866cb6ee012816a1ed /glustolibs-io
parentdf1575e05958f66a674f170a557e5dddcd21df62 (diff)
[Lib] Add run_linux_untar() to io/utils.py
Add method run_linux_untar() to io/utils.py which downloads linux-5.4.54.tar.xz and untar it on specific dirs of mount point or by default on mount point. Change-Id: Id00ea50b4d7fb7c360150aeaac65baec5612e589 Signed-off-by: kshithijiyer <kshithij.ki@gmail.com>
Diffstat (limited to 'glustolibs-io')
-rwxr-xr-xglustolibs-io/glustolibs/io/utils.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/glustolibs-io/glustolibs/io/utils.py b/glustolibs-io/glustolibs/io/utils.py
index a0c1701e1..16ee93f21 100755
--- a/glustolibs-io/glustolibs/io/utils.py
+++ b/glustolibs-io/glustolibs/io/utils.py
@@ -22,6 +22,7 @@ import os
import subprocess
from glusto.core import Glusto as g
+from glustolibs.gluster.glusterfile import file_exists
from glustolibs.gluster.mount_ops import GlusterMount
from glustolibs.gluster.volume_libs import get_subvols
from glustolibs.misc.misc_libs import upload_scripts
@@ -1023,3 +1024,48 @@ def open_file_fd(mountpoint, time, client, start_range=0,
mountpoint, start_range, end_range, time))
proc = g.run_async(client, cmd)
return proc
+
+
+def run_linux_untar(clients, mountpoint, dirs=('.')):
+ """Run linux kernal untar on a given mount point
+
+ Args:
+ clients(str|list): Client nodes on which I/O
+ has to be started.
+ mountpoint(str): Mount point where the volume is
+ mounted.
+ Kwagrs:
+ dirs(tuple): A tuple of dirs where untar has to
+ started. (Default:('.'))
+ Returns:
+ list: Returns a list of process object else None
+ """
+ # Checking and convering clients to list.
+ if not isinstance(clients, list):
+ clients = [clients]
+
+ list_of_procs = []
+ for client in clients:
+ # Download linux untar to root, so that it can be
+ # utilized in subsequent run_linux_untar() calls.
+ cmd = ("wget https://cdn.kernel.org/pub/linux/kernel/"
+ "v5.x/linux-5.4.54.tar.xz")
+ if not file_exists(client, '/root/linux-5.4.54.tar.xz'):
+ ret, _, _ = g.run(client, cmd)
+ if ret:
+ return None
+
+ for directory in dirs:
+ # copy linux tar to dir
+ cmd = ("cp /root/linux-5.4.54.tar.xz {}/{}"
+ .format(mountpoint, directory))
+ ret, _, _ = g.run(client, cmd)
+ if ret:
+ return None
+ # Start linux untar
+ cmd = ("cd {}/{};tar -xvf linux-5.4.54.tar.xz"
+ .format(mountpoint, directory))
+ proc = g.run_async(client, cmd)
+ list_of_procs.append(proc)
+
+ return list_of_procs