remove unused variable, and gave better name to farm operations

Renamed SCHEDULEDMAINTENANCE operation to SCHEDULED_MAINTENANCE  and
CANCELMAINTENANCE to CANCEL_MAINTENANCE
This commit is contained in:
vkg1215
2017-01-23 13:06:33 +05:30
committed by praveenmathamsetty
parent ce4dab7df6
commit 142e6361ef

View File

@@ -2376,8 +2376,7 @@ function New-HVFarm {
$LinkedClone = $true $LinkedClone = $true
$DomainAdmin = $jsonObject.AutomatedFarmSpec.CustomizationSettings.domainAdministrator $DomainAdmin = $jsonObject.AutomatedFarmSpec.CustomizationSettings.domainAdministrator
$reusePreExistingAccounts = $jsonObject.AutomatedFarmSpec.CustomizationSettings.ReusePreExistingAccounts $reusePreExistingAccounts = $jsonObject.AutomatedFarmSpec.CustomizationSettings.ReusePreExistingAccounts
$sysprepCustomizationSettings = $jsonObject.AutomatedFarmSpec.CustomizationSettings.SysprepCustomizationSettings $sysPrepName = $jsonObject.AutomatedFarmSpec.CustomizationSettings.SysprepCustomizationSettings.CustomizationSpec
$sysPrepName = $sysprepCustomizationSettings.CustomizationSpec
} }
$namingMethod = $jsonObject.AutomatedFarmSpec.RdsServerNamingSpec.NamingMethod $namingMethod = $jsonObject.AutomatedFarmSpec.RdsServerNamingSpec.NamingMethod
@@ -5811,14 +5810,14 @@ function Start-HVFarm {
.PARAMETER Recompose .PARAMETER Recompose
Switch for recompose operation. Requests a recompose of RDS Servers in the specified 'AUTOMATED' farm. This marks the RDS Servers for recompose, which is performed asynchronously. Switch for recompose operation. Requests a recompose of RDS Servers in the specified 'AUTOMATED' farm. This marks the RDS Servers for recompose, which is performed asynchronously.
.PARAMETER ScheduleMaintenance .PARAMETER Schedule_Maintenance
Switch for ScheduleMaintenance operation. Requests for scheduling maintenance operation on RDS Servers in the specified Instant clone farm. This marks the RDS Servers for scheduled maintenance, which is performed according to the schedule. Switch for Schedule_Maintenance operation. Requests for scheduling maintenance operation on RDS Servers in the specified Instant clone farm. This marks the RDS Servers for scheduled maintenance, which is performed according to the schedule.
.PARAMETER CancelMaintenance .PARAMETER Cancel_Maintenance
Switch for cancelling maintenance operation. Requests for cancelling a scheduled maintenance operation on the specified Instant clone farm. This stops further maintenance operation on the given farm. Switch for cancelling maintenance operation. Requests for cancelling a scheduled maintenance operation on the specified Instant clone farm. This stops further maintenance operation on the given farm.
.PARAMETER StartTime .PARAMETER StartTime
Specifies when to start the recompose/scheduleMaintenance operation. If unset, the recompose operation will begin immediately. Specifies when to start the recompose/Schedule_Maintenance operation. If unset, the recompose operation will begin immediately.
For IMMEDIATE maintenance if unset, maintenance will begin immediately. For RECURRING maintenance if unset, will be calculated based on recurring maintenance configuration. If in the past, maintenance will begin immediately. For IMMEDIATE maintenance if unset, maintenance will begin immediately. For RECURRING maintenance if unset, will be calculated based on recurring maintenance configuration. If in the past, maintenance will begin immediately.
.PARAMETER LogoffSetting .PARAMETER LogoffSetting
@@ -5878,16 +5877,16 @@ function Start-HVFarm {
Start-HVFarm -Farm 'Farm-01' -Recompose -LogoffSetting 'FORCE_LOGOFF' -ParentVM 'ParentVM' -SnapshotVM 'SnapshotVM' -StartTime $myTime Start-HVFarm -Farm 'Farm-01' -Recompose -LogoffSetting 'FORCE_LOGOFF' -ParentVM 'ParentVM' -SnapshotVM 'SnapshotVM' -StartTime $myTime
.EXAMPLE .EXAMPLE
Requests a ScheduleMaintenance task for instant-clone farm. Schedules an IMMEDIATE maintenance. Requests a Schedule_Maintenance task for instant-clone farm. Schedules an IMMEDIATE maintenance.
Start-HVFarm -Farm 'ICFarm-01' -ScheduleMaintenance -MaintenanceMode IMMEDIATE Start-HVFarm -Farm 'ICFarm-01' -Schedule_Maintenance -MaintenanceMode IMMEDIATE
.EXAMPLE .EXAMPLE
Requests a ScheduleMaintenance task for instant-clone farm. Schedules a recurring weekly maintenace every Saturday night at 23:30 and updates the parentVM and snapshot. Requests a Schedule_Maintenance task for instant-clone farm. Schedules a recurring weekly maintenace every Saturday night at 23:30 and updates the parentVM and snapshot.
Start-HVFarm -ScheduleMaintenance -Farm 'ICFarm-01' -MaintenanceMode RECURRING -MaintenancePeriod WEEKLY -MaintenanceStartTime '11:30' -StartInt 6 -EveryInt 1 -ParentVM 'vm-rdsh-ic' -SnapshotVM 'Snap_Updated' Start-HVFarm -Schedule_Maintenance -Farm 'ICFarm-01' -MaintenanceMode RECURRING -MaintenancePeriod WEEKLY -MaintenanceStartTime '11:30' -StartInt 6 -EveryInt 1 -ParentVM 'vm-rdsh-ic' -SnapshotVM 'Snap_Updated'
.EXAMPLE .EXAMPLE
Requests a CancelMaintenance task for instant-clone farm. Cancels recurring maintenance. Requests a Cancel_Maintenance task for instant-clone farm. Cancels recurring maintenance.
Start-HVFarm -CancelMaintenance -Farm 'ICFarm-01' -MaintenanceMode RECURRING Start-HVFarm -Cancel_Maintenance -Farm 'ICFarm-01' -MaintenanceMode RECURRING
.OUTPUTS .OUTPUTS
None None
@@ -5914,58 +5913,58 @@ function Start-HVFarm {
[Parameter(Mandatory = $false,ParameterSetName = 'RECOMPOSE')] [Parameter(Mandatory = $false,ParameterSetName = 'RECOMPOSE')]
[switch]$Recompose, [switch]$Recompose,
[Parameter(Mandatory = $false,ParameterSetName = 'SCHEDULEMAINTENANCE')] [Parameter(Mandatory = $false,ParameterSetName = 'SCHEDULE_MAINTENANCE')]
[switch]$ScheduleMaintenance, [switch]$Schedule_Maintenance,
[Parameter(Mandatory = $false,ParameterSetName = 'CANCELMAINTENANCE')] [Parameter(Mandatory = $false,ParameterSetName = 'CANCEL_MAINTENANCE')]
[switch]$CancelMaintenance, [switch]$Cancel_Maintenance,
[Parameter(Mandatory = $false,ParameterSetName = 'RECOMPOSE')] [Parameter(Mandatory = $false,ParameterSetName = 'RECOMPOSE')]
[Parameter(Mandatory = $false,ParameterSetName = 'SCHEDULEMAINTENANCE')] [Parameter(Mandatory = $false,ParameterSetName = 'SCHEDULE_MAINTENANCE')]
[System.DateTime]$StartTime, [System.DateTime]$StartTime,
[Parameter(Mandatory = $true,ParameterSetName = 'RECOMPOSE')] [Parameter(Mandatory = $true,ParameterSetName = 'RECOMPOSE')]
[Parameter(Mandatory = $false,ParameterSetName = 'SCHEDULEMAINTENANCE')] [Parameter(Mandatory = $false,ParameterSetName = 'SCHEDULE_MAINTENANCE')]
[ValidateSet('FORCE_LOGOFF','WAIT_FOR_LOGOFF')] [ValidateSet('FORCE_LOGOFF','WAIT_FOR_LOGOFF')]
[string]$LogoffSetting = 'FORCE_LOGOFF', [string]$LogoffSetting = 'FORCE_LOGOFF',
[Parameter(Mandatory = $false,ParameterSetName = 'RECOMPOSE')] [Parameter(Mandatory = $false,ParameterSetName = 'RECOMPOSE')]
[Parameter(Mandatory = $false,ParameterSetName = 'SCHEDULEMAINTENANCE')] [Parameter(Mandatory = $false,ParameterSetName = 'SCHEDULE_MAINTENANCE')]
[boolean]$StopOnFirstError = $true, [boolean]$StopOnFirstError = $true,
[Parameter(Mandatory = $false,ParameterSetName = 'RECOMPOSE')] [Parameter(Mandatory = $false,ParameterSetName = 'RECOMPOSE')]
[string []]$Servers, [string []]$Servers,
[Parameter(Mandatory = $true,ParameterSetName = 'RECOMPOSE')] [Parameter(Mandatory = $true,ParameterSetName = 'RECOMPOSE')]
[Parameter(Mandatory = $false,ParameterSetName = 'SCHEDULEMAINTENANCE')] [Parameter(Mandatory = $false,ParameterSetName = 'SCHEDULE_MAINTENANCE')]
[string]$ParentVM, [string]$ParentVM,
[Parameter(Mandatory = $true,ParameterSetName = 'RECOMPOSE')] [Parameter(Mandatory = $true,ParameterSetName = 'RECOMPOSE')]
[Parameter(Mandatory = $false,ParameterSetName = 'SCHEDULEMAINTENANCE')] [Parameter(Mandatory = $false,ParameterSetName = 'SCHEDULE_MAINTENANCE')]
[string]$SnapshotVM, [string]$SnapshotVM,
[Parameter(Mandatory = $false,ParameterSetName = 'RECOMPOSE')] [Parameter(Mandatory = $false,ParameterSetName = 'RECOMPOSE')]
[Parameter(Mandatory = $false,ParameterSetName = 'SCHEDULEMAINTENANCE')] [Parameter(Mandatory = $false,ParameterSetName = 'SCHEDULE_MAINTENANCE')]
[string]$Vcenter, [string]$Vcenter,
[Parameter(Mandatory = $true,ParameterSetName = 'SCHEDULEMAINTENANCE')] [Parameter(Mandatory = $true,ParameterSetName = 'SCHEDULE_MAINTENANCE')]
[Parameter(Mandatory = $true,ParameterSetName = 'CANCELMAINTENANCE')] [Parameter(Mandatory = $true,ParameterSetName = 'CANCEL_MAINTENANCE')]
[ValidateSet('IMMEDIATE','RECURRING')] [ValidateSet('IMMEDIATE','RECURRING')]
[string]$MaintenanceMode, [string]$MaintenanceMode,
[Parameter(Mandatory = $false,ParameterSetName = 'SCHEDULEMAINTENANCE')] [Parameter(Mandatory = $false,ParameterSetName = 'SCHEDULE_MAINTENANCE')]
[ValidatePattern('^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$')] [ValidatePattern('^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$')]
[string]$MaintenanceStartTime, [string]$MaintenanceStartTime,
[Parameter(Mandatory = $false,ParameterSetName = 'SCHEDULEMAINTENANCE')] [Parameter(Mandatory = $false,ParameterSetName = 'SCHEDULE_MAINTENANCE')]
[ValidateSet('DAILY','WEEKLY','MONTHLY')] [ValidateSet('DAILY','WEEKLY','MONTHLY')]
[string]$MaintenancePeriod, [string]$MaintenancePeriod,
[Parameter(Mandatory = $false,ParameterSetName = 'SCHEDULEMAINTENANCE')] [Parameter(Mandatory = $false,ParameterSetName = 'SCHEDULE_MAINTENANCE')]
[ValidateRange(1, 31)] [ValidateRange(1, 31)]
[int]$StartInt, [int]$StartInt,
[Parameter(Mandatory = $false,ParameterSetName = 'SCHEDULEMAINTENANCE')] [Parameter(Mandatory = $false,ParameterSetName = 'SCHEDULE_MAINTENANCE')]
[ValidateRange(1, 100)] [ValidateRange(1, 100)]
[int]$EveryInt = 1, [int]$EveryInt = 1,
@@ -6069,9 +6068,9 @@ function Start-HVFarm {
Write-Host "Performed recompose task on farm: " $farmList.$item Write-Host "Performed recompose task on farm: " $farmList.$item
} }
} }
'SCHEDULEMAINTENANCE' { 'SCHEDULE_MAINTENANCE' {
if ($farmSource.$item -ne 'INSTANT_CLONE_ENGINE') { if ($farmSource.$item -ne 'INSTANT_CLONE_ENGINE') {
Write-Error "SCHEDULEMAINTENANCE operation is not supported for farm with name [$farmList.$item]. It is only supported for instant-clone farms." Write-Error "SCHEDULE_MAINTENANCE operation is not supported for farm with name [$farmList.$item]. It is only supported for instant-clone farms."
break break
} else { } else {
$spec = New-Object VMware.Hv.FarmMaintenanceSpec $spec = New-Object VMware.Hv.FarmMaintenanceSpec
@@ -6109,21 +6108,21 @@ function Start-HVFarm {
try { try {
$spec.ImageMaintenanceSettings = Set-HVFarmSpec -vcId $vcId -spec $spec.ImageMaintenanceSettings $spec.ImageMaintenanceSettings = Set-HVFarmSpec -vcId $vcId -spec $spec.ImageMaintenanceSettings
} catch { } catch {
Write-Error "SCHEDULEMAINTENANCE task failed with error: $_" Write-Error "SCHEDULE_MAINTENANCE task failed with error: $_"
break break
} }
} }
# call scheduleMaintenance service on farm # call scheduleMaintenance service on farm
if ($pscmdlet.ShouldProcess($farmList.$item)) { if ($pscmdlet.ShouldProcess($farmList.$item)) {
$farm_service_helper.Farm_ScheduleMaintenance($services, $item, $spec) $farm_service_helper.Farm_ScheduleMaintenance($services, $item, $spec)
Write-Host "Performed SCHEDULEMAINTENANCE task on farm: " $farmList.$item Write-Host "Performed SCHEDULE_MAINTENANCE task on farm: " $farmList.$item
} }
} }
} }
'CANCELMAINTENANCE' { 'CANCEL_MAINTENANCE' {
if ($pscmdlet.ShouldProcess($farmList.$item)) { if ($pscmdlet.ShouldProcess($farmList.$item)) {
$farm_service_helper.Farm_CancelScheduleMaintenance($services, $item, $MaintenanceMode) $farm_service_helper.Farm_CancelScheduleMaintenance($services, $item, $MaintenanceMode)
Write-Host "Performed CancelMaintenance task on farm: " $farmList.$item Write-Host "Performed CANCEL_MAINTENANCE task on farm: " $farmList.$item
} }
} }
} }