HP VAN SDN Controller Administrator Guide

98
#------------------------------------------------------------------------------
# Function validate_node_status ( )
# Validates node status after the restore.
#------------------------------------------------------------------------------
function validate_node_status {
local sysIp=$1
# Wait for the restore to complete.
local sysUrl="https://$sysIp:8443/sdn/v2.0/contact"
for (( k=0; k<100; k++ )); do
sleep 30
authToken=`getAuthToken $sysIp`
[ "$authToken" == "" ] && continue
# Try to contact the system.
data=`get $sysIp $authToken $sysUrl`
[ "$data" == "" ] && continue
teamBackup_log "Node:$sysIp came up successfully." && return
done
teamBackup_log "Node:$sysIP failed to come up."
exitBackup 1
}
#------------------------------------------------------------------------------
# Function restore_nodes ( <ipAddrArray> )
# Restores only the specified node(s).
#------------------------------------------------------------------------------
function restore_nodes {
local leaderindex=-1
local restoreIpArr=("$@")
local numNodes=${#restoreIpArr[@]}
for (( i=0; i<$numNodes; i++ )); do
# Get the auth token for a specific node.
restoreAuth[$i]=`getAuthToken ${restoreIpArr[$i]}`
if [ "${restoreAuth[$i]}" == "" ]; then
teamBackup_log "Failed to get the auth Token for ${restoreIpArr[$i]},
can't start restore."
exitBackup 1
fi
uuidURL="https://${restoreIpArr[$i]}:8443/sdn/v2.0/contact"
restoreUUID[$i]=`get ${restoreIpArr[$i]} ${restoreAuth[$i]} "$uuidURL"`
if [ "${restoreUUID[$i]}" == "" ]; then
teamBackup_log "Failed to get the UUID for ${restoreIpArr[$i]}, can't
start restore."
exitBackup 1
fi
restoreUUID[$i]=`extractJSONString "${restoreUUID[$i]}" "uid" | sed '/^$/d'`
teamBackup_log "UUID for ${restoreIpArr[$i]} is ${restoreUUID[$i]}"
# Upload the backup files to a specific node.
local ipFileName="sdn_controller_backup_${restoreIpArr[$i]}*.zip"
local zipFile=`ls $RESTORE_BACKUP_FILESET/$ipFileName`
upload_backup_file ${restoreIpArr[$i]} ${restoreUUID[$i]} \
${restoreAuth[$i]} $zipFile
# Check if this is the leader node from the backup set.
local leaderZip=`echo $zipFile|grep "Leader"`
[ "$leaderZip" != "" ] && leaderIndex=$i
done
# Start restore in the leader node first before all the other nodes.