/// <summary>
 /// Initializes a new instance of the LinuxOperatingSystemProfile
 /// class.
 /// </summary>
 /// <param name="username">The username.</param>
 /// <param name="password">The password.</param>
 /// <param name="sshProfile">The SSH profile.</param>
 public LinuxOperatingSystemProfile(string username = default(string), string password = default(string), SshProfile sshProfile = default(SshProfile))
 {
     Username   = username;
     Password   = password;
     SshProfile = sshProfile;
     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;
        }