From 0991ed88f25771d5adde2119c5b967cd4b397816 Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Thu, 20 Sep 2012 14:37:41 +0100 Subject: [PATCH] heat tests : functional tests add exec_sudo_command Add new method in the Instance class, which uses paramiko invoke_shell instead of exec_command, so sudo commands can run despite requiretty being set in our sudo config Ref #246 Change-Id: I3be691167d4c757b68e589261d6f3a1263d77e69 Signed-off-by: Steven Hardy --- heat/tests/functional/util.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/heat/tests/functional/util.py b/heat/tests/functional/util.py index 0837ba9d..b9f6e064 100644 --- a/heat/tests/functional/util.py +++ b/heat/tests/functional/util.py @@ -153,6 +153,17 @@ class Instance(object): (self.name, self.ip)) break + def exec_sudo_command(self, cmd): + # Force a tty or sudo commands fail + channel = self.ssh.invoke_shell() + channel.sendall("sudo %s\n" % cmd) + channel.sendall('exit\n') + time.sleep(1) # necessary for sendall to complete + stdin = channel.makefile('wb') + stdout = channel.makefile('rb') + stderr = channel.makefile_stderr('rb') + return stdin, stdout, stderr + def exec_command(self, cmd): return self.ssh.exec_command(cmd) -- 2.45.2