From: Steven Hardy Date: Thu, 20 Sep 2012 13:37:41 +0000 (+0100) Subject: heat tests : functional tests add exec_sudo_command X-Git-Tag: 2014.1~1367 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=0991ed88f25771d5adde2119c5b967cd4b397816;p=openstack-build%2Fheat-build.git 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 --- 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)