Provide a config option to customize remote shell command

Our remote ssh code makes all kinds of assumptions about the shell and
path of the guest. Recently some code was added to the command to generate
errors more promptly but it does not work if the shell is /bin/sh. This
commit allows the user to configure tempest with a desired prologue to handle
this case. It does nothing to solve the more general problem and, like the
other image-related options, cannot be customized individually for various
images that tempest may use.

Debug logging of remote commands was also added.

Change-Id: I669dd4386ffb539dad88a9487bef6c172b5d65fa
Closes-Bug: #1465682
This commit is contained in:
David Kranz 2015-06-18 16:58:18 -04:00
parent 97be6211c0
commit 968f1b3a0b
3 changed files with 13 additions and 1 deletions

View File

@ -254,6 +254,10 @@
# value) # value)
#build_timeout = 300 #build_timeout = 300
# Shell fragments to use before executing a command when sshing to a
# guest. (string value)
#ssh_shell_prologue = set -eu -o pipefail; PATH=$$PATH:/sbin;
# Auth method used for authenticate to the instance. Valid choices # Auth method used for authenticate to the instance. Valid choices
# are: keypair, configured, adminpass and disabled. Keypair: start the # are: keypair, configured, adminpass and disabled. Keypair: start the
# servers with a ssh keypair. Configured: use the configured user and # servers with a ssh keypair. Configured: use the configured user and

View File

@ -14,6 +14,7 @@ import netaddr
import re import re
import time import time
from oslo_log import log as logging
import six import six
from tempest_lib.common import ssh from tempest_lib.common import ssh
@ -22,6 +23,8 @@ from tempest import exceptions
CONF = config.CONF CONF = config.CONF
LOG = logging.getLogger(__name__)
class RemoteClient(object): class RemoteClient(object):
@ -48,7 +51,8 @@ class RemoteClient(object):
def exec_command(self, cmd): def exec_command(self, cmd):
# Shell options below add more clearness on failures, # Shell options below add more clearness on failures,
# path is extended for some non-cirros guest oses (centos7) # path is extended for some non-cirros guest oses (centos7)
cmd = "set -eu -o pipefail; PATH=$PATH:/sbin; " + cmd cmd = CONF.compute.ssh_shell_prologue + " " + cmd
LOG.debug("Remote command: %s" % cmd)
return self.ssh_client.exec_command(cmd) return self.ssh_client.exec_command(cmd)
def validate_authentication(self): def validate_authentication(self):

View File

@ -206,6 +206,10 @@ ComputeGroup = [
help="Timeout in seconds to wait for an instance to build. " help="Timeout in seconds to wait for an instance to build. "
"Other services that do not define build_timeout will " "Other services that do not define build_timeout will "
"inherit this value."), "inherit this value."),
cfg.StrOpt('ssh_shell_prologue',
default="set -eu -o pipefail; PATH=$$PATH:/sbin;",
help="Shell fragments to use before executing a command "
"when sshing to a guest."),
cfg.StrOpt('ssh_auth_method', cfg.StrOpt('ssh_auth_method',
default='keypair', default='keypair',
help="Auth method used for authenticate to the instance. " help="Auth method used for authenticate to the instance. "