function extractJSONString { json=$1
field=$2
json=`echo $jsontr
echo $json
}
#Function getAuthToken ( <ipAddr> )
#
function getAuthToken { local nodeIP=$1 url="https://$nodeIP:8443/sdn/v2.0/auth" login="{
\"login\": {
\"domain\": \"$domain\",
\"user\": \"$user\",
\"password\": \"$pass\"
}
}"
# Attempt to authenticate and extract token if successful.
auth=$(curl | \ | ||
| |||
if [ $? | 0 ]; then |
|
|
teamBackup_log "Unable to authenticate as user $user in $domain domain." exitBackup 1
fi
authToken=`extractJSONString "$auth" "token" sed '/^$/d'` if [ $restore_mode
fi
echo $authToken
}
#==============================================================================
#M A I N #============================================================================== restore_mode=0
#Check for zip package.
command
echo "The zip package must be installed to use this script." exit 1
fi
#Check the user specified script parameters. if [ $#
echo "Usage : backupTeam <user> <domain> [<user@ip:path>]" echo " <user> - user name to access the controller"
echo " <domain> - domain of the controller"
echo " [<user@ip:path>] - remote location to store backup file" echo " user - the login name for the system"
echo " ip - the ip address of the system"
echo " path - where to copy the file to on the remote system" exit 1
fi validateTeamBackupStatus user="$1"
echo
echo domain="$2" remotePath=$3 errorCode=0
#Get the authentication token for the local controller. leaderAuth=`getAuthToken localhost`
#Get the system Information for the local controller. getSysInfo $leaderAuth
#Get the set of team IPs and their associated team roles. extractRole_NodeIP $sysInfo
(validateTeamLead)
#Initiate a backup on each node.
for (( i=0; i<$numNodes; i++ )); do nodeAuth[$i]=`getAuthToken ${ipArr[$i]}` uuidURL="https://${ipArr[$i]}:8443/sdn/v2.0/systems"
nodeUUID[$i]=`get ${ipArr[$i]} ${nodeAuth[$i]} "$uuidURL?ip=${ipArr[$i]}"` nodeUUID[$i]=`extractJSONString "${nodeUUID[$i]}" "uid" sed '/^$/d'`
if [ "${ipArr[$i]}" == "$leaderIp" ]; then
#Skip the leader backup backup, since it will be done last. leaderIndex=$i
continue fi backupNode $i
teamBackup_log "Started backup on ${ipArr[$i]}."
done
#Verify the status of the backup on each node. backup_complete=$numNodes waitTime=$(($BACKUP_WAIT_COUNT*10/60))
for (( k=0; k<$BACKUP_WAIT_COUNT; k++ )); do if [ $backup_complete
teamBackup_log "Backup on all member nodes completed successfully."
B.2 Backing up a controller team 125