Add user key data debug script to instance user data
If running with validation add a simple user data script to dump ssh
key info. This is to aid in debugging ssh failures.
Change-Id: I51b4a2df55c8e84fdae1dd58f2ab8714ba33d5bb
diff --git a/tempest/common/compute.py b/tempest/common/compute.py
index 9a483bb..b2667e5 100644
--- a/tempest/common/compute.py
+++ b/tempest/common/compute.py
@@ -13,6 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import base64
+import textwrap
+
from oslo_log import log as logging
from oslo_utils import excutils
@@ -113,6 +116,19 @@
if wait_until is None:
wait_until = 'ACTIVE'
+ if 'user_data' not in kwargs:
+ # If nothing overrides the default user data script then run
+ # a simple script on the host to print networking info. This is
+ # to aid in debugging ssh failures.
+ script = '''
+ #!/bin/sh
+ echo "Printing {user} user authorized keys"
+ cat ~{user}/.ssh/authorized_keys || true
+ '''.format(user=CONF.validation.image_ssh_user)
+ script_clean = textwrap.dedent(script).lstrip().encode('utf8')
+ script_b64 = base64.b64encode(script_clean)
+ kwargs['user_data'] = script_b64
+
if volume_backed:
volume_name = data_utils.rand_name(__name__ + '-volume')
volumes_client = clients.volumes_v2_client