Skip to content

Report Image Download Progress #24180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,47 @@ function New-AzStackHCIVMImage{

if ($PSCmdlet.ParameterSetName -eq "Marketplace")
{
return Az.StackHCIVM.internal\New-AzStackHCIVMMarketplaceGalleryImage @PSBoundParameters
$PSBoundParameters['NoWait'] = $true
$PSBoundParameters['ErrorAction'] = 'Stop'
try {
Az.StackHCIVM.internal\New-AzStackHCIVMMarketplaceGalleryImage @PSBoundParameters
Start-Sleep -Seconds 60
$PercentCompleted = 0
Write-Progress -Activity "Download Percentage: " -Status "$PercentCompleted % Complete:" -PercentComplete $PercentCompleted
$null = $PSBoundParameters.Remove("Version")
$null = $PSBoundParameters.Remove("URN")
$null = $PSBoundParameters.Remove("Tag")
$null = $PSBoundParameters.Remove("StoragePathId")
$null = $PSBoundParameters.Remove("Sku")
$null = $PSBoundParameters.Remove("Publisher")
$null = $PSBoundParameters.Remove("Offer")
$null = $PSBoundParameters.Remove("OSType")
$null = $PSBoundParameters.Remove("ImagePath")
$null = $PSBoundParameters.Remove("CustomLocationId")
$null = $PSBoundParameters.Remove("CloudInitDataSource")
$null = $PSBoundParameters.Remove("Location")
$null = $PSBoundParameters.Remove("NoWait")
while ($PercentCompleted -ne 100 ) {
$image = Az.StackHCIVM.internal\Get-AzStackHCIVMMarketplaceGalleryImage @PSBoundParameters
$PercentCompleted = $image.StatusProgressPercentage
if ($PercentCompleted -eq $null){
$PercentCompleted = 0
}
Write-Progress -Activity "Download Percentage: " -Status "$PercentCompleted % Complete" -PercentComplete $PercentCompleted
Start-Sleep -Seconds 5
if ($image.ProvisioningStatus -eq "Failed") {
Break
}
}
if ($image.ProvisioningStatus -eq "Failed"){
Write-Error $image.StatusErrorMessage -ErrorAction Stop
}

} catch {
Write-Error $_.Exception.Message -ErrorAction Stop
}


} elseif ($PSCmdlet.ParameterSetName -eq "MarketplaceURN") {
if ($URN -match $urnRegex){
$publisher = $Matches.publisher.ToLower()
Expand All @@ -320,15 +359,54 @@ function New-AzStackHCIVMImage{
} else {
Write-Error "Invalid URN provided: $URN. Valid URN format is Publisher:Offer:Sku:Version ." -ErrorAction Stop
}

$PSBoundParameters['NoWait'] = $true
$PSBoundParameters['ErrorAction'] = 'Stop'
try {
Az.StackHCIVM.internal\New-AzStackHCIVMMarketplaceGalleryImage @PSBoundParameters
Start-Sleep -Seconds 60
$PercentCompleted = 0
Write-Progress -Activity "Download Percentage: " -Status "$PercentCompleted % Complete:" -PercentComplete $PercentCompleted
$null = $PSBoundParameters.Remove("Version")
$null = $PSBoundParameters.Remove("URN")
$null = $PSBoundParameters.Remove("Tag")
$null = $PSBoundParameters.Remove("StoragePathId")
$null = $PSBoundParameters.Remove("Sku")
$null = $PSBoundParameters.Remove("Publisher")
$null = $PSBoundParameters.Remove("Offer")
$null = $PSBoundParameters.Remove("OSType")
$null = $PSBoundParameters.Remove("ImagePath")
$null = $PSBoundParameters.Remove("CustomLocationId")
$null = $PSBoundParameters.Remove("CloudInitDataSource")
$null = $PSBoundParameters.Remove("Location")
$null = $PSBoundParameters.Remove("NoWait")
while ($PercentCompleted -ne 100 ) {
$image = Az.StackHCIVM.internal\Get-AzStackHCIVMMarketplaceGalleryImage @PSBoundParameters
$PercentCompleted = $image.StatusProgressPercentage
if ($PercentCompleted -eq $null){
$PercentCompleted = 0
}
Write-Progress -Activity "Download Percentage: " -Status "$PercentCompleted % Complete" -PercentComplete $PercentCompleted
Start-Sleep -Seconds 5
if ($image.ProvisioningStatus -eq "Failed") {
Break
}
}
if ($image.ProvisioningStatus -eq "Failed"){
Write-Error $image.StatusErrorMessage -ErrorAction Stop
}

} catch {
Write-Error $_.Exception.Message -ErrorAction Stop
}

return Az.StackHCIVM.internal\New-AzStackHCIVMMarketplaceGalleryImage @PSBoundParameters

}

if ($PSCmdlet.ParameterSetName -eq "GalleryImage")
{

return Az.StackHCIVM.internal\New-AzStackHCIVMGalleryImage @PSBoundParameters
Az.StackHCIVM.internal\New-AzStackHCIVMGalleryImage @PSBoundParameters
}


Expand Down
11 changes: 11 additions & 0 deletions src/StackHCIVM/StackHCIVM.Autorest/examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Examples
This directory contains examples from the exported cmdlets of the module. When `build-module.ps1` is ran, example stub files will be generated here. If your module support Azure Profiles, the example stubs will be in individual profile folders. These example stubs should be updated to show how the cmdlet is used. The examples are imported into the documentation when `generate-help.ps1` is ran.

## Info
- Modifiable: yes
- Generated: partial
- Committed: yes
- Packaged: no

## Purpose
This separates the example documentation details from the generated documentation information provided directly from the generated cmdlets. Since the cmdlets don't have examples from the REST spec, this provides a means to add examples easily. The example stubs provide the markdown format that is required. The 3 core elements are: the name of the example, the code information of the example, and the description of the example. That information, if the markdown format is followed, will be available to documentation generation and be part of the documents in the `..\docs` folder.
Loading