diff options
| author | Ambarish Soman <asoman@redhat.com> | 2017-10-09 21:31:47 +0530 | 
|---|---|---|
| committer | Jonathan Holloway <jholloway@redhat.com> | 2018-05-09 03:08:05 +0000 | 
| commit | ec9a468e162f3cc00a588956fd6b29d9c0c2bfae (patch) | |
| tree | 996754c3dc52773c3d7d2d80b6bcfa2a20c909ed | |
| parent | eee761bf6970eb6ee67ff33609319eb12fb95ea0 (diff) | |
Function that drops caches on a list of hosts,to run certain FOPs on a cold cache
Change-Id: Ia6a2d73da1c3ea2a123da55c6bcd063b1e7404a4
Signed-off-by: Ambarish Soman <asoman@redhat.com>
| -rwxr-xr-x | glustolibs-misc/glustolibs/misc/misc_libs.py | 23 | 
1 files changed, 23 insertions, 0 deletions
diff --git a/glustolibs-misc/glustolibs/misc/misc_libs.py b/glustolibs-misc/glustolibs/misc/misc_libs.py index e913becf3..e2c1f6ca7 100755 --- a/glustolibs-misc/glustolibs/misc/misc_libs.py +++ b/glustolibs-misc/glustolibs/misc/misc_libs.py @@ -536,3 +536,26 @@ def are_nodes_offline(nodes):      ret = all(node_results.values())      return ret, node_results + + +def drop_caches(hosts): +    """Drops Kernel Cache on a list of hosts +       (in order to run reads/renames etc on a cold cache). + +    Args: +        hosts (list): List of  hosts where kernel caches need to be +                      dropped (Servers/ Clients) + +    Returns: +        bool : True , post succesful completion.Else,False. +    """ +    cmd = "echo 3 > /proc/sys/vm/drop_caches" +    results = g.run_parallel(hosts, cmd) +    _rc = True +    for host, ret_values in results.iteritems(): +        retcode, _, _ = ret_values +        if retcode != 0: +            g.log.error("Unable to drop cache on host %s", host) +            _rc = False + +    return _rc  | 
