private static void AddConfigActionComponent(CustomActionComponent configAction, HDInsight.ClusterCreateParameters inputs, ClusterRole headnodeRole, ClusterRole workernodeRole) { configAction.CustomActions = new CustomActionList(); // Converts config action from PS/SDK to wire contract. foreach (ConfigAction ca in inputs.ConfigActions) { CustomAction newConfigAction; // Based on the config action type defined in SDK, convert them to config action defined in wire contract. ScriptAction sca = ca as ScriptAction; if (sca != null) { newConfigAction = new ScriptCustomAction { Name = ca.Name, Uri = sca.Uri, Parameters = sca.Parameters }; } else { throw new NotSupportedException("No such config action supported."); } newConfigAction.ClusterRoleCollection = new ClusterRoleCollection(); // Add in cluster role collection for each config action. foreach (ClusterNodeType clusterRoleType in ca.ClusterRoleCollection) { if (clusterRoleType == ClusterNodeType.HeadNode) { newConfigAction.ClusterRoleCollection.Add(headnodeRole); } else if (clusterRoleType == ClusterNodeType.DataNode) { newConfigAction.ClusterRoleCollection.Add(workernodeRole); } else { throw new NotSupportedException("No such node type supported."); } } configAction.CustomActions.Add(newConfigAction); } }