Merge "Provide a config option to customize remote shell command"
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index 6424f55..4fe7044 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -254,6 +254,10 @@
 # value)
 #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
 # are: keypair, configured, adminpass and disabled. Keypair: start the
 # servers with a ssh keypair. Configured: use the configured user and
diff --git a/tempest/common/utils/linux/remote_client.py b/tempest/common/utils/linux/remote_client.py
index 4b3995b..d4e6eb8 100644
--- a/tempest/common/utils/linux/remote_client.py
+++ b/tempest/common/utils/linux/remote_client.py
@@ -14,6 +14,7 @@
 import re
 import time
 
+from oslo_log import log as logging
 import six
 from tempest_lib.common import ssh
 
@@ -22,6 +23,8 @@
 
 CONF = config.CONF
 
+LOG = logging.getLogger(__name__)
+
 
 class RemoteClient(object):
 
@@ -48,7 +51,8 @@
     def exec_command(self, cmd):
         # Shell options below add more clearness on failures,
         # 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)
 
     def validate_authentication(self):
diff --git a/tempest/config.py b/tempest/config.py
index 0fa5bf5..fc55723 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -206,6 +206,10 @@
                help="Timeout in seconds to wait for an instance to build. "
                     "Other services that do not define build_timeout will "
                     "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',
                default='keypair',
                help="Auth method used for authenticate to the instance. "