diff options
Diffstat (limited to 'glustolibs-misc/glustolibs')
-rwxr-xr-x | glustolibs-misc/glustolibs/misc/misc_libs.py | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/glustolibs-misc/glustolibs/misc/misc_libs.py b/glustolibs-misc/glustolibs/misc/misc_libs.py index 109dc9621..9f9225929 100755 --- a/glustolibs-misc/glustolibs/misc/misc_libs.py +++ b/glustolibs-misc/glustolibs/misc/misc_libs.py @@ -21,7 +21,7 @@ import sys import time from glusto.core import Glusto as g -from glustolibs.gluster.lib_utils import is_rhel6 +from glustolibs.gluster.lib_utils import is_rhel6, is_rhel7 def create_dirs(list_of_nodes, list_of_dir_paths): @@ -666,3 +666,25 @@ def kill_process(mnode, process_ids='', process_names=''): g.log.error("Failed to kill process with pid %s" % str(pid)) return False return True + + +def bring_down_network_interface(mnode, timeout=150): + """Brings the network interface down for a defined time + + Args: + mnode (str): Node at which the interface has to be bought down + timeout (int): Time duration (in secs) for which network has to + be down + + Returns: + network_status(object): Returns a process object + + Example: + >>> bring_down_network_interface("10.70.43.68", timout=100) + """ + interface = "eth0" if is_rhel7(mnode) else "ens3" + cmd = "ifconfig {0} down\nsleep {1}\nifconfig {0} up".format(interface, + timeout) + _, _, _ = g.run(mnode, "echo \"{}\"> 'test.sh'".format(cmd)) + network_status = g.run_async(mnode, "sh test.sh") + return network_status |