X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=jjb%2Fopendaylight-infra-copy-ssh-keys.sh;h=493f776b7549cda38814220fa9dfcf1ab70c63b6;hb=93a5304ef04620630cbd6de14694607048bf2aa3;hp=b5af750fb865f246a833e798a43bca6977bc840f;hpb=002b9147e8ea4ac1d83543ac89663b45c1c0ecf0;p=releng%2Fbuilder.git diff --git a/jjb/opendaylight-infra-copy-ssh-keys.sh b/jjb/opendaylight-infra-copy-ssh-keys.sh index b5af750fb..493f776b7 100644 --- a/jjb/opendaylight-infra-copy-ssh-keys.sh +++ b/jjb/opendaylight-infra-copy-ssh-keys.sh @@ -1,21 +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" -PYTHON="$WORKSPACE/.venv-openstack/bin/python" -OPENSTACK="$WORKSPACE/.venv-openstack/bin/openstack" +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..." @@ -33,10 +43,10 @@ function copy-ssh-keys-to-slave() { # Print the Stack outputs parameters so that we can identify which IPs belong # to which VM types. -$PYTHON $OPENSTACK stack show -c outputs "$STACK_NAME" +openstack stack show -c outputs "$STACK_NAME" -# shellcheck disable=SC2006 -ADDR=(`$PYTHON $OPENSTACK stack show -f json -c outputs "$STACK_NAME" | \ +# 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\$")) | \ .output_value | .[]'`)