From b076942d26bd25d2f1bc6bcbba2beb35c2971fb3 Mon Sep 17 00:00:00 2001 From: Wes Carroll Date: Mon, 11 Mar 2019 19:17:33 -0400 Subject: [PATCH] Add Journal Default Settings in MB functionality --- ZertoApiWrapper/Public/New-ZertoVpg.ps1 | 28 ++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/ZertoApiWrapper/Public/New-ZertoVpg.ps1 b/ZertoApiWrapper/Public/New-ZertoVpg.ps1 index 783a9a7..b8666ae 100644 --- a/ZertoApiWrapper/Public/New-ZertoVpg.ps1 +++ b/ZertoApiWrapper/Public/New-ZertoVpg.ps1 @@ -126,7 +126,22 @@ function New-ZertoVpg { HelpMessage = "Name of the network to use during a Failover Test operation", Mandatory = $true )] - [string]$testNetwork + [string]$testNetwork, + [Parameter( + HelpMessage = "Name of the datastore to utilize to store Journal data. If not specified, the default datastore will be used.", + Mandatory = $false + )] + [string]$journalDatastore, + [Parameter( + HelpMessage = "Default journal hard limit in megabytes. Default set to 150MB.", + Mandatory = $false + )] + [int]$journalHardLimitInMb = 150, + [Parameter( + HelpMessage = "Default journal warning threshold in megabytes. If unset, will be set to 75% of the journal hard limit.", + Mandatory = $false + )] + [int]$journalWarningThresholdInMb = 0 ) begin { @@ -142,6 +157,9 @@ function New-ZertoVpg { if ($PSBoundParameters.ContainsKey("serviceProfile")) { $identifiersTable['serviceProfileIdentifier'] = $(Get-ZertoServiceProfile -siteIdentifier $identifiersTable['recoverySiteIdentifier'] | Where-Object {$_.ServiceProfileName -like $serviceProfile}).serviceProfileIdentifier } + if ($PSBoundParameters.ContainsKey('journalDatastore')) { + $identifiersTable['journalDatastore'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -datastores | Where-Object {$_.DatastoreName -like $journalDatastore}).DatastoreIdentifier + } switch ($PSCmdlet.ParameterSetName) { "recoveryClusterDatastoreCluster" { $identifiersTable['clusterIdentifier'] = $(Get-ZertoVirtualizationSite -siteIdentifier $identifiersTable['recoverySiteIdentifier'] -hostclusters | Where-Object {$_.VirtualizationClusterName -like $recoveryCluster}).ClusterIdentifier @@ -194,6 +212,9 @@ function New-ZertoVpg { $returnObject | Add-Member -MemberType NoteProperty -Name "VmIdentifier" -Value $vmIdentifier $returnObject } + if (($journalWarningThresholdInMb -eq 0) -or ($journalWarningThresholdInMb -gt $journalHardLimitInMb)) { + $journalWarningThresholdInMb = $journalHardLimitInMb * .75 + } } process { @@ -253,6 +274,11 @@ function New-ZertoVpg { } else { $baseSettings.Vms = $vmIdentifiers } + if ($identifiersTable.ContainsKey('journalDatastore')) { + $baseSettings.Journal.DatastoreIdentifier = $identifiersTable['journalDatastore'] + } + $baseSettings.Journal.Limitation.HardLimitInMB = $journalHardLimitInMb + $baseSettings.Journal.Limitation.WarningThresholdInMB = $journalWarningThresholdInMb $settingsURI = "{0}/{1}" -f $baseUri, $vpgSettingsIdentifier Invoke-ZertoRestRequest -uri $settingsURI -body $($baseSettings | ConvertTo-Json -Depth 10) -method "PUT" | Out-Null }