Skip to content

Commit c3c3274

Browse files
author
Shefali
committed
display script action bug fix
1 parent ccbb5f5 commit c3c3274

File tree

5 files changed

+54
-14
lines changed

5 files changed

+54
-14
lines changed

src/ResourceManager/HDInsight/Commands.HDInsight/Commands.HDInsight.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
<Compile Include="Models\Management\AzureHDInsightMetastore.cs" />
8484
<Compile Include="ManagementCommands\NewAzureHDInsightClusterCommand.cs" />
8585
<Compile Include="ClusterConfigurationUtils.cs" />
86+
<Compile Include="Models\Management\AzureHDInsightScriptAction.cs" />
8687
<Compile Include="Properties\AssemblyInfo.cs" />
8788
</ItemGroup>
8889
<ItemGroup>

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using System.Management.Automation;
1818
using Microsoft.Azure.Commands.HDInsight.Commands;
1919
using Microsoft.Azure.Commands.HDInsight.Models;
20+
using Microsoft.Azure.Commands.HDInsight.Models.Management;
2021
using Microsoft.Azure.Management.HDInsight.Models;
2122

2223
namespace Microsoft.Azure.Commands.HDInsight
@@ -27,7 +28,7 @@ namespace Microsoft.Azure.Commands.HDInsight
2728
OutputType(typeof(AzureHDInsightConfig))]
2829
public class AddAzureHDInsightScriptActionCommand : HDInsightCmdletBase
2930
{
30-
private ScriptAction _action;
31+
private AzureHDInsightScriptAction _action;
3132
#region Input Parameter Definitions
3233

3334
[Parameter(Position = 0,
@@ -55,12 +56,11 @@ public Uri Uri
5556
HelpMessage = "The name of the action.")]
5657
public string Name
5758
{
58-
get { return _action.Name; }
59-
set { _action.Name = value; }
59+
get { return _action.ActionName; }
60+
set { _action.ActionName = value; }
6061
}
6162

6263
[Parameter(Position = 4,
63-
Mandatory = true,
6464
HelpMessage = "The parameters for the action.")]
6565
public string Parameters
6666
{
@@ -72,12 +72,12 @@ public string Parameters
7272

7373
public AddAzureHDInsightScriptActionCommand()
7474
{
75-
_action = new ScriptAction();
75+
_action = new AzureHDInsightScriptAction();
7676
}
7777

7878
protected override void ProcessRecord()
7979
{
80-
List<ScriptAction> actions;
80+
List<AzureHDInsightScriptAction> actions;
8181

8282
if (Config.ScriptActions.TryGetValue(NodeType, out actions))
8383
{
@@ -86,7 +86,7 @@ protected override void ProcessRecord()
8686
}
8787
else
8888
{
89-
Config.ScriptActions.Add(NodeType, new List<ScriptAction> {_action});
89+
Config.ScriptActions.Add(NodeType, new List<AzureHDInsightScriptAction> { _action });
9090
}
9191

9292
WriteObject(Config);

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using System.Management.Automation;
2020
using Microsoft.Azure.Commands.HDInsight.Commands;
2121
using Microsoft.Azure.Commands.HDInsight.Models;
22+
using Microsoft.Azure.Commands.HDInsight.Models.Management;
2223
using Microsoft.Azure.Management.HDInsight.Models;
2324
using Microsoft.WindowsAzure.Commands.Common;
2425

@@ -103,7 +104,7 @@ public string DefaultStorageAccountKey
103104
public Dictionary<string, Dictionary<string, string>> Configurations { get; private set; }
104105

105106
[Parameter(HelpMessage = "Gets config actions for the cluster.")]
106-
public Dictionary<ClusterNodeType, List<ScriptAction>> ScriptActions { get; private set; }
107+
public Dictionary<ClusterNodeType, List<AzureHDInsightScriptAction>> ScriptActions { get; private set; }
107108

108109
[Parameter(HelpMessage = "Gets or sets the StorageContainer for the default Azure Storage Account.")]
109110
public string DefaultStorageContainer
@@ -213,7 +214,7 @@ var storageAccount in
213214
}
214215
foreach (var action in parameters.ScriptActions.Where(action => result.ScriptActions.ContainsKey(action.Key)))
215216
{
216-
result.ScriptActions.Add(action.Key, action.Value);
217+
result.ScriptActions.Add(action.Key, action.Value.Select(a => new AzureHDInsightScriptAction(a)).ToList());
217218
}
218219
return result;
219220
}
@@ -240,7 +241,7 @@ var storageAccount in
240241
}
241242
foreach (var action in value.ScriptActions.Where(action => parameters.ScriptActions.ContainsKey(action.Key)))
242243
{
243-
parameters.ScriptActions.Add(action.Key, action.Value);
244+
parameters.ScriptActions.Add(action.Key, action.Value.Select(a => a.GetScriptActionFromPSModel()).ToList());
244245
}
245246
}
246247
}
@@ -253,7 +254,7 @@ public NewAzureHDInsightClusterCommand()
253254
parameters = new ClusterCreateParameters();
254255
AdditionalStorageAccounts = new Dictionary<string, string>();
255256
Configurations = new Dictionary<string, Dictionary<string, string>>();
256-
ScriptActions = new Dictionary<ClusterNodeType, List<ScriptAction>>();
257+
ScriptActions = new Dictionary<ClusterNodeType, List<AzureHDInsightScriptAction>>();
257258
}
258259

259260
protected override void ProcessRecord()
@@ -293,7 +294,8 @@ var storageAccount in
293294
}
294295
foreach (var action in ScriptActions.Where(action => parameters.ScriptActions.ContainsKey(action.Key)))
295296
{
296-
parameters.ScriptActions.Add(action.Key, action.Value);
297+
parameters.ScriptActions.Add(action.Key,
298+
action.Value.Select(a => a.GetScriptActionFromPSModel()).ToList());
297299
}
298300
if (OozieMetastore != null)
299301
{

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
using System.Collections;
1616
using System.Collections.Generic;
17+
using Microsoft.Azure.Commands.HDInsight.Models.Management;
1718
using Microsoft.Azure.Management.HDInsight.Models;
1819

1920
namespace Microsoft.Azure.Commands.HDInsight.Models
@@ -73,14 +74,14 @@ public class AzureHDInsightConfig
7374
/// <summary>
7475
/// Gets config actions for the cluster.
7576
/// </summary>
76-
public Dictionary<ClusterNodeType, List<ScriptAction>> ScriptActions { get; private set; }
77+
public Dictionary<ClusterNodeType, List<AzureHDInsightScriptAction>> ScriptActions { get; private set; }
7778

7879
public AzureHDInsightConfig()
7980
{
8081
ClusterType = HDInsightClusterType.Hadoop;
8182
AdditionalStorageAccounts = new Dictionary<string, string>();
8283
Configurations = new Dictionary<string, Hashtable>();
83-
ScriptActions = new Dictionary<ClusterNodeType, List<ScriptAction>>();
84+
ScriptActions = new Dictionary<ClusterNodeType, List<AzureHDInsightScriptAction>>();
8485
}
8586
}
8687
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using System.Net.PeerToPeer.Collaboration;
3+
using Microsoft.Azure.Management.HDInsight.Models;
4+
5+
namespace Microsoft.Azure.Commands.HDInsight.Models.Management
6+
{
7+
public class AzureHDInsightScriptAction
8+
{
9+
public AzureHDInsightScriptAction(ScriptAction action)
10+
{
11+
ActionName = action.Name;
12+
Uri = action.Uri;
13+
Parameters = action.Parameters;
14+
}
15+
16+
public AzureHDInsightScriptAction()
17+
{
18+
}
19+
20+
public ScriptAction GetScriptActionFromPSModel()
21+
{
22+
var param = "";
23+
if (Parameters != null)
24+
{
25+
param = Parameters;
26+
}
27+
return new ScriptAction(ActionName, Uri, param);
28+
}
29+
30+
public string ActionName { get; set; }
31+
32+
public Uri Uri { get; set; }
33+
34+
public string Parameters { get; set; }
35+
}
36+
}

0 commit comments

Comments
 (0)