public override void ExecuteCmdlet()
{
parameters.UserName = HttpCredential.UserName;
parameters.Password = HttpCredential.Password.ConvertToString();
if (RdpCredential != null)
{
parameters.RdpUsername = RdpCredential.UserName;
parameters.RdpPassword = RdpCredential.Password.ConvertToString();
}
if (OSType == OSType.Linux && SshCredential != null)
{
parameters.SshUserName = SshCredential.UserName;
if (!string.IsNullOrEmpty(SshCredential.Password.ConvertToString()))
{
parameters.SshPassword = SshCredential.Password.ConvertToString();
}
if (!string.IsNullOrEmpty(SshPublicKey))
{
parameters.SshPublicKey = SshPublicKey;
}
}
foreach (
var storageAccount in
AdditionalStorageAccounts.Where(
storageAccount => !parameters.AdditionalStorageAccounts.ContainsKey(storageAccount.Key)))
{
parameters.AdditionalStorageAccounts.Add(storageAccount.Key, storageAccount.Value);
}
foreach (var config in Configurations.Where(config => !parameters.Configurations.ContainsKey(config.Key)))
{
parameters.Configurations.Add(config.Key, config.Value);
}
foreach (var action in ScriptActions.Where(action => parameters.ScriptActions.ContainsKey(action.Key)))
{
parameters.ScriptActions.Add(action.Key,
action.Value.Select(a => a.GetScriptActionFromPSModel()).ToList());
}
foreach (var component in ComponentVersion.Where(component => !parameters.ComponentVersion.ContainsKey(component.Key)))
{
parameters.ComponentVersion.Add(component.Key, component.Value);
}
if (OozieMetastore != null)
{
var metastore = OozieMetastore;
parameters.OozieMetastore = new Metastore(metastore.SqlAzureServerName, metastore.DatabaseName, metastore.Credential.UserName, metastore.Credential.Password.ConvertToString());
}
if (HiveMetastore != null)
{
var metastore = HiveMetastore;
parameters.HiveMetastore = new Metastore(metastore.SqlAzureServerName, metastore.DatabaseName, metastore.Credential.UserName, metastore.Credential.Password.ConvertToString());
}
if (!string.IsNullOrEmpty(CertificatePassword))
{
if (!string.IsNullOrEmpty(CertificateFilePath))
{
CertificateFileContents = File.ReadAllBytes(CertificateFilePath);
}
var servicePrincipal = new Management.HDInsight.Models.ServicePrincipal(
GetApplicationId(), GetTenantId(AadTenantId), CertificateFileContents,
CertificatePassword);
parameters.Principal = servicePrincipal;
}
if (SecurityProfile != null)
{
parameters.SecurityProfile = new SecurityProfile()
{
DirectoryType = DirectoryType.ActiveDirectory,
Domain = SecurityProfile.Domain,
DomainUsername =
SecurityProfile.DomainUserCredential != null
? SecurityProfile.DomainUserCredential.UserName
: null,
DomainUserPassword =
SecurityProfile.DomainUserCredential != null &&
SecurityProfile.DomainUserCredential.Password != null
? SecurityProfile.DomainUserCredential.Password.ConvertToString()
: null,
OrganizationalUnitDN = SecurityProfile.OrganizationalUnitDN,
LdapsUrls = SecurityProfile.LdapsUrls,
ClusterUsersGroupDNs = SecurityProfile.ClusterUsersGroupDNs
};
}
var cluster = HDInsightManagementClient.CreateNewCluster(ResourceGroupName, ClusterName, parameters);
if (cluster != null)
{
WriteObject(new AzureHDInsightCluster(cluster.Cluster));
}
}