HP VAN SDN Controller Administrator Guide

93
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 --noproxy $nodeIP -X POST --fail -ksSfL --url "$url" \
-H "Content-Type: application/json" --data-binary "$login" 2>&1)
if [ $? -ne 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 -ne 1 ] && [ "$authToken" == "" ]; then
teamBackup_log "Failed to get the authentication token."
exitBackup 1
fi
echo $authToken
}
#==============================================================================
# M A I N
#==============================================================================
restore_mode=0
# Check for zip package.
command -v zip &> /dev/null
if [ $? -ne 0 ]; then
echo "The zip package must be installed to use this script."
exit 1
fi
# Check the user specified script parameters.
if [ $# -lt 2 ]; then
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 -n "Enter Controller Password: "
read -s pass
echo
domain="$2"
remotePath=$3
errorCode=0
# Get the authentication token for the local controller.
leaderAuth=`getAuthToken localhost`