X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=utils%2Ffetch_os_creds.sh;h=0e2a2b93f7bbfc3622686910798773814ea6f8bc;hb=6d7df1240ecd45c761002d142cdd2118ff45fa50;hp=b514a91d3cadb6f625988849017a508bbe0c1dd5;hpb=832c9c2eded3f7d93479b2c8e56fd17d304ab569;p=releng.git diff --git a/utils/fetch_os_creds.sh b/utils/fetch_os_creds.sh index b514a91d3..0e2a2b93f 100755 --- a/utils/fetch_os_creds.sh +++ b/utils/fetch_os_creds.sh @@ -12,7 +12,7 @@ set -o nounset set -o pipefail usage() { - echo "usage: $0 [-v] -d -i -a [-s ]" >&2 + echo "usage: $0 [-v] -d -i -a [-o ] [-s ]" >&2 echo "[-v] Virtualized deployment" >&2 echo "[-s ] Path to ssh key. For MCP deployments only" >&2 } @@ -54,12 +54,13 @@ swap_to_public() { : ${DEPLOY_TYPE:=''} #Get options -while getopts ":d:i:a:h:s:v" optchar; do +while getopts ":d:i:a:h:s:o:v" optchar; do case "${optchar}" in d) dest_path=${OPTARG} ;; i) installer_type=${OPTARG} ;; a) installer_ip=${OPTARG} ;; s) ssh_key=${OPTARG} ;; + o) os_cacert=${OPTARG} ;; v) DEPLOY_TYPE="virt" ;; *) echo "Non-option argument: '-${OPTARG}'" >&2 usage @@ -70,6 +71,7 @@ done # set vars from env if not provided by user as options dest_path=${dest_path:-$HOME/opnfv-openrc.sh} +os_cacert=${os_cacert:-$HOME/os_cacert} installer_type=${installer_type:-$INSTALLER_TYPE} installer_ip=${installer_ip:-$INSTALLER_IP} if [ "${installer_type}" == "fuel" ] && [ "${BRANCH}" == "master" ]; then @@ -105,11 +107,15 @@ if [ "$installer_type" == "fuel" ]; then # retrieving controller vip controller_ip=$(ssh 2>/dev/null ${ssh_options} ubuntu@${installer_ip} \ - "sudo salt --out txt 'ctl01*' pillar.get _param:openstack_control_address | awk '{print \$2}'" | \ + "sudo salt --out txt 'ctl*' pillar.get _param:openstack_control_address | awk '{print \$2; exit}'" | \ sed 's/ //g') &> /dev/null info "Fetching rc file from controller $controller_ip..." ssh ${ssh_options} ubuntu@${controller_ip} "sudo cat /root/keystonercv3" > $dest_path + + if [[ $BUILD_TAG =~ "baremetal" ]]; then + ssh ${ssh_options} ubuntu@${installer_ip} "cat /etc/ssl/certs/os_cacert" > $os_cacert + fi else #ip_fuel="10.20.0.2" env=$(sshpass -p r00tme ssh 2>/dev/null ${ssh_options} root@${installer_ip} \ @@ -142,6 +148,13 @@ if [ "$installer_type" == "fuel" ]; then echo $auth_url >> $dest_path elif [ "$installer_type" == "apex" ]; then + if ! ipcalc -c $installer_ip; then + installer_ip=$(sudo virsh domifaddr undercloud | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}') + if [ -z "$installer_ip" ] || ! $(ipcalc -c $installer_ip); then + echo "Unable to find valid IP for Apex undercloud: ${installer_ip}" + exit 1 + fi + fi verify_connectivity $installer_ip # The credentials file is located in the Instack VM (192.0.2.1) @@ -155,6 +168,8 @@ elif [ "$installer_type" == "apex" ]; then elif [ "$installer_type" == "compass" ]; then if [ "${BRANCH}" == "master" ]; then sudo docker cp compass-tasks:/opt/openrc $dest_path &> /dev/null + sudo chown $(whoami):$(whoami) $dest_path + sudo docker cp compass-tasks:/opt/os_cacert $os_cacert &> /dev/null else verify_connectivity $installer_ip controller_ip=$(sshpass -p'root' ssh 2>/dev/null $ssh_options root@${installer_ip} \