From 8f735bee6249550b639c5bcb28bda7737406eb82 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sun, 17 May 2020 11:04:41 -0400 Subject: [PATCH 1/3] Correct body creation method --- ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 b/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 index ae95a22..be8f999 100644 --- a/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 +++ b/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 @@ -27,18 +27,25 @@ function Start-ZertoCloneVpg { ) begin { + + } + + process { $baseUri = "vpgs" $vpgInfo = Get-ZertoVpg -name $vpgName if ( -not $vpgInfo ) { Write-Error "VPG: $vpgName could not be found. Please check the name and try again." } $vpgIdentifier = $vpgInfo.vpgIdentifier + $body = @{ } if ( $PSBoundParameters.ContainsKey('datastoreName') ) { $recoverysiteIdentifier = $vpgInfo.recoverysite.identifier $recoverySiteDatastores = Get-ZertoVirtualizationSite -siteIdentifier $recoverysiteIdentifier -datastores $datastoreIdentifier = $($recoverySiteDatastores | Where-Object { $_.datastoreName -like $datastoreName }).DatastoreIdentifier if ( -not $datastoreIdentifier ) { Write-Error "Datastore: $datastoreName is not a valid datastore. Please check the name and try again." -ErrorAction Stop + } else { + $body['DatastoreIdentifier'] = $datastoreIdentifier } } if ( $PSBoundParameters.ContainsKey('vmName') ) { From 77b7e1c376c36726e4c8195becc499adfc667be8 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sun, 17 May 2020 11:05:15 -0400 Subject: [PATCH 2/3] Fix Body Creation Method --- .../Public/Start-ZertoCloneVpg.ps1 | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 b/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 index be8f999..17f4919 100644 --- a/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 +++ b/ZertoApiWrapper/Public/Start-ZertoCloneVpg.ps1 @@ -62,32 +62,20 @@ function Start-ZertoCloneVpg { } } $body['VmIdentifiers'] = $vmIdentifiers - if ($checkpointIdentifier) { - $body['CheckpointIdentifier'] = $checkpointIdentifier - } } - } - - process { - $uri = "{0}/{1}/CloneStart" -f $baseUri, $vpgIdentifier - $body = [ordered]@{ } if ( $PSBoundParameters.ContainsKey('checkpointIdentifier') ) { $body['checkpointId'] = $checkpointIdentifier } - if ( $datastoreIdentifier ) { - $body['DatastoreIdentifier'] = $datastoreIdentifier - } - if ( $vmIdentifiers ) { - $body['VmIdentifiers'] = $vmIdentifiers - } Write-Verbose $body + $uri = "{0}/{1}/CloneStart" -f $baseUri, $vpgIdentifier if ($PSCmdlet.ShouldProcess("Clone Vpg")) { Invoke-ZertoRestRequest -uri $uri -body $($body | ConvertTo-Json) -method "POST" + Write-Verbose "Call Submitted to $uri" + Write-Verbose "With the following information: $($body | ConvertTo-Json)" } } end { - Write-Verbose "Call Submitted to $uri" - Write-Verbose "With the following information: $($body | ConvertTo-Json)" + } } From cccd45b7fddfc2d26798945094770c73fee40566 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Sun, 17 May 2020 11:07:31 -0400 Subject: [PATCH 3/3] Update ChangeLog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0abe48e..06498e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project is transitioning to [Semantic Versioning](https://semver.org/sp * 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. +* Updated `Start-ZertoCloneVpg` to fix an issue where an error would be thrown if an operation specified a subset of VMs to be cloned. ## [1.4.1]