Skip to content

Commit a359862

Browse files
committed
Powershell changes to allow specifying VM sizes
1 parent 8ee6c12 commit a359862

File tree

10 files changed

+177
-17
lines changed

10 files changed

+177
-17
lines changed

src/ServiceManagement/HDInsight/Commands.HDInsight.Test/HDInsight/CmdLetTests/NewClusterCmdletTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ public void ICanCreateAClusterUsingPowerShellAndConfig_New_Set_Add_Hive_Oozie()
420420
.WithParameter(CmdletConstants.Credential, GetPSCredential("hadoop", this.GetRandomValidPassword()))
421421
.Invoke();
422422

423-
ClusterCreateParameters request = AzureHDInsightClusterManagementClientSimulator.LastCreateRequest;
423+
ClusterCreateParametersV2 request = AzureHDInsightClusterManagementClientSimulator.LastCreateRequest;
424424
Assert.IsNotNull(request.HiveMetastore);
425425
Assert.IsNotNull(request.OozieMetastore);
426426

@@ -493,7 +493,7 @@ public void ICanCreateAClusterUsingPowerShellAndConfig_New_Set_Add_Hive_Oozie_An
493493
.WithParameter(CmdletConstants.Credential, GetPSCredential("hadoop", this.GetRandomValidPassword()))
494494
.Invoke();
495495

496-
ClusterCreateParameters request = AzureHDInsightClusterManagementClientSimulator.LastCreateRequest;
496+
ClusterCreateParametersV2 request = AzureHDInsightClusterManagementClientSimulator.LastCreateRequest;
497497
Assert.IsNotNull(request.HiveMetastore);
498498
Assert.IsNotNull(request.OozieMetastore);
499499

@@ -565,7 +565,7 @@ public void ICanCreateAClusterUsingPowerShellAndConfig_New_Set_Add_ScriptAction(
565565
.WithParameter(CmdletConstants.Credential, GetPSCredential("hadoop", this.GetRandomValidPassword()))
566566
.Invoke();
567567

568-
ClusterCreateParameters request = AzureHDInsightClusterManagementClientSimulator.LastCreateRequest;
568+
ClusterCreateParametersV2 request = AzureHDInsightClusterManagementClientSimulator.LastCreateRequest;
569569
Assert.IsTrue(request.ConfigActions != null && request.ConfigActions.Count == 2);
570570
Assert.IsTrue(
571571
request.ConfigActions.ElementAt(0).Name == "test1" &&

src/ServiceManagement/HDInsight/Commands.HDInsight.Test/Models/Simulators/AzureHDInsightClusterManagementClientSimulator.cs

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace Microsoft.WindowsAzure.Commands.Test.Utilities.HDInsight.Simulators
3030
{
3131
internal class AzureHDInsightClusterManagementClientSimulator : IHDInsightClient
3232
{
33-
internal static ClusterCreateParameters LastCreateRequest;
33+
internal static ClusterCreateParametersV2 LastCreateRequest;
3434

3535
private static readonly Collection<SimulatorClusterContainer> Clusters = new Collection<SimulatorClusterContainer>
3636
{
@@ -176,9 +176,12 @@ public void Cancel()
176176
{
177177
}
178178

179+
180+
179181
public ClusterDetails CreateCluster(ClusterCreateParameters cluster)
180182
{
181-
Task<ClusterDetails> createTask = this.CreateClusterAsync(cluster);
183+
Task<ClusterDetails> createTask = this.CreateClusterAsync(
184+
new ClusterCreateParametersV2( cluster));
182185
createTask.Wait();
183186
return createTask.Result;
184187
}
@@ -188,7 +191,24 @@ public ClusterDetails CreateCluster(ClusterCreateParameters cluster, TimeSpan ti
188191
return this.CreateCluster(cluster);
189192
}
190193

194+
public ClusterDetails CreateCluster(ClusterCreateParametersV2 cluster)
195+
{
196+
Task<ClusterDetails> createTask = this.CreateClusterAsync(cluster);
197+
createTask.Wait();
198+
return createTask.Result;
199+
}
200+
201+
public ClusterDetails CreateCluster(ClusterCreateParametersV2 cluster, TimeSpan timeout)
202+
{
203+
return this.CreateCluster(cluster);
204+
}
205+
191206
public Task<ClusterDetails> CreateClusterAsync(ClusterCreateParameters clusterCreateParameters)
207+
{
208+
return CreateClusterAsync(new ClusterCreateParametersV2(clusterCreateParameters));
209+
}
210+
211+
public Task<ClusterDetails> CreateClusterAsync(ClusterCreateParametersV2 clusterCreateParameters)
192212
{
193213
this.LogMessage("Creating cluster '{0}' in location {1}", clusterCreateParameters.Name, clusterCreateParameters.Location);
194214
LastCreateRequest = clusterCreateParameters;
@@ -218,6 +238,16 @@ public void DeleteCluster(string dnsName, TimeSpan timeout)
218238
this.DeleteClusterAsync(dnsName).Wait();
219239
}
220240

241+
public void DeleteCluster(string dnsName, string location)
242+
{
243+
throw new NotImplementedException();
244+
}
245+
246+
public void DeleteCluster(string dnsName, string location, TimeSpan timeout)
247+
{
248+
throw new NotImplementedException();
249+
}
250+
221251
public async Task DeleteClusterAsync(string name)
222252
{
223253
ClusterDetails cluster = await this.GetClusterAsync(name);
@@ -230,6 +260,11 @@ public async Task DeleteClusterAsync(string name)
230260
Clusters.Remove(GetClusterInternal(name));
231261
}
232262

263+
public Task DeleteClusterAsync(string name, string location)
264+
{
265+
throw new NotImplementedException();
266+
}
267+
233268
public void DisableHttp(string dnsName, string location)
234269
{
235270
this.DisableHttpAsync(dnsName, location).Wait();
@@ -265,6 +300,13 @@ public ClusterDetails GetCluster(string dnsName)
265300
return getTask.Result;
266301
}
267302

303+
public ClusterDetails GetCluster(string dnsName, string location)
304+
{
305+
Task<ClusterDetails> getTask = this.GetClusterAsync(dnsName, location);
306+
getTask.Wait();
307+
return getTask.Result;
308+
}
309+
268310
public async Task<ClusterDetails> GetClusterAsync(string name)
269311
{
270312
this.LogMessage("Getting hdinsight clusters for subscriptionid : {0}", this.credentials.SubscriptionId.ToString());
@@ -273,6 +315,11 @@ public async Task<ClusterDetails> GetClusterAsync(string name)
273315
return cluster;
274316
}
275317

318+
public Task<ClusterDetails> GetClusterAsync(string name, string location)
319+
{
320+
throw new NotImplementedException();
321+
}
322+
276323
public ClusterDetails ChangeClusterSize(string dnsName, string location, int newSize)
277324
{
278325
return ChangeClusterSizeAsync(dnsName, location, newSize).WaitForResult();

src/ServiceManagement/HDInsight/Commands.HDInsight/Cmdlet/NewAzureHDInsightClusterCmdlet.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ public AzureHDInsightConfig Config
9494
var result = new AzureHDInsightConfig();
9595
result.ClusterSizeInNodes = this.command.ClusterSizeInNodes;
9696
result.HeadNodeVMSize = this.command.HeadNodeSize;
97+
result.DataNodeVMSize = this.command.DataNodeSize;
98+
result.ZookeeperNodeVMSize = this.command.ZookeeperNodeSize;
9799
result.ClusterType = this.command.ClusterType;
98100
result.VirtualNetworkId = this.command.VirtualNetworkId;
99101
result.SubnetName = this.command.SubnetName;
@@ -128,6 +130,8 @@ public AzureHDInsightConfig Config
128130
this.command.VirtualNetworkId = value.VirtualNetworkId;
129131
this.command.SubnetName = value.SubnetName;
130132
this.command.HeadNodeSize = value.HeadNodeVMSize;
133+
this.command.DataNodeSize = value.DataNodeVMSize;
134+
this.command.ZookeeperNodeSize = value.ZookeeperNodeVMSize;
131135
this.command.DefaultStorageAccountName = value.DefaultStorageAccount.StorageAccountName;
132136
this.command.DefaultStorageAccountKey = value.DefaultStorageAccount.StorageAccountKey;
133137
this.command.DefaultStorageContainerName = value.DefaultStorageAccount.StorageContainerName;
@@ -257,7 +261,7 @@ public string Version
257261
/// <inheritdoc />
258262
[Parameter(Position = 13, Mandatory = false, HelpMessage = "The size of the headnode VM.",
259263
ParameterSetName = AzureHdInsightPowerShellConstants.ParameterSetClusterByNameWithSpecificSubscriptionCredentials)]
260-
public NodeVMSize HeadNodeVMSize
264+
public string HeadNodeVMSize
261265
{
262266
get { return this.command.HeadNodeSize; }
263267
set { this.command.HeadNodeSize = value; }
@@ -290,6 +294,24 @@ public string SubnetName
290294
set { this.command.SubnetName = value; }
291295
}
292296

297+
/// <inheritdoc />
298+
[Parameter(Position = 17, Mandatory = false, HelpMessage = "The size of the datanode VM.",
299+
ParameterSetName = AzureHdInsightPowerShellConstants.ParameterSetClusterByNameWithSpecificSubscriptionCredentials)]
300+
public string DataNodeVMSize
301+
{
302+
get { return this.command.DataNodeSize; }
303+
set { this.command.DataNodeSize = value; }
304+
}
305+
306+
/// <inheritdoc />
307+
[Parameter(Position = 18, Mandatory = false, HelpMessage = "The size of the zookeeper VM.",
308+
ParameterSetName = AzureHdInsightPowerShellConstants.ParameterSetClusterByNameWithSpecificSubscriptionCredentials)]
309+
public string ZookeeperNodeVMSize
310+
{
311+
get { return this.command.ZookeeperNodeSize; }
312+
set { this.command.ZookeeperNodeSize = value; }
313+
}
314+
293315
/// <inheritdoc />
294316
protected override void BeginProcessing()
295317
{

src/ServiceManagement/HDInsight/Commands.HDInsight/Cmdlet/NewAzureHDInsightClusterConfigCmdlet.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public int ClusterSizeInNodes
5252
/// <inheritdoc />
5353
[Parameter(Position = 1, Mandatory = false, HelpMessage = "The size of the head node VMs.",
5454
ParameterSetName = AzureHdInsightPowerShellConstants.ParameterSetConfigClusterSizeInNodesOnly)]
55-
public NodeVMSize HeadNodeVMSize
55+
public string HeadNodeVMSize
5656
{
5757
get { return command.HeadNodeVMSize; }
5858
set { command.HeadNodeVMSize = value; }
@@ -85,6 +85,23 @@ public string SubnetName
8585
set { command.SubnetName = value; }
8686
}
8787

88+
/// <inheritdoc />
89+
[Parameter(Position = 5, Mandatory = false, HelpMessage = "The size of the data node VMs.",
90+
ParameterSetName = AzureHdInsightPowerShellConstants.ParameterSetConfigClusterSizeInNodesOnly)]
91+
public string DataNodeVMSize
92+
{
93+
get { return command.DataNodeVMSize; }
94+
set { command.DataNodeVMSize = value; }
95+
}
96+
97+
/// <inheritdoc />
98+
[Parameter(Position = 6, Mandatory = false, HelpMessage = "The size of the zookeper node VMs.",
99+
ParameterSetName = AzureHdInsightPowerShellConstants.ParameterSetConfigClusterSizeInNodesOnly)]
100+
public string ZookeeperNodeVMSize
101+
{
102+
get { return command.ZookeeperNodeVMSize; }
103+
set { command.ZookeeperNodeVMSize = value; }
104+
}
88105
/// <summary>
89106
/// Finishes the execution of the cmdlet by listing the clusters.
90107
/// </summary>

src/ServiceManagement/HDInsight/Commands.HDInsight/Model/Commands/BaseCommandInterfaces/INewAzureHDInsightClusterConfigBase.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,23 @@ internal interface INewAzureHDInsightClusterConfigBase
2929
/// <value>
3030
/// The size of the head node VM.
3131
/// </value>
32-
NodeVMSize HeadNodeVMSize { get; set; }
32+
string HeadNodeVMSize { get; set; }
33+
34+
/// <summary>
35+
/// Gets or sets the size of the data node VMs.
36+
/// </summary>
37+
/// <value>
38+
/// The size of the data node VM.
39+
/// </value>
40+
string DataNodeVMSize { get; set; }
41+
42+
/// <summary>
43+
/// Gets or sets the size of the zookeeper node VMs.
44+
/// </summary>
45+
/// <value>
46+
/// The size of the zookeeper node VM.
47+
/// </value>
48+
string ZookeeperNodeVMSize { get; set; }
3349

3450
/// <summary>
3551
/// Gets or sets the type of the cluster.

src/ServiceManagement/HDInsight/Commands.HDInsight/Model/Commands/CommandImplementations/NewAzureHDInsightClusterCommand.cs

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ public NewAzureHDInsightClusterCommand()
4646
public int ClusterSizeInNodes { get; set; }
4747

4848
/// <inheritdoc />
49-
public NodeVMSize HeadNodeSize { get; set; }
49+
public string HeadNodeSize { get; set; }
50+
51+
/// <inheritdoc />
52+
public string DataNodeSize { get; set; }
53+
54+
/// <inheritdoc />
55+
public string ZookeeperNodeSize { get; set; }
5056

5157
/// <inheritdoc />
5258
public ConfigValuesCollection CoreConfiguration { get; set; }
@@ -111,14 +117,15 @@ public override async Task EndProcessing()
111117
{
112118
IHDInsightClient client = this.GetClient();
113119
client.ClusterProvisioning += this.ClientOnClusterProvisioning;
114-
ClusterCreateParameters createClusterRequest = this.GetClusterCreateParameters();
120+
ClusterCreateParametersV2 createClusterRequest = this.GetClusterCreateParameters();
115121
var cluster = await client.CreateClusterAsync(createClusterRequest);
116122
this.Output.Add(new AzureHDInsightCluster(cluster));
117123
}
118124

119-
internal ClusterCreateParameters GetClusterCreateParameters()
125+
internal ClusterCreateParametersV2 GetClusterCreateParameters()
120126
{
121-
var createClusterRequest = new ClusterCreateParameters();
127+
var createClusterRequest = new ClusterCreateParametersV2();
128+
122129
createClusterRequest.Name = this.Name;
123130
createClusterRequest.Version = this.Version;
124131
createClusterRequest.Location = this.Location;
@@ -136,7 +143,7 @@ internal ClusterCreateParameters GetClusterCreateParameters()
136143
createClusterRequest.StormConfiguration.AddRange(this.StormConfiguration);
137144
createClusterRequest.HBaseConfiguration.AdditionalLibraries = this.HBaseConfiguration.AdditionalLibraries;
138145
createClusterRequest.HBaseConfiguration.ConfigurationCollection.AddRange(this.HBaseConfiguration.ConfigurationCollection);
139-
createClusterRequest.HeadNodeSize = this.HeadNodeSize;
146+
140147
createClusterRequest.DefaultStorageAccountName = this.DefaultStorageAccountName;
141148
createClusterRequest.DefaultStorageAccountKey = this.DefaultStorageAccountKey;
142149
createClusterRequest.DefaultStorageContainer = this.DefaultStorageContainerName;
@@ -171,6 +178,22 @@ internal ClusterCreateParameters GetClusterCreateParameters()
171178
this.OozieMetastore.Credential.UserName,
172179
this.OozieMetastore.Credential.GetCleartextPassword());
173180
}
181+
182+
if (!string.IsNullOrEmpty(this.HeadNodeSize))
183+
{
184+
createClusterRequest.HeadNodeSize = this.HeadNodeSize;
185+
}
186+
187+
if (!string.IsNullOrEmpty(this.DataNodeSize))
188+
{
189+
createClusterRequest.DataNodeSize = this.DataNodeSize;
190+
}
191+
192+
if (!string.IsNullOrEmpty(this.ZookeeperNodeSize))
193+
{
194+
createClusterRequest.ZookeeperNodeSize = this.ZookeeperNodeSize;
195+
}
196+
174197
return createClusterRequest;
175198
}
176199

src/ServiceManagement/HDInsight/Commands.HDInsight/Model/Commands/CommandImplementations/NewAzureHDInsightClusterConfigCommand.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,24 @@ public int ClusterSizeInNodes
3333
set { this.config.ClusterSizeInNodes = value; }
3434
}
3535

36-
public NodeVMSize HeadNodeVMSize
36+
public string HeadNodeVMSize
3737
{
3838
get { return this.config.HeadNodeVMSize; }
3939
set { this.config.HeadNodeVMSize = value; }
4040
}
4141

42+
public string DataNodeVMSize
43+
{
44+
get { return this.config.DataNodeVMSize; }
45+
set { this.config.DataNodeVMSize = value; }
46+
}
47+
48+
public string ZookeeperNodeVMSize
49+
{
50+
get { return this.config.ZookeeperNodeVMSize; }
51+
set { this.config.ZookeeperNodeVMSize = value; }
52+
}
53+
4254
public ClusterType ClusterType
4355
{
4456
get { return this.config.ClusterType; }

src/ServiceManagement/HDInsight/Commands.HDInsight/Model/Commands/CommandInterfaces/INewAzureHDInsightClusterCommand.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ internal interface INewAzureHDInsightClusterCommand : IAzureHDInsightCommand<Azu
4949

5050
string Location { get; set; }
5151

52-
NodeVMSize HeadNodeSize { get; set; }
52+
string HeadNodeSize { get; set; }
53+
54+
string DataNodeSize { get; set; }
55+
56+
string ZookeeperNodeSize { get; set; }
5357

5458
ClusterType ClusterType { get; set; }
5559

src/ServiceManagement/HDInsight/Commands.HDInsight/Model/DataObjects/AzureHDInsightConfig.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ public AzureHDInsightConfig()
3636
this.MapReduceConfiguration = new MapReduceConfiguration();
3737
this.HiveConfiguration = new HiveConfiguration();
3838
this.OozieConfiguration = new OozieConfiguration();
39-
this.HeadNodeVMSize = NodeVMSize.Default;
39+
this.HeadNodeVMSize = NodeVMSize.Large.ToString();
40+
this.DataNodeVMSize = NodeVMSize.Large.ToString();
41+
this.ZookeeperNodeVMSize = null;
4042
this.ClusterType = ClusterType.Hadoop;
4143
this.StormConfiguration = new ConfigValuesCollection();
4244
this.HBaseConfiguration = new HBaseConfiguration();
@@ -53,7 +55,23 @@ public AzureHDInsightConfig()
5355
/// <value>
5456
/// The size of the head node VM.
5557
/// </value>
56-
public NodeVMSize HeadNodeVMSize { get; set; }
58+
public string HeadNodeVMSize { get; set; }
59+
60+
/// <summary>
61+
/// Gets or sets the size of the head node VM.
62+
/// </summary>
63+
/// <value>
64+
/// The size of the head node VM.
65+
/// </value>
66+
public string DataNodeVMSize { get; set; }
67+
68+
/// <summary>
69+
/// Gets or sets the size of the head node VM.
70+
/// </summary>
71+
/// <value>
72+
/// The size of the head node VM.
73+
/// </value>
74+
public string ZookeeperNodeVMSize { get; set; }
5775

5876
/// <summary>
5977
/// Gets or sets the size of the cluster in data nodes.

src/ServiceManagement/HDInsight/Commands.HDInsight/Model/GetAzureHDInsightClusters/AzureHDInsightClusterCommandBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ internal IHDInsightClient GetClient()
4747
this.CurrentSubscription,
4848
client.GetEnvironmentOrDefault(this.CurrentSubscription.Environment),
4949
client.Profile);
50+
subscriptionCredentials.Endpoint = this.Endpoint;
5051
var clientInstance = ServiceLocator.Instance.Locate<IAzureHDInsightClusterManagementClientFactory>().Create(subscriptionCredentials);
5152
clientInstance.SetCancellationSource(this.tokenSource);
5253
if (this.Logger.IsNotNull())

0 commit comments

Comments
 (0)