HP OneView Manual del usuario

Página 286

Advertising
background image

$downloadUri

try
{
$testCurlSslOption = curl -V
if ($testCurlSslOption -match "SSL")
{
invoke-expression $curlDownloadCommand
}
else
{
if ($global:interactiveMode -eq 1)
{
Write-Host "Version of curl must support SSL to get improved download performance."
}
else
{
Write-EventLog -EventId 100 -LogName Application -Source backup.ps1 -Message "Version of curl must
support SSL to get improved download performance"
}

return download-Backup-without-curl $backupResource $authValue $hostname
}

if ($LASTEXITCODE -ne 0)
{
$errorResponse = invoke-expression $curlGetDownloadErrorCommand
if ($global:interactiveMode -eq 1)
{
Write-Host "Download using curl error: $errorResponse"
}
else
{
Write-EventLog -EventId 100 -LogName Application -Source backup.ps1 -Message "Download error:
$errorResponse"
}

if (Test-Path $filePath)
{
Remove-Item $filePath
}
return
}

if ($global:interactiveMode -eq 1)
{
Write-Host "Backup download complete!"
}
}
catch [System.Management.Automation.CommandNotFoundException]
{
return download-Backup-without-curl $backupResource $authValue $hostname
}
catch [System.Exception]
{
Write-Host "Not able to download backup"
Write-Host $error[0].Exception
return
}

return $filePath
}

##### Function to download the Backup file without using the curl command #####
function download-Backup-without-curl ([PSCustomObject]$backupResource,[string]$authValue,[string]$hostname)
{
<#
.DESCRIPTION
Downloads the backup file from the appliance to the local system (without using curl)

.PARAMETER backupResource
Backup resource containing Uri for downloading

.PARAMETER authValue
The authorized sessionID

.PARAMETER hostname
The IP address of the appliance

.INPUTS
None, does not accept piping

.OUTPUTS
The absolute path of the download file

.EXAMPLE
download-backup-without-curl $backupResource $sessionID https://11.111.11.111
#>

# appends Uri ( obtained from previous function) to IP address
$downloadUri = $hostname + $backupResource.downloadUri

286 Ejemplos de secuencias de comandos de copia de seguridad y restauración

Advertising