Skip to content

Commit

Permalink
fix: increase Get-VCFSystemPrecheckTask output verbosity (#256)
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Thaler <nathan.thaler@broadcom.com>
  • Loading branch information
nthaler-vmware committed Jan 3, 2024
1 parent 59ecfcd commit 960caaf
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release History

## v2.5.0

> Released: Unreleased
- Updated `Get-VCFSystemPrecheckTask` cmdlet with optional parameter `failureOnly`.

## v2.4.1

> Released: 2023-12-15
Expand Down
2 changes: 1 addition & 1 deletion PowerVCF.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
RootModule = 'PowerVCF.psm1'

# Version number of this module.
ModuleVersion = '2.4.1.1000'
ModuleVersion = '2.5.0.1000'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
30 changes: 26 additions & 4 deletions PowerVCF.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -4261,27 +4261,49 @@ Function Get-VCFSystemPrecheckTask {
Retrieves the status of a system level precheck task.
.DESCRIPTION
The Get-VCFSystemPrecheckTask mdlet retrieves the status of a system level precheck task that can be polled
The Get-VCFSystemPrecheckTask cmdlet retrieves the status of a system level precheck task that can be polled
and monitored.
.EXAMPLE
Get-VCFSystemPrecheckTask -id 4d661acc-2be6-491d-9256-ba3c78020e5d
This example shows how to retrieve the status of a system level precheck task by unique ID.
.EXAMPLE
Get-VCFSystemPrecheckTask -id 4d661acc-2be6-491d-9256-ba3c78020e5d -failureOnly
This example shows how to retrieve only failed subtasks from the system level precheck task by unique ID.
.PARAMETER id
Specifies the unique ID of the system level precheck task.
.PARAMETER failureOnly
Specifies to return only the failed subtasks.
#>

Param (
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$id
[Parameter (Mandatory = $true)] [ValidateNotNullOrEmpty()] [String]$id,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$failureOnly
)

Try {
createHeader # Set the Accept and Authorization headers.
checkVCFToken # Validate the access token and refresh, if necessary.
$uri = "https://$sddcManager/v1/system/prechecks/tasks/$id"
$response = Invoke-RestMethod -Method GET -Uri $uri -Headers $headers -ContentType 'application/json'
$response

Do {
# Keep checking until status is not IN_PROGRESS
$response = Invoke-RestMethod -Method GET -Uri $uri -Headers $headers -ContentType 'application/json'
Start-Sleep -Seconds 2
} While ($response.status -eq "IN_PROGRESS")

if ($response.status -eq "FAILED" -and $PsBoundParameters.ContainsKey("failureOnly")) {
$failed_task = $response.subTasks | Where-Object { $_.status -eq "FAILED" }
$failed_subtask = $failed_task.stages | Where-Object { $_.status -eq "FAILED" }
$failed_subtask
} else {
$response
}

} Catch {
ResponseException -object $_
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ Get-VCFSystemPrecheckTask -id 4d661acc-2be6-491d-9256-ba3c78020e5d

This example shows how to retrieve the status of a system level precheck task by unique ID.

### Example 2

```powershell
Get-VCFSystemPrecheckTask -id 4d661acc-2be6-491d-9256-ba3c78020e5d -failureOnly
```

This example shows how to retrieve only failed subtasks from the system level precheck task by unique ID.

## Parameters

### -id
Expand All @@ -41,7 +49,21 @@ Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -failureOnly

Specifies to return only the failed subtasks.

```yaml
Type: Switch
Parameter Sets: (All)
Aliases:

Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### Common Parameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).

0 comments on commit 960caaf

Please sign in to comment.