EasyManua.ls Logo

HP HPE VAN SDN Controller 2.7 - Page 207

HP HPE VAN SDN Controller 2.7
231 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
chmod 777 $RESTORE_TEAM_DIR
}
#------------------------------------------------------------------------------
# Function validate_my_Ip ( )
# Validates the configured node IP against the backed up IP addresses.
#------------------------------------------------------------------------------
function validate_my_Ip {
for (( v=0; v<numBackup; v++ )); do
myip='ifconfig|grep -o "${backupIp[$v]}"'
if [ "$myip" != "" ]; then
teamBackup_log "IP $myip is a valid member of the team."
return
fi
done
teamBackup_log "IP $myip is not a valid member of the team, exiting."
exitBackup 1
}
#------------------------------------------------------------------------------
# Function upload_backup_file ( <systemIp> <systemUUID> <authToken> <zipFile> )
# Uploads backup file to the specific nodes of the team.
#------------------------------------------------------------------------------
function upload_backup_file {
local sysIp=$1
local sysUUID=$2
local sysAuth=$3
local uploadUrl="https://$sysIp:8443/sdn/v2.0/restore/backup"
local zipFile=$4
if [ ! -f $zipFile ]; then
teamBackup_log "File $zipFile does not exist."
exitBackup 1
fi
curl --noproxy $sysIp -X POST --fail -ksSfL --url $uploadUrl \
-H "X-Auth-Token:$sysAuth"\
--data-binary @$zipFile
if [ $? -ne 0 ]; then
teamBackup_log "Failed to upload backup $zipFile to $sysIp."
exitBackup 1
fi
teamBackup_log "Backup $zipFile uploaded successfully to $sysIp."
}
#------------------------------------------------------------------------------
# Function restore_node ( <systemIp> <systemUUID> <authToken> )
# Restores a particular node.
#------------------------------------------------------------------------------
function restore_node {
local sysIp=$1
local sysUUID=$2
local sysAuth=$3
local restoreUrl="https://$sysIp:8443/sdn/v2.0/restore"
# Set the IP first. Ignore errors since this only works for standalone.
put $sysIp $sysAuth "https://$sysIp:8443/sdn/v2.0/systems/$sysUUID" \
"{\"system\":{\"ip\":\"$sysIp\"}}" > /dev/null 2>&1
restoreSession='post $sysIp $sysAuth $restoreUrl '
if [ $errorCode -ne 0 ]; then
teamBackup_log "Failed to start restore on node $sysIp."
exitBackup 1
fi
teamBackup_log "Started restore on node $sysIp."
}
#------------------------------------------------------------------------------
# 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/systems"
for (( k=0; k<100; k++ )); do
sleep 30
authToken='getAuthToken $sysIp'
[ "$authToken" == "" ] && continue
# Try to contact the system.
data='get $sysIp $authToken "$sysUr?ip=$sysIp"'
[ "$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
Restoring a controller team 207

Table of Contents

Related product manuals