HP Matrix 7.2 KVM Private Cloud Backup and Restore

Table Of Contents
Attempts to send a web request to the appliance and obtain a authorized sessionID.
.PARAMETER username
The username to log into the remote appliance
.PARAMETER password
The correct password associated with username
.PARAMETER hostname
The appliance address to send the request to (in https://{ipaddress} format)
.INPUTS
None, does not accept piping
.OUTPUTS
Outputs the response body containing the needed session ID.
.EXAMPLE
$authtoken = login-appliance $username $password $hostname
#>
# the particular URI on the Appliance to reqest an "auth token"
$loginURI = "/rest/login-sessions"
# append the URI to the end of the IP address to obtain a full URI
$fullLoginURI = $hostname + $loginURI
# create the request body as a hash table, then convert it to json format
$body = @{ userName = $username; password = $password } | convertTo-json
# use setup-request to issue the REST request to login and get the response
try
{
$loginResponse = setup-request -Uri $fullLoginURI -method "POST" -accept "application/json"
-contentType "application/json" -Body $body
if ($loginResponse -ne $null)
{
$loginResponse | convertFrom-Json
}
}
catch [System.Exception]
{
if ($global:interactiveMode -eq 1)
{
Write-Host $error[0].Exception.Message
}
else
{
Write-EventLog -EventId 100 -LogName Application -Source backup.ps1 -Message
$error[0].Exception.Message
}
}
}
##### Executing backup ######
function backup-Appliance ([string]$authValue,[string]$hostname)
{
<#
.DESCRIPTION
Gives the appliance the command to start creating a backup
.PARAMETER authValue
The authorized sessionID given by login-appliance
.PARAMETER hostname
The location of the appliance to connect to (in https://{ipaddress} format)
.INPUTS
None, does not accept piping
.OUTPUTS
The object returned by the appliance
.EXAMPLE
$backupResponse = backup-Appliance $sessionID $hostname
#>
# append the appropriate URI to the IP address of the Appliance
40