From 2a3f61072f1acac0fdb47d259228e3e461edec6f Mon Sep 17 00:00:00 2001 From: Vitaly Parakhin Date: Mon, 25 May 2015 16:56:55 +0300 Subject: [PATCH] Add Fuel admin password parameter --- config/fuel.cfg | 6 +++++- config/mos-ubuntu-updatesonly.cfg | 4 ++-- config/mos-ubuntu.cfg | 4 ++-- fuel-createmirror | 29 +++++++++++++++++++++++++---- 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/config/fuel.cfg b/config/fuel.cfg index b413feb..6a78f40 100644 --- a/config/fuel.cfg +++ b/config/fuel.cfg @@ -23,7 +23,11 @@ source <( $BINROOT/util/parse_yaml.py /etc/fuel/astute.yaml "FUEL" ) source <( $BINROOT/util/parse_yaml.py /etc/nailgun/version.yaml "FUEL" ) FUEL_VERSION=$FUEL_VERSION_release FUEL_SERVER=$FUEL_ADMIN_NETWORK_ipaddress -FUEL_ADMIN_PASS=$FUEL_FUEL_ACCESS_password FULL_RELEASE=$FUEL_VERSION_openstack_version +if [ $FUEL_MASTER_PASS ]; then + FUEL_ADMIN_PASS=$FUEL_MASTER_PASS +else + FUEL_ADMIN_PASS=$FUEL_FUEL_ACCESS_password +fi fi diff --git a/config/mos-ubuntu-updatesonly.cfg b/config/mos-ubuntu-updatesonly.cfg index 91a83f5..fad5f5c 100644 --- a/config/mos-ubuntu-updatesonly.cfg +++ b/config/mos-ubuntu-updatesonly.cfg @@ -4,8 +4,8 @@ source "$(dirname $(readlink -f "${BASH_SOURCE[0]}"))/fuel.cfg" # Sync source UPSTREAM=$MIRROR_MOS_UBUNTU_HOST -UPSTREAM_DIR=$MIRROR_UBUNTU_DIR -UPSTREAM_DIR_HTTP="mos/ubuntu" +UPSTREAM_DIR=$MIRROR_MOS_UBUNTU_DIR +UPSTREAM_DIR_HTTP=$MIRROR_MOS_UBUNTU_HTTPDIR # Always sync full MOS mirror PARTIAL_UPSTREAM=0 diff --git a/config/mos-ubuntu.cfg b/config/mos-ubuntu.cfg index 2c2cd44..c9023d8 100644 --- a/config/mos-ubuntu.cfg +++ b/config/mos-ubuntu.cfg @@ -4,8 +4,8 @@ source "$(dirname $(readlink -f "${BASH_SOURCE[0]}"))/fuel.cfg" # Sync source UPSTREAM=$MIRROR_MOS_UBUNTU_HOST -UPSTREAM_DIR=$MIRROR_UBUNTU_DIR -UPSTREAM_DIR_HTTP="mos/ubuntu" +UPSTREAM_DIR=$MIRROR_MOS_UBUNTU_DIR +UPSTREAM_DIR_HTTP=$MIRROR_MOS_UBUNTU_HTTPDIR # Always sync full MOS mirror PARTIAL_UPSTREAM=0 diff --git a/fuel-createmirror b/fuel-createmirror index 39c7931..4eb99da 100755 --- a/fuel-createmirror +++ b/fuel-createmirror @@ -24,6 +24,7 @@ Options: -M| --mos Create/Update MOS local mirror only -U| --ubuntu Create/Update Ubuntu local mirror only -N| --dry-run Show commands to execute instead of running them + -p| --password Fuel Master admin password (defaults to admin) CUSTOMIZATION ------------- @@ -34,6 +35,9 @@ script behavior: Please refer to the description of parameters in that configuration file. +See more detailed description in the Fuel Operations Guide: +https://docs.mirantis.com/openstack/fuel/fuel-6.1/operations.html#external-ubuntu-ops + EOF } @@ -52,12 +56,15 @@ print_repositories_ubuntu() { if [ "$PARTIAL_UPSTREAM" == "0" ]; then echo -e " Replace the URI value for the following repositories:" for dist in "${DISTs[@]}"; do - echo -e " Repository \"$dist\" URI=\"deb http://$FUEL_SERVER:8080/$1 $dist ${DIST_COMPONENTs[$dist]}\"" + distlabel=`echo "$dist" | sed "s/$FUEL_VERSION//"` + echo -e " Repository \"$distlabel\" URI=\"deb http://$FUEL_SERVER:8080/$1 $dist ${DIST_COMPONENTs[$dist]}\"" done else - echo -e " REMOVE all repositories named \"ubuntu-*\" and change URI for the following one:" + echo -e " Replace the URI value for the following repositories:" echo echo -e " Repository \"ubuntu\" new URI=\"deb http://$FUEL_SERVER:8080/$1 ${DISTs[0]} main\"" + echo -e " Repository \"ubuntu-security\" new URI=\"deb http://$FUEL_SERVER:8080/$1 ${DISTs[0]} main\"" + echo -e " Repository \"ubuntu-updates\" new URI=\"deb http://$FUEL_SERVER:8080/$1 ${DISTs[0]} main\"" fi echo } @@ -76,7 +83,7 @@ add_repositories_to_nailgun() { [ "$OPT_NO_DEFAULT" == "1" ] && makedefault="" [ "$OPT_NO_APPLY" == "1" ] && apply="" # find envs with status "new" and with given release_id - envs=`fuel env 2>&1 | grep -w new | awk -v release_id=$release_id -F'|' '$5 == release_id {print $1}'` + envs=`fuel --user=admin --password="$FUEL_ADMIN_PASS" env 2>&1 | grep -w new | awk -v release_id=$release_id -F'|' '$5 == release_id {print $1}'` for env in ${envs}; do $EXEC_PREFIX fuel-package-updates -d $2 -r $FULL_RELEASE --no-download $makedefault $apply \ -s $FUEL_SERVER -p "$FUEL_ADMIN_PASS" -b http://$FUEL_SERVER:8080/$3 -e $env $clearupstream 2>/dev/null @@ -100,7 +107,7 @@ OPT_UBUNTU=1 EXEC_PREFIX="" # Parse options -OPTS=`getopt -o hdaMUN -l help,no-default,no-apply,mos,ubuntu,dry-run -- "$@"` +OPTS=`getopt -o hdaMUNp: -l help,no-default,no-apply,mos,ubuntu,password:,dry-run -- "$@"` if [ $? != 0 ]; then usage_short exit 1 @@ -116,6 +123,7 @@ while true ; do -N | --dry-run ) EXEC_PREFIX="echo EXEC "; shift;; -M | --mos ) unset OPT_UBUNTU; shift;; -U | --ubuntu ) unset OPT_MOS; shift;; + -p | --password ) FUEL_MASTER_PASS="$2"; shift; shift;; -- ) shift; break;; * ) break;; esac @@ -138,6 +146,19 @@ export BINROOT=$(dirname `readlink -f "$0"`) . $BINROOT/config/common.cfg . $BINROOT/config/fuel.cfg +# If running on Fuel node - check if we can connect to backend +if hash fuel2 2>/dev/null; then + echo " * INFO: Verifying connection to the Fuel backend" + if fuel --user=admin --password=$FUEL_ADMIN_PASS release &>/dev/null; then + echo " * INFO: Fuel backend connection OK" + else + echo " * FATAL: Connect to Fuel backend failed. Please verify that Fuel services are up&running." + echo " If services are OK, please make sure you have specified the correct Fuel Master admin password" + usage_short + exit 1 + fi +fi + if [ -z "${RSYNC_PROXY+x}" ] && [ $http_proxy ]; then export http_proxy export RSYNC_PROXY=$http_proxy