Skip to content

Commit

Permalink
Add -Schedule parameter to schedule related parameter sets
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhenyu Zhou committed Sep 10, 2020
1 parent 857043f commit 548da54
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Set-AzHDInsightClusterAutoscaleConfiguration [[-ResourceGroupName] <String>] [-C
Set-AzHDInsightClusterAutoscaleConfiguration [[-ResourceGroupName] <String>] [-ClusterName] <String>
[-TimeZone <String>]
[-Condition <System.Collections.Generic.List`1[Microsoft.Azure.Commands.HDInsight.Models.AzureHDInsightAutoscaleCondition]>]
[-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
[-Schedule] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### AutoscaleConfigurationByNameParameterSet
Expand All @@ -46,7 +46,7 @@ Set-AzHDInsightClusterAutoscaleConfiguration [-ResourceId] <String> [-MinWorkerN
```
Set-AzHDInsightClusterAutoscaleConfiguration [-ResourceId] <String> [-TimeZone <String>]
[-Condition <System.Collections.Generic.List`1[Microsoft.Azure.Commands.HDInsight.Models.AzureHDInsightAutoscaleCondition]>]
[-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
[-Schedule] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### AutoscaleConfigurationByResourceIdParameterSet
Expand All @@ -67,7 +67,7 @@ Set-AzHDInsightClusterAutoscaleConfiguration [-InputObject] <AzureHDInsightClust
```
Set-AzHDInsightClusterAutoscaleConfiguration [-InputObject] <AzureHDInsightCluster> [-TimeZone <String>]
[-Condition <System.Collections.Generic.List`1[Microsoft.Azure.Commands.HDInsight.Models.AzureHDInsightAutoscaleCondition]>]
[-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
[-Schedule] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### AutoscaleConfigurationByInputObjectParameterSet
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,3 @@
"Microsoft.Azure.PowerShell.Cmdlets.HDInsight.dll","Microsoft.Azure.Commands.HDInsight.NewAzureHDInsightClusterCommand","New-AzHDInsightCluster","1","8700","Parameter set '__AllParameterSets', 'CertificateFilePath', 'CertificateFileContents' of cmdlet 'New-AzHDInsightCluster' have the same mandatory parameters, and both of them are not default parameter set which may cause confusion.","Merge these parameter sets into one parameter set."
"Microsoft.Azure.PowerShell.Cmdlets.HDInsight.dll","Microsoft.Azure.Commands.HDInsight.NewAzureHDInsightClusterAutoscaleScheduleConditionCommand","New-AzHDInsightClusterAutoscaleScheduleCondition","1","8100","New-AzHDInsightClusterAutoscaleScheduleCondition Does not support ShouldProcess but the cmdlet verb New indicates that it should.","Determine if the cmdlet should implement ShouldProcess and if so determine if it should implement Force / ShouldContinue"
"Microsoft.Azure.PowerShell.Cmdlets.HDInsight.dll","Microsoft.Azure.Commands.HDInsight.NewAzureHDInsightClusterAutoscaleConfiguration","New-AzHDInsightClusterAutoscaleConfiguration","1","8100","New-AzHDInsightClusterAutoscaleConfiguration Does not support ShouldProcess but the cmdlet verb New indicates that it should.","Determine if the cmdlet should implement ShouldProcess and if so determine if it should implement Force / ShouldContinue"
"Microsoft.Azure.PowerShell.Cmdlets.HDInsight.dll","Microsoft.Azure.Commands.HDInsight.SetAzureHDInsightClusterAutoscaleConfigurationCommand","Set-AzHDInsightClusterAutoscaleConfiguration","1","8700","Parameter set 'LoadAutoscaleByResourceIdParameterSet', 'ScheduleAutoscaleByResourceIdParameterSet' of cmdlet 'Set-AzHDInsightClusterAutoscaleConfiguration' have the same mandatory parameters, and both of them are not default parameter set which may cause confusion.","Merge these parameter sets into one parameter set."
"Microsoft.Azure.PowerShell.Cmdlets.HDInsight.dll","Microsoft.Azure.Commands.HDInsight.SetAzureHDInsightClusterAutoscaleConfigurationCommand","Set-AzHDInsightClusterAutoscaleConfiguration","1","8700","Parameter set 'LoadAutoscaleByInputObjectParameterSet', 'ScheduleAutoscaleByInputObjectParameterSet' of cmdlet 'Set-AzHDInsightClusterAutoscaleConfiguration' have the same mandatory parameters, and both of them are not default parameter set which may cause confusion.","Merge these parameter sets into one parameter set."

0 comments on commit 548da54

Please sign in to comment.