Skip to content

Commit 2967a34

Browse files
authored
Merge pull request Azure#4678 from metafractal/preview
Update New-AzureRmHDInsightCluster cmdlet to add new parameter that specifies number of data disks per worker node.
2 parents 5bacbcd + 4095d44 commit 2967a34

File tree

6 files changed

+107
-11
lines changed

6 files changed

+107
-11
lines changed

src/ResourceManager/HDInsight/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21+
* Added support for Data Disks property in cluster creation
22+
- Added parameter 'WorkerNodeDataDisksGroups' to the New-AzureHDInsightCluster cmdlet
2123

2224
## Version 3.4.0
2325

src/ResourceManager/HDInsight/Commands.HDInsight.Test/UnitTests/NewClusterTests.cs

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using Moq;
2121
using Newtonsoft.Json;
2222
using System.Collections.Generic;
23+
using System.Linq;
2324
using System.Management.Automation;
2425
using Xunit;
2526

@@ -151,7 +152,6 @@ public void CanCreateNewHDInsightCluster_Linux()
151152
clusterout.Name == ClusterName &&
152153
clusterout.OperatingSystemType == OSType.Linux)),
153154
Times.Once);
154-
155155
}
156156

157157
[Fact]
@@ -205,8 +205,12 @@ public void CanCreateNewHDInsightCluster_Secure_Linux()
205205
Times.Once);
206206
}
207207

208-
private void CreateNewHDInsightCluster(bool addSecurityProfileInresponse = false, bool setEdgeNodeVmSize = false)
208+
private void CreateNewHDInsightCluster(
209+
bool addSecurityProfileInresponse = false,
210+
bool setEdgeNodeVmSize = false,
211+
int workerNodeDataDisks = 0)
209212
{
213+
// Assign cmdlet parameters
210214
cmdlet.ClusterName = ClusterName;
211215
cmdlet.ResourceGroupName = ResourceGroupName;
212216
cmdlet.ClusterSizeInNodes = ClusterSize;
@@ -217,9 +221,13 @@ private void CreateNewHDInsightCluster(bool addSecurityProfileInresponse = false
217221
cmdlet.ClusterType = ClusterType;
218222
cmdlet.SshCredential = _sshCred;
219223
cmdlet.OSType = OSType.Linux;
224+
cmdlet.DisksPerWorkerNode = workerNodeDataDisks;
220225
if (setEdgeNodeVmSize)
226+
{
221227
cmdlet.EdgeNodeSize = "edgeNodeVmSizeSetTest";
228+
}
222229

230+
// Construct cluster Object
223231
var cluster = new Cluster
224232
{
225233
Id = "id",
@@ -237,10 +245,29 @@ private void CreateNewHDInsightCluster(bool addSecurityProfileInresponse = false
237245
{
238246
CoresUsed = 24
239247
},
240-
OperatingSystemType = OSType.Linux
248+
OperatingSystemType = OSType.Linux,
249+
ComputeProfile = new ComputeProfile()
250+
{
251+
Roles = new List<Role>()
252+
}
241253
}
242254
};
243255

256+
if (workerNodeDataDisks > 0)
257+
{
258+
cluster.Properties.ComputeProfile.Roles.Add(new Role()
259+
{
260+
Name = "workernode",
261+
DataDisksGroups = new List<DataDisksGroupProperties>()
262+
{
263+
new DataDisksGroupProperties()
264+
{
265+
DisksPerNode = workerNodeDataDisks
266+
}
267+
}
268+
});
269+
}
270+
244271
if (addSecurityProfileInresponse)
245272
{
246273
cluster.Properties.SecurityProfile = new SecurityProfile()
@@ -285,6 +312,7 @@ private void CreateNewHDInsightCluster(bool addSecurityProfileInresponse = false
285312

286313
var getresponse = new ClusterGetResponse {Cluster = cluster};
287314

315+
// Setup Mocks and verify successfull GET response
288316
hdinsightManagementMock.Setup(
289317
c => c.CreateNewCluster(ResourceGroupName, ClusterName, It.Is<ClusterCreateParameters>(
290318
parameters =>
@@ -299,10 +327,12 @@ private void CreateNewHDInsightCluster(bool addSecurityProfileInresponse = false
299327
parameters.OSType == OSType.Linux &&
300328
parameters.SshUserName == _sshCred.UserName &&
301329
parameters.SshPassword == _sshCred.Password.ConvertToString() &&
302-
((!setEdgeNodeVmSize && parameters.EdgeNodeSize == null) || (setEdgeNodeVmSize && parameters.EdgeNodeSize == "edgeNodeVmSizeSetTest")))))
330+
((!setEdgeNodeVmSize && parameters.EdgeNodeSize == null) || (setEdgeNodeVmSize && parameters.EdgeNodeSize == "edgeNodeVmSizeSetTest")) &&
331+
(workerNodeDataDisks == 0) || (workerNodeDataDisks > 0 && parameters.WorkerNodeDataDisksGroups.First().DisksPerNode == workerNodeDataDisks))))
303332
.Returns(getresponse)
304333
.Verifiable();
305334

335+
// Execute Cmdlet and verify output
306336
cmdlet.ExecuteCmdlet();
307337

308338
commandRuntimeMock.VerifyAll();
@@ -314,7 +344,8 @@ private void CreateNewHDInsightCluster(bool addSecurityProfileInresponse = false
314344
clusterout.CoresUsed == 24 &&
315345
clusterout.Location == Location &&
316346
clusterout.Name == ClusterName &&
317-
clusterout.OperatingSystemType == OSType.Linux)),
347+
clusterout.OperatingSystemType == OSType.Linux &&
348+
(workerNodeDataDisks == 0) || (clusterout.WorkerNodeDataDisksGroups.First().DisksPerNode == workerNodeDataDisks))),
318349
Times.Once);
319350
}
320351

@@ -438,6 +469,16 @@ public void CanCreateNewHDInsightCluster_LinuxComponentVersion()
438469
Times.Once);
439470
}
440471

472+
[Fact]
473+
[Trait(Category.AcceptanceType, Category.CheckIn)]
474+
public void CanCreateNewHDInsightCluster_Kafka_DataDisks_Linux()
475+
{
476+
ClusterType = "Kafka";
477+
HdiVersion = "3.6";
478+
479+
CreateNewHDInsightCluster(workerNodeDataDisks: 8);
480+
}
481+
441482
[Fact]
442483
[Trait(Category.AcceptanceType, Category.CheckIn)]
443484
public void TestStorageAccountTypeDefaultsToAzureStorage()

src/ResourceManager/HDInsight/Commands.HDInsight/ManagementCommands/NewAzureHDInsightClusterCommand.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ public AzureHDInsightConfig Config
136136
CertificateFileContents = CertificateFileContents,
137137
CertificateFilePath = CertificateFilePath,
138138
CertificatePassword = CertificatePassword,
139-
SecurityProfile = SecurityProfile
139+
SecurityProfile = SecurityProfile,
140+
DisksPerWorkerNode = DisksPerWorkerNode
140141
};
141142
foreach (
142143
var storageAccount in
@@ -157,6 +158,7 @@ var storageAccount in
157158
{
158159
result.ComponentVersion.Add(component.Key, component.Value);
159160
}
161+
160162
return result;
161163
}
162164
set
@@ -187,6 +189,7 @@ var storageAccount in
187189
ObjectId = value.ObjectId;
188190
CertificatePassword = value.CertificatePassword;
189191
SecurityProfile = value.SecurityProfile;
192+
DisksPerWorkerNode = value.DisksPerWorkerNode;
190193

191194
foreach (
192195
var storageAccount in
@@ -348,6 +351,9 @@ public DateTime RdpAccessExpiry
348351
[Parameter(HelpMessage = "Gets or sets Security Profile which is used for creating secure cluster.")]
349352
public AzureHDInsightSecurityProfile SecurityProfile { get; set; }
350353

354+
[Parameter(HelpMessage = "Gets or sets the number of disks for worker node role in the cluster.")]
355+
public int DisksPerWorkerNode { get; set; }
356+
351357
#endregion
352358

353359

@@ -456,7 +462,18 @@ var storageAccount in
456462
ClusterUsersGroupDNs = SecurityProfile.ClusterUsersGroupDNs
457463
};
458464
}
459-
465+
466+
if (DisksPerWorkerNode > 0)
467+
{
468+
parameters.WorkerNodeDataDisksGroups = new List<DataDisksGroupProperties>()
469+
{
470+
new DataDisksGroupProperties()
471+
{
472+
DisksPerNode = DisksPerWorkerNode
473+
}
474+
};
475+
}
476+
460477
var cluster = HDInsightManagementClient.CreateNewCluster(ResourceGroupName, ClusterName, parameters);
461478

462479
if (cluster != null)

src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHDInsightCluster.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ public AzureHDInsightCluster(Cluster cluster)
4545
{
4646
ComponentVersion.Add(componentVersion.ToString());
4747
}
48+
WorkerNodeDataDisksGroups = new List<DataDisksGroupProperties>();
49+
if (cluster.Properties.ComputeProfile != null && cluster.Properties.ComputeProfile.Roles.Any())
50+
{
51+
var rolesWithDataDisksGroups = cluster.Properties.ComputeProfile.Roles.Where(x => x.DataDisksGroups != null);
52+
foreach (var role in rolesWithDataDisksGroups)
53+
{
54+
WorkerNodeDataDisksGroups.AddRange(role.DataDisksGroups);
55+
}
56+
}
4857
var clusterSecurityProfile = cluster.Properties.SecurityProfile;
4958
SecurityProfile = clusterSecurityProfile != null ? new AzureHDInsightSecurityProfile()
5059
{
@@ -178,6 +187,11 @@ public AzureHDInsightCluster(Cluster cluster, IDictionary<string, string> cluste
178187
/// Version of a component service in the cluster
179188
/// </summary>
180189
public List<string> ComponentVersion { get; set; }
190+
191+
/// <summary>
192+
/// Data Disks Group Properties for the Worker Role.
193+
/// </summary>
194+
public List<DataDisksGroupProperties> WorkerNodeDataDisksGroups { get; set; }
181195

182196
/// Gets or sets the security profile.
183197
/// </summary>

src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHDInsightConfig.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ public class AzureHDInsightConfig
130130
/// </value>
131131
public AzureHDInsightSecurityProfile SecurityProfile { get; set; }
132132

133+
/// <summary>
134+
/// Gets or sets the number of disks for worker node role for the cluster.
135+
/// </summary>
136+
public int DisksPerWorkerNode { get; set; }
137+
133138
public AzureHDInsightConfig()
134139
{
135140
ClusterType = Constants.Hadoop;

src/ResourceManager/HDInsight/Commands.HDInsight/help/New-AzureRmHDInsightCluster.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
external help file: Microsoft.Azure.Commands.HDInsight.dll-Help.xml
3+
Module Name: AzureRM.HDInsight
34
ms.assetid: 691AC991-3249-487C-A0DF-C579ED7D00E7
45
online version:
56
schema: 2.0.0
@@ -29,7 +30,7 @@ New-AzureRmHDInsightCluster [-Location] <String> [-ResourceGroupName] <String> [
2930
[-VirtualNetworkId <String>] [-SubnetName <String>] [-OSType <OSType>] [-ClusterTier <Tier>]
3031
[-SshCredential <PSCredential>] [-SshPublicKey <String>] [-RdpCredential <PSCredential>]
3132
[-RdpAccessExpiry <DateTime>] [-ObjectId <Guid>] [-CertificatePassword <String>] [-AadTenantId <Guid>]
32-
[-SecurityProfile <AzureHDInsightSecurityProfile>] [<CommonParameters>]
33+
[-SecurityProfile <AzureHDInsightSecurityProfile>] [-DisksPerWorkerNode <Int32>] [<CommonParameters>]
3334
```
3435

3536
### CertificateFilePath
@@ -50,7 +51,7 @@ New-AzureRmHDInsightCluster [-Location] <String> [-ResourceGroupName] <String> [
5051
[-SshCredential <PSCredential>] [-SshPublicKey <String>] [-RdpCredential <PSCredential>]
5152
[-RdpAccessExpiry <DateTime>] [-ObjectId <Guid>] [-CertificateFilePath <String>]
5253
[-CertificatePassword <String>] [-AadTenantId <Guid>] [-SecurityProfile <AzureHDInsightSecurityProfile>]
53-
[<CommonParameters>]
54+
[-DisksPerWorkerNode <Int32>] [<CommonParameters>]
5455
```
5556

5657
### CertificateFileContents
@@ -71,7 +72,7 @@ New-AzureRmHDInsightCluster [-Location] <String> [-ResourceGroupName] <String> [
7172
[-SshCredential <PSCredential>] [-SshPublicKey <String>] [-RdpCredential <PSCredential>]
7273
[-RdpAccessExpiry <DateTime>] [-ObjectId <Guid>] [-CertificateFileContents <Byte[]>]
7374
[-CertificatePassword <String>] [-AadTenantId <Guid>] [-SecurityProfile <AzureHDInsightSecurityProfile>]
74-
[<CommonParameters>]
75+
[-DisksPerWorkerNode <Int32>] [<CommonParameters>]
7576
```
7677

7778
## DESCRIPTION
@@ -86,6 +87,8 @@ The New-AzureHDInsightCluster creates an Azure HDInsight cluster by using the sp
8687

8788

8889

90+
91+
8992
```
9093
PS C:\&gt; # Primary storage account info
9194
$storageAccountResourceGroupName = "Group"
@@ -388,6 +391,21 @@ Accept pipeline input: False
388391
Accept wildcard characters: False
389392
```
390393
394+
### -DisksPerWorkerNode
395+
Specifies the number of disks for worker node role in the cluster.
396+
397+
```yaml
398+
Type: Int32
399+
Parameter Sets: (All)
400+
Aliases:
401+
402+
Required: False
403+
Position: Named
404+
Default value: None
405+
Accept pipeline input: False
406+
Accept wildcard characters: False
407+
```
408+
391409
### -EdgeNodeSize
392410
Specifies the size of the virtual machine for the edge node. Use Get-AzureRmVMSize for acceptable VM sizes, and see HDInsight's pricing page. This parameter is valid only for RServer clusters.
393411
@@ -709,7 +727,6 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
709727
## INPUTS
710728
711729
### AzureHDInsightConfig
712-
713730
Parameter 'Config' accepts value of type 'AzureHDInsightConfig' from the pipeline
714731
715732
## OUTPUTS

0 commit comments

Comments
 (0)