X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=utils%2Ffetch_os_creds.sh;h=8374edbbdb23ddb5efd126f86dbcfe488dc035b2;hb=5bec8614dd747bf62336ae4ecf5393869643ad09;hp=993c0b948129f50be413798c0ed17c153f2d4568;hpb=5c8a2d71bc1d13646a3dc618e5bb0cdfb21693bb;p=releng.git diff --git a/utils/fetch_os_creds.sh b/utils/fetch_os_creds.sh index 993c0b948..8374edbbd 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 @@ -153,36 +155,41 @@ elif [ "$installer_type" == "apex" ]; then sudo scp $ssh_options root@$installer_ip:/home/stack/overcloudrc.v3 $dest_path elif [ "$installer_type" == "compass" ]; then - verify_connectivity $installer_ip - controller_ip=$(sshpass -p'root' ssh 2>/dev/null $ssh_options root@${installer_ip} \ - 'mysql -ucompass -pcompass -Dcompass -e"select * from cluster;"' \ - | awk -F"," '{for(i=1;i/dev/null $ssh_options root@${installer_ip} \ - "scp $ssh_options ${controller_ip}:/opt/admin-openrc.sh ." &> /dev/null - sshpass -p root scp 2>/dev/null $ssh_options root@${installer_ip}:~/admin-openrc.sh $dest_path &> /dev/null + 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} \ + 'mysql -ucompass -pcompass -Dcompass -e"select * from cluster;"' \ + | awk -F"," '{for(i=1;i /dev/null 2>&1 ; then - public_ip=$(sshpass -p root ssh $ssh_options root@${installer_ip} \ - "ssh ${controller_ip} 'source /opt/admin-openrc.sh; openstack endpoint show identity '" \ - | grep publicurl | awk '{print $4}') - else - public_ip=$(sshpass -p root ssh $ssh_options root@${installer_ip} \ - "ssh ${controller_ip} 'source /opt/admin-openrc.sh; \ - openstack endpoint list --interface public --service identity '" \ - | grep identity | awk '{print $14}') + info "Fetching rc file from controller $controller_ip..." + sshpass -p root ssh 2>/dev/null $ssh_options root@${installer_ip} \ + "scp $ssh_options ${controller_ip}:/opt/admin-openrc.sh ." &> /dev/null + sshpass -p root scp 2>/dev/null $ssh_options root@${installer_ip}:~/admin-openrc.sh $dest_path &> /dev/null + + info "This file contains the mgmt keystone API, we need the public one for our rc file" + + if grep "OS_AUTH_URL.*v2" $dest_path > /dev/null 2>&1 ; then + public_ip=$(sshpass -p root ssh $ssh_options root@${installer_ip} \ + "ssh ${controller_ip} 'source /opt/admin-openrc.sh; openstack endpoint show identity '" \ + | grep publicurl | awk '{print $4}') + else + public_ip=$(sshpass -p root ssh $ssh_options root@${installer_ip} \ + "ssh ${controller_ip} 'source /opt/admin-openrc.sh; \ + openstack endpoint list --interface public --service identity '" \ + | grep identity | awk '{print $14}') + fi + info "public_ip: $public_ip" + swap_to_public $public_ip fi - info "public_ip: $public_ip" - swap_to_public $public_ip - elif [ "$installer_type" == "joid" ]; then # do nothing...for the moment