Merge "Update cloud image Ubuntu18.04 mininet ovs"
[releng/builder.git] / jjb / opendaylight-infra-copy-ssh-keys.sh
index d6801239f6b0b843889608bd2fda9c8e95584916..c8aa145964b254a15462765c26e5138a861f2d9a 100644 (file)
@@ -1,19 +1,31 @@
-#!/bin/bash
-echo "----------> Copy ssh public keys to csit lab"
+#!/bin/bash -l
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2017 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
 
-# shellcheck disable=SC1090
-source "$WORKSPACE/.venv-openstack/bin/activate"
+echo "----------> Copy ssh public keys to csit lab"
 
 function copy-ssh-keys-to-slave() {
     RETRIES=60
     for j in $(seq 1 $RETRIES); do
-        # shellcheck disable=SC2092
+        # shellcheck disable=SC2006,SC2092
         if `ssh-copy-id -i /home/jenkins/.ssh/id_rsa.pub "jenkins@${i}" > /dev/null 2>&1`; then
             ssh "jenkins@${i}" 'echo "$(facter ipaddress_eth0) $(/bin/hostname)" | sudo tee -a /etc/hosts'
             echo "Successfully copied public keys to slave ${i}"
             break
         elif [ "$j" -eq $RETRIES ]; then
             echo "SSH not responding on ${i} after $RETIRES tries. Giving up."
+
+            server=$(openstack port list -f value -c device_id --fixed-ip ip-address="${i}")
+            echo "Dumping console logs for $server ${i}"
+            openstack console log show "$server"
+
             exit 1
         else
             echo "SSH not responding on ${i}. Retrying in 10 seconds..."
@@ -29,11 +41,19 @@ function copy-ssh-keys-to-slave() {
     done
 }
 
+# shellcheck disable=SC1090
+. ~/lf-env.sh
+
+lf-activate-venv --python python3 \
+    python-heatclient \
+    python-openstackclient \
+    yq
+
 # Print the Stack outputs parameters so that we can identify which IPs belong
 # to which VM types.
 openstack stack show -c outputs "$STACK_NAME"
 
-# shellcheck disable=SC2006
+# shellcheck disable=SC2006,SC2207
 ADDR=(`openstack stack show -f json -c outputs "$STACK_NAME" | \
        jq -r '.outputs[] | \
               select(.output_key | match("^vm_[0-9]+_ips\$")) | \