HP OneView Manual del usuario

Página 283

Advertising
background image

{
$taskResourceJson = setup-request -Uri $fullBackupUri -method "POST" -accept "application/json" -contentType
"application/json" -authValue $authValue
}
else
{
$taskUri = setup-request -Uri $fullBackupUri -method "POST" -accept "application/json" -contentType
"application/json" -authValue $authValue -returnLocation $true
if ($taskUri -ne $null)
{
$taskResourceJson = setup-request -Uri $taskUri -method "GET" -accept "application/json" -contentType
"application/json" -authValue $authValue
}
}
if ($taskResourceJson -ne $null)
{
return $taskResourceJson | 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

}
}
}

##### Polling to see if backup is finished ######
function waitFor-completion ([object]$taskResource,[string]$authValue,[string]$hostname)
{
<#
.DESCRIPTION
Checks the status of the backup every twenty seconds, stops when status changes from running to a
different status

.PARAMETER taskResource
The response object from the backup-appliance method

.PARAMETER authValue
The authorized session ID

.PARAMETER hostname
The appliance to connect to (in https://{ipaddress} format)

.INPUTS
None, does not accept piping

.OUTPUTS
The new task resource object, which contains the Uri to get the backup resource in the next function

.EXAMPLE
$taskResource = waitFor-Completion $taskResource $sessionID $hostname
#>

# extracts the Uri of the task Resource from itself, to poll repeatedly
$taskResourceUri = $taskResource.uri
if ($taskResourceUri -eq $null)
{
# Caller will provide the error message
return
}

# appends the Uri to the hostname to create a fully-qualified Uri
$fullTaskUri = $hostname + $taskResourceUri

# retries if unable to get backup progress information
$errorCount = 0
$errorMessage = ""

if ($global:interactiveMode -eq 1)
{
Write-Host "Backup initiated."
Write-Host "Checking for backup completion, this may take a while."
}

# a while loop to determine when the backup process is finished
do
{

try

C.1 Secuencia de comandos de copia de seguridad de ejemplo 283

Advertising