/// <summary> /// Initializes a new instance of the Role class. /// </summary> /// <param name="name">The name of the role.</param> /// <param name="minInstanceCount">The minimum instance count of the /// cluster.</param> /// <param name="targetInstanceCount">The instance count of the /// cluster.</param> /// <param name="hardwareProfile">The hardware profile.</param> /// <param name="osProfile">The operating system profile.</param> /// <param name="virtualNetworkProfile">The virtual network /// profile.</param> /// <param name="dataDisksGroups">The data disks groups for the /// role.</param> /// <param name="scriptActions">The list of script actions on the /// role.</param> public Role(string name = default(string), int?minInstanceCount = default(int?), int?targetInstanceCount = default(int?), HardwareProfile hardwareProfile = default(HardwareProfile), OsProfile osProfile = default(OsProfile), VirtualNetworkProfile virtualNetworkProfile = default(VirtualNetworkProfile), IList <DataDisksGroups> dataDisksGroups = default(IList <DataDisksGroups>), IList <ScriptAction> scriptActions = default(IList <ScriptAction>)) { Name = name; MinInstanceCount = minInstanceCount; TargetInstanceCount = targetInstanceCount; HardwareProfile = hardwareProfile; OsProfile = osProfile; VirtualNetworkProfile = virtualNetworkProfile; DataDisksGroups = dataDisksGroups; ScriptActions = scriptActions; CustomInit(); }
/// <summary> /// Initializes a new instance of the Role class. /// </summary> /// <param name="name">The name of the role.</param> /// <param name="minInstanceCount">The minimum instance count of the /// cluster.</param> /// <param name="targetInstanceCount">The instance count of the /// cluster.</param> /// <param name="autoscaleConfiguration">The autoscale /// configurations.</param> /// <param name="hardwareProfile">The hardware profile.</param> /// <param name="osProfile">The operating system profile.</param> /// <param name="virtualNetworkProfile">The virtual network /// profile.</param> /// <param name="dataDisksGroups">The data disks groups for the /// role.</param> /// <param name="scriptActions">The list of script actions on the /// role.</param> /// <param name="encryptDataDisks">Indicates whether encrypt the data /// disks.</param> public Role(string name = default(string), int?minInstanceCount = default(int?), int?targetInstanceCount = default(int?), Autoscale autoscaleConfiguration = default(Autoscale), HardwareProfile hardwareProfile = default(HardwareProfile), OsProfile osProfile = default(OsProfile), VirtualNetworkProfile virtualNetworkProfile = default(VirtualNetworkProfile), IList <DataDisksGroups> dataDisksGroups = default(IList <DataDisksGroups>), IList <ScriptAction> scriptActions = default(IList <ScriptAction>), bool?encryptDataDisks = default(bool?)) { Name = name; MinInstanceCount = minInstanceCount; TargetInstanceCount = targetInstanceCount; AutoscaleConfiguration = autoscaleConfiguration; HardwareProfile = hardwareProfile; OsProfile = osProfile; VirtualNetworkProfile = virtualNetworkProfile; DataDisksGroups = dataDisksGroups; ScriptActions = scriptActions; EncryptDataDisks = encryptDataDisks; CustomInit(); }
private static IEnumerable<Role> GetRoleCollection(ClusterCreateParameters clusterCreateParameters) { //OS Profile var osProfile = new OsProfile(); if (clusterCreateParameters.OSType == OSType.Windows) { RdpSettings rdpSettings = null; if (!string.IsNullOrEmpty(clusterCreateParameters.RdpUsername)) { rdpSettings = new RdpSettings { UserName = clusterCreateParameters.RdpUsername, Password = clusterCreateParameters.RdpPassword, ExpiryDate = clusterCreateParameters.RdpAccessExpiry }; } osProfile = new OsProfile { WindowsOperatingSystemProfile = new WindowsOperatingSystemProfile { RdpSettings = rdpSettings } }; } else if (clusterCreateParameters.OSType == OSType.Linux) { var sshPublicKeys = new List<SshPublicKey>(); if (!string.IsNullOrEmpty(clusterCreateParameters.SshPublicKey)) { var sshPublicKey = new SshPublicKey { CertificateData = clusterCreateParameters.SshPublicKey }; sshPublicKeys.Add(sshPublicKey); } SshProfile sshProfile; if (sshPublicKeys.Count > 0) { sshProfile = new SshProfile { SshPublicKeys = sshPublicKeys }; } else { sshProfile = null; } osProfile = new OsProfile { LinuxOperatingSystemProfile = new LinuxOperatingSystemProfile { UserName = clusterCreateParameters.SshUserName, Password = clusterCreateParameters.SshPassword, SshProfile = sshProfile } }; } //VNet Profile var vnetProfile = new VirtualNetworkProfile(); if (!string.IsNullOrEmpty(clusterCreateParameters.VirtualNetworkId)) { vnetProfile.Id = clusterCreateParameters.VirtualNetworkId; } if (!string.IsNullOrEmpty(clusterCreateParameters.SubnetName)) { vnetProfile.SubnetName = clusterCreateParameters.SubnetName; } if (string.IsNullOrEmpty(vnetProfile.Id) && string.IsNullOrEmpty(vnetProfile.SubnetName)) { vnetProfile = null; } List<ScriptAction> workernodeactions = null; List<ScriptAction> headnodeactions = null; List<ScriptAction> zookeepernodeactions = null; //Script Actions foreach (var scriptAction in clusterCreateParameters.ScriptActions) { if (scriptAction.Key.ToString().ToLower().Equals("workernode")) { workernodeactions = scriptAction.Value; } else if (scriptAction.Key.ToString().ToLower().Equals("headnode")) { headnodeactions = scriptAction.Value; } else if (scriptAction.Key.ToString().ToLower().Equals("zookeepernode")) { zookeepernodeactions = scriptAction.Value; } } //Roles var roles = new List<Role>(); var headNodeSize = GetHeadNodeSize(clusterCreateParameters); var headNode = new Role { Name = "headnode", TargetInstanceCount = 2, HardwareProfile = new HardwareProfile { VmSize = headNodeSize }, OsProfile = osProfile, VirtualNetworkProfile = vnetProfile, ScriptActions = headnodeactions }; roles.Add(headNode); var workerNodeSize = GetWorkerNodeSize(clusterCreateParameters); var workerNode = new Role { Name = "workernode", TargetInstanceCount = clusterCreateParameters.ClusterSizeInNodes, HardwareProfile = new HardwareProfile { VmSize = workerNodeSize }, OsProfile = osProfile, ScriptActions = workernodeactions }; roles.Add(workerNode); if (clusterCreateParameters.OSType == OSType.Windows) { if (clusterCreateParameters.ClusterType == HDInsightClusterType.Hadoop || clusterCreateParameters.ClusterType == HDInsightClusterType.Spark) { return roles; } } if (clusterCreateParameters.OSType == OSType.Linux) { if (clusterCreateParameters.ClusterType == HDInsightClusterType.Hadoop || clusterCreateParameters.ClusterType == HDInsightClusterType.Spark) { clusterCreateParameters.ZookeeperNodeSize = "Small"; } } string zookeeperNodeSize = clusterCreateParameters.ZookeeperNodeSize ?? "Medium"; var zookeepernode = new Role { Name = "zookeepernode", ScriptActions = zookeepernodeactions, TargetInstanceCount = 3, OsProfile = osProfile, HardwareProfile = new HardwareProfile { VmSize = zookeeperNodeSize } }; roles.Add(zookeepernode); return roles; }