Skip to content

Instantly share code, notes, and snippets.

@abutcher
Last active December 19, 2015 06:58
Show Gist options
  • Select an option

  • Save abutcher/5914814 to your computer and use it in GitHub Desktop.

Select an option

Save abutcher/5914814 to your computer and use it in GitHub Desktop.
Openshift ose gear migration script to be run from broker...
#!/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
@abutcher

abutcher commented Jul 3, 2013

Copy link
Copy Markdown
Author

@tbielawa|openShiftPatching | abutcher|ose: plz 2 add 'exclude uuids' options
@tbielawa|openShiftPatching | so I can ose-migrate -t foo -f foo -x 51b19033f21a34a6a9000002 51b19033f21a34a6a9000002 51b19033f21a34a6a9000004 ....

@abutcher

abutcher commented Jul 3, 2013

Copy link
Copy Markdown
Author

^^ Added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment