From 4289f44874d2e046bef296dc01fdbd9e89cbde96 Mon Sep 17 00:00:00 2001 From: Alina Quereilhac Date: Mon, 17 Jun 2013 14:04:07 -0700 Subject: [PATCH] adding back use of sudo in sshfuncs.rexec --- src/nepi/resources/linux/node.py | 9 ++------- src/nepi/util/sshfuncs.py | 3 +++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/nepi/resources/linux/node.py b/src/nepi/resources/linux/node.py index b7e86684..f5a5429c 100644 --- a/src/nepi/resources/linux/node.py +++ b/src/nepi/resources/linux/node.py @@ -428,19 +428,14 @@ class LinuxNode(ResourceManager): forces to save the exit code of the command execution to the ecodefile """ - # Prepare command to be executed as a bash script file - # Make sure command ends in ';' so the curly brackets syntax is correct - if not command.strip()[-1] == ';': - command += " ; " - # The exit code of the command will be stored in ecodefile - command = " { { %(command)s } ; echo $? > %(ecodefile)s ; } " % { + command = " %(command)s ; echo $? > %(ecodefile)s ;" % { 'command': command, 'ecodefile': ecodefile, } # Export environment - environ = "\n".join(map(lambda e: "export %s" % e, env.split(" "))) \ + environ = "\n".join(map(lambda e: "export %s" % e, env.split(" "))) + "\n" \ if env else "" # Add environ to command diff --git a/src/nepi/util/sshfuncs.py b/src/nepi/util/sshfuncs.py index 7fe579b6..eb2abd0c 100644 --- a/src/nepi/util/sshfuncs.py +++ b/src/nepi/util/sshfuncs.py @@ -268,6 +268,9 @@ def rexec(command, host, user, tmp_known_hosts = make_server_key_args(server_key, host, port) args.extend(['-o', 'UserKnownHostsFile=%s' % (tmp_known_hosts.name,)]) + if sudo: + command = "sudo " + command + args.append(command) for x in xrange(retry): -- 2.43.0