Last active
December 19, 2015 06:58
-
-
Save abutcher/5914814 to your computer and use it in GitHub Desktop.
Openshift ose gear migration script to be run from broker...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e | |
| OPTS=`getopt -o hdt:f:x: --long help,dry-run,to-host:,from-host:,exclude: -n 'parse-options' -- "$@"` | |
| usage(){ | |
| echo "Usage: $0 --help --dry-run --to-host [HOST] --from-host [HOST] --exclude \"[UUID [UUID] ...]\"" | |
| exit 1 | |
| } | |
| if [ $? != 0 ] ; then usage; exit 1 ; fi | |
| eval set -- "$OPTS" | |
| TO_HOST="" | |
| FROM_HOST="" | |
| DRY_RUN=1 | |
| EXCLUDE_LIST="" | |
| while true; do | |
| case "$1" in | |
| -h | --help ) usage; shift ;; | |
| -d | --dry-run ) DRY_RUN=0; shift ;; | |
| -t | --to-host ) TO_HOST="$2"; shift 2 ;; | |
| -f | --from-host ) FROM_HOST="$2"; shift 2 ;; | |
| -x | --exclude ) EXCLUDE_LIST="$2"; shift 2;; | |
| * ) break ;; | |
| -- ) shift; break ;; | |
| esac | |
| done | |
| [ -z $TO_HOST ] && echo "Did not supply --to-host bailing!" && exit 1 | |
| [ -z $FROM_HOST ] && echo "Did not supply --from-host bailing!" && exit 1 | |
| ssh-add -l > /dev/null | |
| GEARS=`ssh -oStrictHostKeyChecking=no root@$FROM_HOST "oo-admin-ctl-gears list"` | |
| for GEAR in $GEARS; | |
| do | |
| echo "**************************************************************************" | |
| if [[ $EXCLUDE_LIST =~ $GEAR ]]; | |
| then | |
| echo | |
| echo "Skipping $GEAR" | |
| echo | |
| else | |
| COMMAND="oo-admin-move --gear_uuid $GEAR -i $TO_HOST" | |
| if [ $DRY_RUN -eq 0 ]; | |
| then | |
| echo | |
| echo $COMMAND; | |
| echo | |
| else | |
| echo | |
| $COMMAND | |
| echo | |
| fi | |
| fi | |
| done |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
^^ Added.