Skip to content

Commit

Permalink
feat: add monitorStatus optional param to Get-VCFTask (#259)
Browse files Browse the repository at this point in the history
Add `monitorStatus` optional param to `Get-VCFTask` to actively monitor a running task until it is no longer in progress.

Signed-off by: Nathan Thaler <nathan.thaler@broadcom.com>
  • Loading branch information
nthaler-vmware committed Jan 12, 2024
1 parent b6afdcf commit 07bc4e3
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 23 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- Updated `Get-VCFSystemPrecheckTask` cmdlet with optional parameter `failureOnly`.
- Updated `Get-VCFPersonality` cmdlet with optional parameter `name`.

- Updated `Get-VCFTask` cmdlet with optional parameter `monitorStatus`

## v2.4.1

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 2-Clause License

Copyright 2023 Broadcom. All Rights Reserved.
Copyright 2023-2024 Broadcom. All Rights Reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
following conditions are met:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Broadcom. All Rights Reserved.
# Copyright 2023-2024 Broadcom. All Rights Reserved.
# SPDX-License-Identifier: BSD-2

docs-install:
Expand Down
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PowerShell Module for VMware Cloud Foundation
Copyright 2023 Broadcom. All Rights Reserved.
Copyright 2023-2024 Broadcom. All Rights Reserved.

This product is licensed to you under the BSD-2 license (the "License"). You may not use this product except in
compliance with the BSD-2 License.
Expand Down
6 changes: 3 additions & 3 deletions PowerVCF.psd1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Broadcom. All Rights Reserved.
# Copyright 2023-2024 Broadcom. All Rights Reserved.
# SPDX-License-Identifier: BSD-2

# Module manifest for module 'PowerVCF'
Expand All @@ -11,7 +11,7 @@
RootModule = 'PowerVCF.psm1'

# Version number of this module.
ModuleVersion = '2.5.0.1001'
ModuleVersion = '2.5.0.1002'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand All @@ -26,7 +26,7 @@ Author = 'Broadcom'
CompanyName = 'Broadcom'

# Copyright statement for this module
Copyright = 'Copyright 2023 Broadcom. All Rights Reserved.'
Copyright = 'Copyright 2023-2024 Broadcom. All Rights Reserved.'

# Description of the functionality provided by this module
Description = 'PowerShell Module for VMware Cloud Foundation'
Expand Down
26 changes: 23 additions & 3 deletions PowerVCF.psm1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Broadcom. All Rights Reserved.
# Copyright 2023-2024 Broadcom. All Rights Reserved.
# SPDX-License-Identifier: BSD-2

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
Expand Down Expand Up @@ -3291,8 +3291,8 @@ Function Get-VCFPersonality {
$uri = "https://$sddcManager/v1/personalities/$id"
$response = Invoke-RestMethod -Method GET -Uri $uri -Headers $headers
$response
}
if ($PsBoundParameters.ContainsKey("name")) {
}
if ($PsBoundParameters.ContainsKey("name")) {
$uri ="https://$sddcManager/v1/personalities?personalityName=$name"
$response = Invoke-RestMethod -Method GET -Uri $uri -Headers $headers
# depending on the composition of the image, the response body may or may not contain elements
Expand Down Expand Up @@ -4352,15 +4352,23 @@ Function Get-VCFTask {
Get-VCFTask -status SUCCESSFUL
This example shows how to retrieve all tasks with a specific status.
.EXAMPLE
Get-VCFTask -id 7e1c2eee-3177-4e3b-84db-bfebc83f386a -monitorStatus
This example shows how to actively monitor a task until it completes.
.PARAMETER id
Specifies the unique ID of the task.
.PARAMETER monitorStatus
Specifies the option to actively monitor a task until it completes
.PARAMETER status
Specifies the status of the task. One of: SUCCESSFUL, FAILED.
#>

Param (
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [String]$id,
[Parameter (Mandatory = $false)] [ValidateNotNullOrEmpty()] [Switch]$monitorStatus,
[Parameter (Mandatory = $false)] [ValidateSet("SUCCESSFUL", "FAILED")] [String]$status
)

Expand All @@ -4384,6 +4392,18 @@ Function Get-VCFTask {
}
}
$response
if ($PsBoundParameters.ContainsKey("monitorStatus")) {
$pollCount = 0
While ($response.status -eq "IN_PROGRESS") {
Write-Host "Task still in state IN_PROGRESS. Will re-poll in 30 seconds"
Start-Sleep -Seconds 30
$pollCount++
}
# return the updated task status if and only if the status has changed
if (($response.status -ne "IN_PROGRESS") -and $($pollCount) ) {
$response
}
}
} elseif ($PsBoundParameters.ContainsKey("status")) {
$uri = "https://$sddcManager/v1/tasks/"
$response = Invoke-RestMethod -Method GET -Uri $uri -Headers $headers
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ You can also start a discussion on the GitHub [discussions][gh-discussions] area

## License

Copyright 2023 Broadcom. All Rights Reserved.
Copyright 2023-2024 Broadcom. All Rights Reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Expand Down
14 changes: 7 additions & 7 deletions docs/community/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ This PowerShell module is the work of many contributors and the project team app
Thank you for your interest in the project. Whether it's a bug report, enhancement, correction, or
additional documentation, we greatly value feedback and contributions from our community.

Name | Title | Role | GitHub |
------------------|------------------------------------------|--------------|------------------------------------------------------------------|
Brian O'Connell | Staff II Solutions Architect, VMware | Maintainer | [:fontawesome-brands-github:](https://github.com/LifeOfBrianOC) |
Gary Blake | Senior Staff Solutions Architect, VMware | Maintainer | [:fontawesome-brands-github:](https://github.com/GaryJBlake) |
Ken Gould | Staff II Solutions Architect, VMware | Maintainer | [:fontawesome-brands-github:](https://github.com/feardamhan) |
Ryan Johnson | Senior Staff Solutions Architect, VMware | Maintainer | [:fontawesome-brands-github:](https://github.com/tenthirtyam) |
Giuliano Bertello | Staff Solutions Architect, VMware | Collaborator | [:fontawesome-brands-github:](https://github.com/GiulianoBerteo) |
Name | Role | GitHub |
------------------|--------------|------------------------------------------------------------------|
Brian O'Connell | Maintainer | [:fontawesome-brands-github:](https://github.com/LifeOfBrianOC) |
Gary Blake | Maintainer | [:fontawesome-brands-github:](https://github.com/GaryJBlake) |
Ken Gould | Maintainer | [:fontawesome-brands-github:](https://github.com/feardamhan) |
Ryan Johnson | Maintainer | [:fontawesome-brands-github:](https://github.com/tenthirtyam) |
Giuliano Bertello | Collaborator | [:fontawesome-brands-github:](https://github.com/GiulianoBerteo) |
26 changes: 25 additions & 1 deletion docs/documentation/functions/tasks/Get-VCFTask.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Retrieves a list of tasks.
## Syntax

```powershell
Get-VCFTask [[-id] <String>] [[-status] <String>] [<CommonParameters>]
Get-VCFTask [[-id] <String>] [[-status] <String>] [-monitorStatus] [<CommonParameters>]
```

## Description
Expand Down Expand Up @@ -40,6 +40,14 @@ Get-VCFTask -status SUCCESSFUL

This example shows how to retrieve all tasks with a specific status.

### Example 4

```powershell
Get-VCFTask -id 7e1c2eee-3177-4e3b-84db-bfebc83f386a -monitorStatus
```

This example shows how to actively monitor the progress of a task until it completes.

## Parameters

### -id
Expand Down Expand Up @@ -74,6 +82,22 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -monitorStatus

Specifies the option to monitor a task's progress.

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

Required: False
Position: 3
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).
7 changes: 3 additions & 4 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ edit_uri: blob/main/docs/

# Copyright
copyright: |
Copyright &copy; 2005-2023 Broadcom. All Rights Reserved.<br/>
Copyright &copy; 2005-2024 Broadcom. All Rights Reserved.<br/>
The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.<br/><br/>
# Configuration
Expand Down Expand Up @@ -69,7 +69,6 @@ plugins:
jinja_options:
variable_start_string: "${{"
variable_end_string: "}}"
- git-authors
- git-revision-date-localized:
enabled: !ENV [CI, false]
enable_creation_date: false
Expand Down Expand Up @@ -103,8 +102,8 @@ markdown_extensions:
- footnotes
- md_in_html
- pymdownx.emoji:
emoji_index: !!python/name:materialx.emoji.twemoji
emoji_generator: !!python/name:materialx.emoji.to_svg
emoji_index: !!python/name:material.extensions.emoji.twemoji
emoji_generator: !!python/name:material.extensions.emoji.to_svg
options:
custom_icons:
- material/.icons
Expand Down

0 comments on commit 07bc4e3

Please sign in to comment.