Merge pull request #81 from ZertoPublic/Invoke-ZertoMoveCommit-Fix

Fix Invoke-ZertoMoveCommit
This commit is contained in:
Wes Carroll
2020-05-13 10:38:31 -04:00
committed by GitHub
8 changed files with 61 additions and 19 deletions
+2 -1
View File
@@ -11,7 +11,8 @@ and this project is transitioning to [Semantic Versioning](https://semver.org/sp
#### Fixed #### Fixed
* Updated `Get-ZertoEvent` to translate a vpg name parameter to a vpgIdentifier per the API documentation * Updated `Get-ZertoEvent` to translate a vpg name parameter to a vpgIdentifier per the API documentation
* Updated `Invoke-ZertoMoveCommit` to ensure that when one of the parameter switches is defined, all required parameters are sent to avoid conflicts with parameters passed with the `Invoke-ZertoMove` command.
## [1.4.1] ## [1.4.1]
@@ -1,6 +1,6 @@
<# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #> <# .ExternalHelp ./en-us/ZertoApiWrapper-help.xml #>
function Invoke-ZertoMoveCommit { function Invoke-ZertoMoveCommit {
[cmdletbinding(SupportsShouldProcess = $true)] [cmdletbinding(SupportsShouldProcess = $true, DefaultParameterSetName = "Main")]
param( param(
[Parameter( [Parameter(
HelpMessage = "Name(s) of the VPG(s) to commit.", HelpMessage = "Name(s) of the VPG(s) to commit.",
@@ -9,11 +9,16 @@ function Invoke-ZertoMoveCommit {
[ValidateNotNullOrEmpty()] [ValidateNotNullOrEmpty()]
[string[]]$vpgName, [string[]]$vpgName,
[Parameter( [Parameter(
HelpMessage = "Set this to True to reverse protect the VPG(s) to the source site. If not set, will use selection made during move initiation. True or False" HelpMessage = "Use this switch to reverse protect the VPG(s) to the source site. If neither 'ReverseProtction' nor 'KeepSourceVms' switch is specified, the commit process will use selection made during move initiation.",
ParameterSetName = 'ReverseProtect',
Mandatory
)] )]
[switch]$reverseProtection, [switch]$reverseProtection,
[Parameter( [Parameter(
HelpMessage = "Use this switch to keep the source VMs. If not set, they will be destroyed." HelpMessage = "Use this switch to keep the source VMs at the source site. If neither 'ReverseProtction' nor 'KeepSourceVms' switch is specified, the commit process will use selection made during move initiation.",
ParameterSetName = 'KeepSource',
Mandatory
)] )]
[switch]$keepSourceVms [switch]$keepSourceVms
) )
@@ -21,10 +26,16 @@ function Invoke-ZertoMoveCommit {
begin { begin {
$baseUri = "vpgs" $baseUri = "vpgs"
$body = @{ } $body = @{ }
if ($reverseProtection) { Switch ($PSCmdlet.ParameterSetName){
$body["ReverseProtection"] = $true 'KeepSource' {
} elseif ($keepSourceVms) { $body["KeepSourceVms"] = $true
$body["KeepSourceVms"] = $true $body["ReverseProtection"] = $false
}
'ReverseProtect' {
$body["ReverseProtection"] = $true
$body["KeepSourceVms"] = $false
}
} }
} }
+3
View File
@@ -112,6 +112,7 @@ The type of event to return. This filter behaves in the same way as the eventCat
Type: String Type: String
Parameter Sets: filter Parameter Sets: filter
Aliases: Aliases:
Accepted values: All, Events, Alerts
Required: False Required: False
Position: Named Position: Named
@@ -159,6 +160,7 @@ The type of entity for which you wish to return results. Possible Values are: 'V
Type: String Type: String
Parameter Sets: filter Parameter Sets: filter
Aliases: Aliases:
Accepted values: VPG, VRA, Unknown, Site
Required: False Required: False
Position: Named Position: Named
@@ -174,6 +176,7 @@ This filter behaves in the same way as the category filter. If both category and
Type: String Type: String
Parameter Sets: filter Parameter Sets: filter
Aliases: Aliases:
Accepted values: All, Events, Alerts
Required: False Required: False
Position: Named Position: Named
+1
View File
@@ -88,6 +88,7 @@ The priority specified for the VPG. Possible values are: 'Low', 'Medium', or 'Hi
Type: String Type: String
Parameter Sets: filter Parameter Sets: filter
Aliases: Aliases:
Accepted values: Low, Medium, High
Required: False Required: False
Position: Named Position: Named
+1
View File
@@ -102,6 +102,7 @@ Possible values are: 'Failover', 'Failover Test', or 'Move'
Type: String Type: String
Parameter Sets: filter Parameter Sets: filter
Aliases: Aliases:
Accepted values: Failover, Failover Test, Move
Required: False Required: False
Position: Named Position: Named
+1
View File
@@ -129,6 +129,7 @@ The status of the task. Possible values are: 'InProgress', 'Paused', 'Failed', '
Type: String Type: String
Parameter Sets: filter Parameter Sets: filter
Aliases: Aliases:
Accepted values: InProgress, Paused, Failed, Completed, Cancelling
Required: False Required: False
Position: Named Position: Named
+1
View File
@@ -271,6 +271,7 @@ The VPG priority. Possible values are: 'Low', 'Medium', 'High'
Type: String Type: String
Parameter Sets: filter Parameter Sets: filter
Aliases: Aliases:
Accepted values: Low, Medium, High
Required: False Required: False
Position: Named Position: Named
+34 -11
View File
@@ -12,9 +12,19 @@ Commit a VPG currently undergoing a move operation.
## SYNTAX ## SYNTAX
### Main (Default)
``` ```
Invoke-ZertoMoveCommit [-vpgName] <String[]> [-reverseProtection] [-keepSourceVms] [-WhatIf] [-Confirm] Invoke-ZertoMoveCommit -vpgName <String[]> [-WhatIf] [-Confirm] [<CommonParameters>]
[<CommonParameters>] ```
### ReverseProtect
```
Invoke-ZertoMoveCommit -vpgName <String[]> [-reverseProtection] [-WhatIf] [-Confirm] [<CommonParameters>]
```
### KeepSource
```
Invoke-ZertoMoveCommit -vpgName <String[]> [-keepSourceVms] [-WhatIf] [-Confirm] [<CommonParameters>]
``` ```
## DESCRIPTION ## DESCRIPTION
@@ -27,20 +37,33 @@ Commit a VPG currently undergoing a move operation.
PS C:\> Invoke-ZertoMoveCommit -vpgName "MyVpg" PS C:\> Invoke-ZertoMoveCommit -vpgName "MyVpg"
``` ```
Commit VPG "MyVpg" after a move has been started. Commit VPG "MyVpg" after a move operation has been completed. This commit process with use the `-KeepSourceVms` or `-ReverseProtection` selection made during the move initation.
### Example 2
```powershell
PS C:\> Invoke-ZertoMoveCommit -vpgName "MyVpg" -keepSourceVms
```
Commit VPG "MyVpg" after a move operation has been completed specifying to keep the vms at the source location and NOT reverse protection. This commit process will overrule any reverse protection or keep source vms selection made during the move initiation.
### Example 3
```powershell
PS C:\> Invoke-ZertoMoveCommit -vpgName "MyVpg" -reverseProtection
```
Commit VPG "MyVpg" after a move operation has been completed specifying to reverse protection of the VMs back to the source location. The VMs at the source location will be removed from inventory at the source location and the disks will be used as pre-seed volumes. This commit process will overrule any reverse protection or keep source vms selection made during the move initiation.
## PARAMETERS ## PARAMETERS
### -keepSourceVms ### -keepSourceVms
Use this switch to keep the source VMs. "Use this switch to keep the source VMs at the source site. If neither 'ReverseProtction' nor 'KeepSourceVms' switch is specified, the commit process will use selection made during move initiation."
If not set, they will be destroyed.
```yaml ```yaml
Type: SwitchParameter Type: SwitchParameter
Parameter Sets: (All) Parameter Sets: KeepSource
Aliases: Aliases:
Required: False Required: True
Position: Named Position: Named
Default value: None Default value: None
Accept pipeline input: False Accept pipeline input: False
@@ -48,14 +71,14 @@ Accept wildcard characters: False
``` ```
### -reverseProtection ### -reverseProtection
Set this to True to reverse protect the VPG(s) to the source site. If not set, will use selection made during move initiation. True or False "Use this switch to reverse protect the VPG(s) to the source site. If neither 'ReverseProtction' nor 'KeepSourceVms' switch is specified, the commit process will use selection made during move initiation."
```yaml ```yaml
Type: SwitchParameter Type: SwitchParameter
Parameter Sets: (All) Parameter Sets: ReverseProtect
Aliases: Aliases:
Required: False Required: True
Position: Named Position: Named
Default value: None Default value: None
Accept pipeline input: False Accept pipeline input: False
@@ -71,7 +94,7 @@ Parameter Sets: (All)
Aliases: Aliases:
Required: True Required: True
Position: 0 Position: Named
Default value: None Default value: None
Accept pipeline input: False Accept pipeline input: False
Accept wildcard characters: False Accept wildcard characters: False