From 998aa11be6a89197a3b30c0645771c467cad8c13 Mon Sep 17 00:00:00 2001 From: Lucia Guevgeozian Odizzio Date: Thu, 22 May 2014 15:55:40 +0200 Subject: [PATCH] Fix multihop --- examples/linux/multihop_ssh.py | 4 ++-- src/nepi/resources/linux/application.py | 9 +++++---- src/nepi/resources/linux/node.py | 22 +++++++++++++--------- src/nepi/util/sshfuncs.py | 8 ++++---- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/examples/linux/multihop_ssh.py b/examples/linux/multihop_ssh.py index a141faba..8bcd47f3 100755 --- a/examples/linux/multihop_ssh.py +++ b/examples/linux/multihop_ssh.py @@ -27,7 +27,7 @@ ec = ExperimentController(exp_id) # server node1 = ec.register_resource("LinuxNode") -ec.set(node1, "hostname", "wlab19.") +ec.set(node1, "hostname", "wlab29.") ec.set(node1, "username", "root") ec.set(node1, "gatewayUser", "etourdi") ec.set(node1, "gateway", "etourdi.pl.sophia.inria.fr") @@ -46,7 +46,7 @@ ec.set(node2, "cleanProcesses", True) app1 = ec.register_resource("LinuxApplication") video= "../big_buck_bunny_240p_mpeg4_lq.ts" ec.set(app1, "sources", video) -command = "cat ${SRC}/big_buck_bunny_240p_mpeg4_lq.ts| nc wlab5 1234" +command = "cat ${SRC}/big_buck_bunny_240p_mpeg4_lq.ts| nc wlab5. 1234" ec.set(app1, "command", command) ec.register_connection(app1, node1) diff --git a/src/nepi/resources/linux/application.py b/src/nepi/resources/linux/application.py index 45efd21d..af6ae34d 100644 --- a/src/nepi/resources/linux/application.py +++ b/src/nepi/resources/linux/application.py @@ -282,10 +282,11 @@ class LinuxApplication(ResourceManager): procs = dict() ps_aux = "ps aux |awk '{print $2,$11}'" (out, err), proc = self.node.execute(ps_aux) - for line in out.strip().split("\n"): - parts = line.strip().split(" ") - procs[parts[0]] = parts[1] - pickle.dump(procs, open("/tmp/save.proc", "wb")) + if len(out) != 0: + for line in out.strip().split("\n"): + parts = line.strip().split(" ") + procs[parts[0]] = parts[1] + pickle.dump(procs, open("/tmp/save.proc", "wb")) # create run dir for application self.node.mkdir(self.run_home) diff --git a/src/nepi/resources/linux/node.py b/src/nepi/resources/linux/node.py index 6de7cd97..01a1d40f 100644 --- a/src/nepi/resources/linux/node.py +++ b/src/nepi/resources/linux/node.py @@ -418,15 +418,19 @@ class LinuxNode(ResourceManager): pids_temp = dict() ps_aux = "ps aux |awk '{print $2,$11}'" (out, err), proc = self.execute(ps_aux) - for line in out.strip().split("\n"): - parts = line.strip().split(" ") - pids_temp[parts[0]] = parts[1] - kill_pids = set(pids_temp.items()) - set(pids.items()) - kill_pids = ' '.join(dict(kill_pids).keys()) - - cmd = ("killall tcpdump || /bin/true ; " + - "kill $(ps aux | grep '[n]epi' | awk '{print $2}') || /bin/true ; " + - "kill %s || /bin/true ; " % kill_pids) + if len(out) != 0: + for line in out.strip().split("\n"): + parts = line.strip().split(" ") + pids_temp[parts[0]] = parts[1] + kill_pids = set(pids_temp.items()) - set(pids.items()) + kill_pids = ' '.join(dict(kill_pids).keys()) + + cmd = ("killall tcpdump || /bin/true ; " + + "kill $(ps aux | grep '[n]epi' | awk '{print $2}') || /bin/true ; " + + "kill %s || /bin/true ; " % kill_pids) + else: + cmd = ("killall tcpdump || /bin/true ; " + + "kill $(ps aux | grep '[n]epi' | awk '{print $2}') || /bin/true ; ") else: cmd = ("killall tcpdump || /bin/true ; " + "kill $(ps aux | grep '[n]epi' | awk '{print $2}') || /bin/true ; ") diff --git a/src/nepi/util/sshfuncs.py b/src/nepi/util/sshfuncs.py index 9a416aee..b06abdbd 100644 --- a/src/nepi/util/sshfuncs.py +++ b/src/nepi/util/sshfuncs.py @@ -252,9 +252,9 @@ def rexec(command, host, user, if gw: if gwuser: - proxycommand = 'ProxyCommand=ssh %s@%s -W %%h:%%p' % (gwuser, gw) + proxycommand = 'ProxyCommand=ssh -q %s@%s -W %%h:%%p' % (gwuser, gw) else: - proxycommand = 'ProxyCommand=ssh %%r@%s -W %%h:%%p' % gw + proxycommand = 'ProxyCommand=ssh -q %%r@%s -W %%h:%%p' % gw args.extend(['-o', proxycommand]) if agent: @@ -347,9 +347,9 @@ def rcopy(source, dest, if gw: if gwuser: - proxycommand = 'ProxyCommand=ssh %s@%s -W %%h:%%p' % (gwuser, gw) + proxycommand = 'ProxyCommand=ssh -q %s@%s -W %%h:%%p' % (gwuser, gw) else: - proxycommand = 'ProxyCommand=ssh %%r@%s -W %%h:%%p' % gw + proxycommand = 'ProxyCommand=ssh -q %%r@%s -W %%h:%%p' % gw args.extend(['-o', proxycommand]) if recursive: -- 2.43.0