From ec9a468e162f3cc00a588956fd6b29d9c0c2bfae Mon Sep 17 00:00:00 2001 From: Ambarish Soman Date: Mon, 9 Oct 2017 21:31:47 +0530 Subject: 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 --- glustolibs-misc/glustolibs/misc/misc_libs.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'glustolibs-misc') 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 -- cgit