EasyManua.ls Logo

HP HPE VAN SDN Controller 2.7 - Page 209

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...
errorCode=$?
let "attempts = $attempts + 1"
if [ 35 -eq $errorCode ]; then
teamBackup_log "SSL error on POST to $postUrl, retrying..."
continue;
fi
break;
done
echo $postRes
}
#------------------------------------------------------------------------------
# Function put ( <ipAddr> <authToken> <url> <data> )
# Performs a PUT of the specified data.
#------------------------------------------------------------------------------
function put {
local putIP=$1
local putToken=$2
local putUrl=$3
local putData=$4
local attempts=0
while [ $attempts -lt 5 ]; do
putRes='curl --noproxy $putIP --header "X-Auth-Token:$putToken" \
--fail -ksS -L -f --request PUT "$putUrl" --data-binary "$putData"'
errorCode=$?
let "attempts = $attempts + 1"
if [ 35 -eq $errorCode ]; then
teamBackup_log "SSL error on POST to $putUrl, retrying"
continue;
fi
break;
done
echo $putRes
}
#------------------------------------------------------------------------------
# Function extractJSONString ( <json> <fieldName> )
# Extracts the Json value corresponding to the field name.
#------------------------------------------------------------------------------
function extractJSONString {
json=$1
field=$2
json='echo $json|tr -d '"'| sed -e 's/\,\|{/\n/g'|grep -w "$field"| \
cut -d ':' -f2-'
echo $json
}
#------------------------------------------------------------------------------
# Function getAuthToken ( <ipAddr> )
# Log-in and get the UID.
#------------------------------------------------------------------------------
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 --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=1
selective_restore=0
# Check for unzip package.
command -v unzip &> /dev/null
if [ $? -ne 0 ]; then
echo "The unzip package must be installed to use this script."
exit 1
fi
# Check the user specified script parameters.
if [ $# -lt 3 ]; then
echo "Usage : restoreTeam <user> <domain> [<ip1> <ip2> ...] <user@IP:path>"
echo " <user> - user name to access the controller"
echo " <domain> - domain of the controller"
echo " [<ip1> <ip2> ...] - ip(s) of node(s) to be restored; if none are specified all nodes are restored"
echo " <user@IP:path> - remote location to retrieve backup file"
echo " user - the login name for the system"
echo " ip - the ip address of the system"
Restoring a controller team 209

Table of Contents

Related product manuals