标签:rtu star ssi can test pytho mes bre psql
#/bin/bash usage="Usage: $0 -o/--org orgId[Must] -p/--prepare t[Option] -f/--force t[Option] -d/--dry t[Option]" force=0 prepare=0 step=0 dry=0 RED=‘\033[0;31m‘ BLUE=‘\033[1;32m‘ GREEN=‘\033[1;34m‘ NC=‘\033[0m‘ # No Color #read input parameters while [ "$1" != "" ] do case $1 in -o|--org) shift orgId=$1 ;; -f|--force) shift if [ "$1" = "-p" ];then prepare=1 fi force=1 ;; -p|--prepare) shift if [ "$1" = "-f" ];then force=1 fi prepare=1 ;; -d|--dry) shift dry=1 ;; *) echo $usage exit 1 ;; esac shift done if [ -z $orgId ];then echo -e "$RED[Error] Missing orgId!$NC\r\n$usage" exit fi logs="csc_migrage_$orgId.log" check_and_commit() { cmd="" step=`expr "$step" + 1` echo "" echo -e "$BLUE[`date +‘%Y-%m-%d %H:%M:%S‘`][Step $step] exec $1 $NC" if [ $force -eq 0 ];then while true; do read -p "Do you confirm to execute step $1? [y/n]" yn case $yn in [Yy]* ) $2; if [ $dry -eq 1 ];then echo -e "$GREEN [Dry Run]$NC $cmd" else echo $cmd eval $cmd fi break;; [Nn]* ) echo "ignore step $1" ;break;; esac done else $2 if [ $dry -eq 1 ];then echo -e "$GREEN [Dry Run]$NC $cmd" else echo $cmd eval $cmd fi fi } prepare_message_confirm() { echo "Please make sure next items be done" echo -e "${RED} 1.env.sh use correct environment information ${NC}" echo -e "${RED} 2.all gcs vm had added the onecloud replay URL and restarted${NC}" echo -e "${RED} 3.make sure this vm can connect to brown field mongo/redshift/CMC gateway ${NC}" echo -e "${RED} 4.had startup cloud-subscriber with correct version and expose port 3424 ${NC}" echo -e "${RED} 5.brown field subscrbier-sync pod had patched ${NC}" if [ $force -eq 0 ];then while true; do read -p "Do you confirm ? [y/n]" yn case $yn in [Yy]* ) echo "will continue to execute for org :$orgId";break;; [Nn]* ) exit -1 ;break;; esac done fi } test() { echo "test" } migrate_mongo_big_collections() { cmd="python ./mongo_to_psql_sxaccfs.py -m $compass_mongo -n $onecloud_postgres_host -d $onecloud_postgres_db -u $onecloud_postgres_username -p $onecloud_postgres_password" } mongo_to_postgres_noorg() { cmd="python ./mongo_to_psql.py -m $compass_mongo -n $onecloud_postgres_host -d $onecloud_postgres_db -u $onecloud_postgres_username -p $onecloud_postgres_password --no-org" } brown_sub_fullsync() { cmd="curl ‘$old_subscriber_api/sync?orgid=$orgId&mode=fsync-es&save-sync-logs=false&async=false‘" } mongo_to_postgres_relay() { cmd="python ./mongo_to_psql.py -m $compass_mongo -n $onecloud_postgres_host -d $onecloud_postgres_db -u $onecloud_postgres_username -p $onecloud_postgres_password -o $orgId -i in_collection_names.txt" } sub_clean() { cmd="curl ‘http://localhost:3424/migrate-clear?orgId=$orgId‘" } sub_soc() { cmd="curl ‘http://localhost:3424/migrate-usoc?orgId=$orgId‘" } sub_cc() { cmd="curl ‘http://localhost:3424/migrate-subscriber-cc?orgId=$orgId‘" } sub_billing() { cmd="curl ‘http://localhost:3424/migrate-subscriber-billing?orgId=$orgId‘" } sub_update_fee() { cmd="curl ‘http://localhost:3424/calc-usoc-fee?orgId=$orgId‘" } sub_reindex() { cmd="curl ‘$onecloud_subscriber_api/index/reindex?org=$orgId‘" } acs_relay() { sed -i "3i\ \"oneCloudRelay\": true," org_$orgId.json cat org_$orgId.json cmd="curl -X POST -d @org_$orgId.json --url http://$old_gcs_ipaddress:8081/cc/organization/$orgId" } check_org_exists() { curl -s http://$old_gcs_ipaddress:8081/cc/organization/$orgId>org_$orgId.json if [ `cat org_$orgId.json|grep ‘No organization found‘|wc -l` -eq 1 ];then echo -e "$RED org:$orgId is not exist! $NC" rm -rf org_$orgId.json exit -1 fi } acs_workflow() { cmd="curl -X POST --url ‘http://$onecloud_gcs_ipaddress:8081/cc/workflow/audit?orgId=$orgId‘" } mongo_to_postgres_cloud() { cmd="python ./mongo_to_psql.py -m $cloud_mongo -n $onecloud_postgres_host -d $onecloud_postgres_db -u $onecloud_postgres_username -p $onecloud_postgres_password -o $orgId" } mongo_to_postgres_compass_others() { cmd="python ./mongo_to_psql.py -m $compass_mongo -n $onecloud_postgres_host -d $onecloud_postgres_db -u $onecloud_postgres_username -p $onecloud_postgres_password -o $orgId -e ex_collection_names.txt" } mongo_to_mongo() { cmd="./migrate_mongo_to_mongo.sh $orgId" } copy_cc_org() { cmd="curl -X POST -d @org_$orgId.json --url http://$onecloud_gcs_ipaddress:8081/cc/organization/$orgId" } main() { if [ $force -eq 0 ];then prepare_message_confirm fi if [ $prepare -eq 1 ];then check_and_commit "Migrate 2 Big Collection of Mongo" migrate_mongo_big_collections check_and_commit "Mongo2Postgres cross org files" mongo_to_postgres_noorg fi check_org_exists check_and_commit "Subscriber Full Sync for org $orgId" brown_sub_fullsync check_and_commit "Migrate Compass Mongo for ACS relay" mongo_to_postgres_relay check_and_commit "Subscriber Migrate Clean for org $orgId" sub_clean check_and_commit "Subscriber Migrate usoc for org $orgId" sub_soc check_and_commit "Subscriber Migrate cc subscribers for $orgId" sub_cc check_and_commit "Subscriber Migrate billing for $orgId" sub_billing check_and_commit "Subscriber Migrate fee for $orgId" sub_update_fee check_and_commit "Subscriber reindex in green for $orgId" sub_reindex check_and_commit "Migrate CC org to green " copy_cc_org check_and_commit "Enable ACS Relay for org $orgId" acs_relay check_and_commit "Migrate ACS workflow for $orgId" acs_workflow check_and_commit "Copy ALL Cloud Collections Mongo2Postgres" mongo_to_postgres_cloud check_and_commit "Copy left compass collections Mongo2Postgres" mongo_to_postgres_compass_others check_and_commit "Migrate Cloud Mongo to New Cloud Mongo" mongo_to_mongo } source env.sh main
标签:rtu star ssi can test pytho mes bre psql
原文地址:https://www.cnblogs.com/tben/p/10784090.html