From 803300cde0cdf8afad679f152f8815dc7f2b5e36 Mon Sep 17 00:00:00 2001 From: Zhenyu Zhou Date: Thu, 10 Sep 2020 17:24:55 +0800 Subject: [PATCH] Add -Schedule parameter to schedule related parameter sets --- .../ScenarioTests/HDInsightAutoscaleTests.ps1 | 2 +- .../ScenarioTests/HDInsightClusterTests.ps1 | 2 +- ...ghtClusterAutoscaleConfigurationCommand.cs | 14 +++++++++++ ...zHDInsightClusterAutoscaleConfiguration.md | 2 +- ...nsightClusterAutoscaleScheduleCondition.md | 2 +- ...zHDInsightClusterAutoscaleConfiguration.md | 25 +++++++++++++++---- 6 files changed, 38 insertions(+), 9 deletions(-) diff --git a/src/HDInsight/HDInsight.Test/ScenarioTests/HDInsightAutoscaleTests.ps1 b/src/HDInsight/HDInsight.Test/ScenarioTests/HDInsightAutoscaleTests.ps1 index 575fafcd3601..7405c1c3578f 100644 --- a/src/HDInsight/HDInsight.Test/ScenarioTests/HDInsightAutoscaleTests.ps1 +++ b/src/HDInsight/HDInsight.Test/ScenarioTests/HDInsightAutoscaleTests.ps1 @@ -56,7 +56,7 @@ function Test-AutoscaleRelatedCommands{ $condition2=New-AzHDInsightClusterAutoscaleScheduleCondition -Time 08:00 -WorkerNodeCount 4 -Day Friday $scheduleAutoscaleCluster=Set-AzHDInsightClusterAutoscaleConfiguration -ResourceGroupName $cluster.ResourceGroup ` - -ClusterName $cluster.Name -TimeZone "Pacific Standard Time" -Condition $condition1,$condition2 + -ClusterName $cluster.Name -Schedule -TimeZone "Pacific Standard Time" -Condition $condition1,$condition2 Assert-AreEqual $scheduleAutoscaleCluster.ComputeProfile.Roles[1].AutoscaleConfiguration.Recurrence.TimeZone "Pacific Standard Time" Assert-AreEqual $scheduleAutoscaleCluster.ComputeProfile.Roles[1].AutoscaleConfiguration.Recurrence.Condition[0].WorkerNodeCount 5 diff --git a/src/HDInsight/HDInsight.Test/ScenarioTests/HDInsightClusterTests.ps1 b/src/HDInsight/HDInsight.Test/ScenarioTests/HDInsightClusterTests.ps1 index 9310fc43b189..6c6691522402 100644 --- a/src/HDInsight/HDInsight.Test/ScenarioTests/HDInsightClusterTests.ps1 +++ b/src/HDInsight/HDInsight.Test/ScenarioTests/HDInsightClusterTests.ps1 @@ -257,7 +257,7 @@ function Test-CreateClusterWithScheduleBasedAutoscale{ $autoscaleConfiguration=New-AzHDInsightClusterAutoscaleConfiguration -TimeZone ([System.TimeZoneInfo]::Local).Id ` -Condition $condition1,$condition2 - # create cluster with load-based autoscale + # create cluster with schedule-based autoscale $cluster=New-AzHDInsightCluster -Location $params.location -ResourceGroupName $params.resourceGroupName ` -ClusterName $params.clusterName -ClusterSizeInNodes $params.clusterSizeInNodes -ClusterType $params.clusterType ` -DefaultStorageAccountName $params.storageAccountName -DefaultStorageAccountKey $params.storageAccountKey ` diff --git a/src/HDInsight/HDInsight/ManagementCommands/SetAzureHDInsightClusterAutoscaleConfigurationCommand.cs b/src/HDInsight/HDInsight/ManagementCommands/SetAzureHDInsightClusterAutoscaleConfigurationCommand.cs index a23922f93e59..c074efaf1e80 100644 --- a/src/HDInsight/HDInsight/ManagementCommands/SetAzureHDInsightClusterAutoscaleConfigurationCommand.cs +++ b/src/HDInsight/HDInsight/ManagementCommands/SetAzureHDInsightClusterAutoscaleConfigurationCommand.cs @@ -189,6 +189,20 @@ public class SetAzureHDInsightClusterAutoscaleConfigurationCommand : HDInsightCm [ValidateNotNullOrEmpty] public AzureHDInsightAutoscale AutoscaleConfiguration { get; set; } + [Parameter( + Mandatory = true, + HelpMessage = "Set schedule-based parameters", + ParameterSetName = ScheduleAutoscaleByNameParameterSet)] + [Parameter( + Mandatory = true, + HelpMessage = "Set schedule-based parameters", + ParameterSetName = ScheduleAutoscaleByResourceIdParameterSet)] + [Parameter( + Mandatory = true, + HelpMessage = "Set schedule-based parameters", + ParameterSetName = ScheduleAutoscaleByInputObjectParameterSet)] + public SwitchParameter Schedule { get; set; } + [Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")] public SwitchParameter AsJob { get; set; } diff --git a/src/HDInsight/HDInsight/help/New-AzHDInsightClusterAutoscaleConfiguration.md b/src/HDInsight/HDInsight/help/New-AzHDInsightClusterAutoscaleConfiguration.md index 51fb0954cbb5..1edc97fee0ea 100644 --- a/src/HDInsight/HDInsight/help/New-AzHDInsightClusterAutoscaleConfiguration.md +++ b/src/HDInsight/HDInsight/help/New-AzHDInsightClusterAutoscaleConfiguration.md @@ -142,4 +142,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable [Set-AzHDInsightClusterAutoscaleConfiguration](./Set-AzHDInsightClusterAutoscaleConfiguration.md) [Get-AzHDInsightClusterAutoscaleConfiguration](./Get-AzHDInsightClusterAutoscaleConfiguration.md) -[Remove-AzHDInsightClusterAutoscaleConfiguration](./New-AzHDInsightClusterAutoscaleConfiguration.md) +[Remove-AzHDInsightClusterAutoscaleConfiguration](./Remove-AzHDInsightClusterAutoscaleConfiguration.md) diff --git a/src/HDInsight/HDInsight/help/New-AzHDInsightClusterAutoscaleScheduleCondition.md b/src/HDInsight/HDInsight/help/New-AzHDInsightClusterAutoscaleScheduleCondition.md index 4fbdac89d646..a3efb31624c4 100644 --- a/src/HDInsight/HDInsight/help/New-AzHDInsightClusterAutoscaleScheduleCondition.md +++ b/src/HDInsight/HDInsight/help/New-AzHDInsightClusterAutoscaleScheduleCondition.md @@ -38,7 +38,7 @@ PS C:\> $condition=New-AzHDInsightClusterAutoscaleScheduleCondition -Time 09:00 # Set the cluster autoscale configuration PS C:\> $clusterResourceGroup="group" PS C:\> $clusterName="MyCluster" -PS C:\> Set-AzHDInsightClusterAutoscaleConfiguration -ResourceGroupName $clusterResourceGroup -ClusterName $clusterName -TimeZone "Pacific Standard Time" -Condition $condition +PS C:\> Set-AzHDInsightClusterAutoscaleConfiguration -ResourceGroupName $clusterResourceGroup -ClusterName $clusterName -Schedule -TimeZone "Pacific Standard Time" -Condition $condition ``` This command creates a condition where cluster autoscale to 5 worker nodes at 09:00 every Monday, Wednesday. diff --git a/src/HDInsight/HDInsight/help/Set-AzHDInsightClusterAutoscaleConfiguration.md b/src/HDInsight/HDInsight/help/Set-AzHDInsightClusterAutoscaleConfiguration.md index 319ee3453a71..137e9741c13a 100644 --- a/src/HDInsight/HDInsight/help/Set-AzHDInsightClusterAutoscaleConfiguration.md +++ b/src/HDInsight/HDInsight/help/Set-AzHDInsightClusterAutoscaleConfiguration.md @@ -25,7 +25,7 @@ Set-AzHDInsightClusterAutoscaleConfiguration [[-ResourceGroupName] ] [-C Set-AzHDInsightClusterAutoscaleConfiguration [[-ResourceGroupName] ] [-ClusterName] [-TimeZone ] [-Condition ] - [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] + [-Schedule] [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` ### AutoscaleConfigurationByNameParameterSet @@ -46,7 +46,7 @@ Set-AzHDInsightClusterAutoscaleConfiguration [-ResourceId] [-MinWorkerN ``` Set-AzHDInsightClusterAutoscaleConfiguration [-ResourceId] [-TimeZone ] [-Condition ] - [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] + [-Schedule] [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` ### AutoscaleConfigurationByResourceIdParameterSet @@ -67,7 +67,7 @@ Set-AzHDInsightClusterAutoscaleConfiguration [-InputObject] [-TimeZone ] [-Condition ] - [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] + [-Schedule] [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` ### AutoscaleConfigurationByInputObjectParameterSet @@ -101,7 +101,7 @@ PS C:\> $condition2=New-AzHDInsightClusterAutoscaleScheduleCondition -Time 09:00 # Set autoscale configuration PS C:\> $clusterResourceGroup="group" PS C:\> $clusterName="MyCluster" -PS C:\> Set-AzHDInsightClusterAutoscaleConfiguration -ResourceGroupName $clusterResourceGroup -ClusterName $clusterName -TimeZone "Pacific Standard Time" -Condition $condition1,$condition2 +PS C:\> Set-AzHDInsightClusterAutoscaleConfiguration -ResourceGroupName $clusterResourceGroup -ClusterName $clusterName -Schedule -TimeZone "Pacific Standard Time" -Condition $condition1,$condition2 ``` This command sets the Schedule-based autoscale configuration of the HDInsight cluster. @@ -274,6 +274,21 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` +### -Schedule +Set schedule-based parameters + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: ScheduleAutoscaleByNameParameterSet, ScheduleAutoscaleByResourceIdParameterSet, ScheduleAutoscaleByInputObjectParameterSet +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -TimeZone Gets or sets the time zone of schedule-based autoscale. @@ -339,4 +354,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable [New-AzHDInsightClusterAutoscaleConfiguration](./New-AzHDInsightClusterAutoscaleConfiguration.md) [Get-AzHDInsightClusterAutoscaleConfiguration](./Get-AzHDInsightClusterAutoscaleConfiguration.md) -[Remove-AzHDInsightClusterAutoscaleConfiguration](./Set-AzHDInsightClusterAutoscaleConfiguration.md) +[Remove-AzHDInsightClusterAutoscaleConfiguration](./Remove-AzHDInsightClusterAutoscaleConfiguration.md)