Skip to content

Adding option to config "IgnoreSslErrors" when creating HDInsight client #319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void CommandsNeedCurrentSubscriptionSet()
var getClustersCommand = new GetAzureHDInsightClusterCommand();
try
{
getClustersCommand.GetClient();
getClustersCommand.GetClient(false);
Assert.Fail("Should have failed.");
}
catch (ArgumentNullException noSubscriptionException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Microsoft.WindowsAzure.Commands.Test.Utilities.HDInsight.Simulators
{
public class AzureHDInsightClusterManagementClientSimulatorFactory : IAzureHDInsightClusterManagementClientFactory
{
public IHDInsightClient Create(IHDInsightSubscriptionCredentials credentials)
public IHDInsightClient Create(IHDInsightSubscriptionCredentials credentials, bool ignoreSslErrors)
{
return new AzureHDInsightClusterManagementClientSimulator(credentials);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ public Uri Endpoint
set { this.command.Endpoint = value; }
}

/// <inheritdoc />
[Parameter(Position = 4, Mandatory = false, HelpMessage = "Rule for SSL errors with HDInsight client.")]
public bool IgnoreSslErrors
{
get { return this.command.IgnoreSslErrors; }
set { this.command.IgnoreSslErrors = value; }
}

/// <inheritdoc />
[Parameter(Position = 0, Mandatory = false, HelpMessage = "The name of the HDInsight cluster to locate.", ValueFromPipeline = true,
ParameterSetName = AzureHdInsightPowerShellConstants.ParameterSetClusterByNameWithSpecificSubscriptionCredentials)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ public Uri Endpoint
set { this.command.Endpoint = value; }
}

/// <inheritdoc />
[Parameter(Mandatory = false, HelpMessage = "Rule for SSL errors with HDInsight client.")]
public bool IgnoreSslErrors
{
get { return this.command.IgnoreSslErrors; }
set { this.command.IgnoreSslErrors = value; }
}

/// <inheritdoc />
[Parameter(Mandatory = false, HelpMessage = "The JobID of the jobDetails to get details for.", ValueFromPipeline = true,
ValueFromPipelineByPropertyName = true)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ public Uri Endpoint
set { this.command.Endpoint = value; }
}

/// <inheritdoc />
[Parameter(Mandatory = false, HelpMessage = "Rule for SSL errors with HDInsight client.")]
public bool IgnoreSslErrors
{
get { return this.command.IgnoreSslErrors; }
set { this.command.IgnoreSslErrors = value; }
}

/// <inheritdoc />
[Parameter(Mandatory = true, HelpMessage = "The JobID of the jobDetails to get details for.", ValueFromPipeline = true,
ValueFromPipelineByPropertyName = true)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ public Uri Endpoint
set { this.command.Endpoint = value; }
}

/// <inheritdoc />
[Parameter(Mandatory = false, HelpMessage = "Rule for SSL errors with HDInsight client.")]
public bool IgnoreSslErrors
{
get { return this.command.IgnoreSslErrors; }
set { this.command.IgnoreSslErrors = value; }
}

/// <summary>
/// Gets or sets a flag to only show Azure regions available to the subscription.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ public Uri Endpoint
set { this.command.Endpoint = value; }
}

/// <inheritdoc />
[Parameter(Position = 5, Mandatory = false, HelpMessage = "Rule for SSL errors with HDInsight client.")]
public bool IgnoreSslErrors
{
get { return this.command.IgnoreSslErrors; }
set { this.command.IgnoreSslErrors = value; }
}

/// <inheritdoc />
[Parameter(Position = 1, Mandatory = true, HelpMessage = "The Location of the HDInsight cluster to grant http access to.")]
public string Location
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,14 @@ public Uri EndPoint
set { this.command.Endpoint = value; }
}

[Parameter(Position = 19, Mandatory = false, HelpMessage = "Rule for SSL errors with HDInsight client.",
ParameterSetName = AzureHdInsightPowerShellConstants.ParameterSetClusterByNameWithSpecificSubscriptionCredentials)]
public bool IgnoreSslErrors
{
get { return this.command.IgnoreSslErrors; }
set { this.command.IgnoreSslErrors = value; }
}

/// <inheritdoc />
[Parameter(Position = 3, Mandatory = true, HelpMessage = "The azure location where the new cluster should be created.",
ParameterSetName = AzureHdInsightPowerShellConstants.ParameterSetClusterByNameWithSpecificSubscriptionCredentials)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ public Uri Endpoint
set { this.command.Endpoint = value; }
}

/// <inheritdoc />
[Parameter(Position = 6, Mandatory = false, HelpMessage = "Rule for SSL errors with HDInsight client.",
ParameterSetName = AzureHdInsightPowerShellConstants.ParameterSetClusterByNameWithSpecificSubscriptionCredentials)]
public bool IgnoreSslErrors
{
get { return this.command.IgnoreSslErrors; }
set { this.command.IgnoreSslErrors = value; }
}

/// <inheritdoc />
[Parameter(Position = 0, Mandatory = true, HelpMessage = "The name of the cluster to remove.", ValueFromPipeline = true,
ParameterSetName = AzureHdInsightPowerShellConstants.ParameterSetClusterByNameWithSpecificSubscriptionCredentials)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ public bool Enable
set { this.enableHttpServices = value; }
}

/// <inheritdoc />
[Parameter(Position = 6, Mandatory = false, HelpMessage = "Rule for SSL errors with HDInsight client.",
ParameterSetName = AzureHdInsightPowerShellConstants.ParameterSetClusterByNameWithSpecificSubscriptionCredentials)]
public bool IgnoreSslErrors
{
get { return this.command.IgnoreSslErrors; }
set { this.command.IgnoreSslErrors = value; }
}

/// <inheritdoc />
[Parameter(Position = 4, Mandatory = false, HelpMessage = "The Endpoint to use when connecting to Azure.",
ParameterSetName = AzureHdInsightPowerShellConstants.ParameterSetClusterByNameWithSpecificSubscriptionCredentials)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ public Uri Endpoint
set { command.Endpoint = value; }
}

/// <inheritdoc />
[Parameter(Mandatory = false, HelpMessage = "Rule for SSL errors with HDInsight client.",
ParameterSetName = AzureHdInsightPowerShellConstants.ParameterSetClusterByNameWithSpecificSubscriptionCredentials)]
public bool IgnoreSslErrors
{
get { return command.IgnoreSslErrors; }
set { command.IgnoreSslErrors = value; }
}

/// <inheritdoc />
[Parameter(Mandatory = false, HelpMessage = "The name of the HDInsight cluster to set the size of.", ValueFromPipeline = false,
ParameterSetName = AzureHdInsightPowerShellConstants.ParameterSetClusterByNameWithSpecificSubscriptionCredentials)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ public Uri Endpoint
set { this.command.Endpoint = value; }
}

/// <inheritdoc />
[Parameter(Mandatory = false, HelpMessage = "Rule for SSL errors with HDInsight client.",
ParameterSetName = AzureHdInsightPowerShellConstants.ParameterSetStartJobByNameWithSpecificSubscriptionCredentials)]
public bool IgnoreSslErrors
{
get { return this.command.IgnoreSslErrors; }
set { this.command.IgnoreSslErrors = value; }
}

/// <inheritdoc />
[Parameter(Mandatory = true, Position = 2, HelpMessage = "The jobDetails definition to start on the Azure HDInsight cluster.",
ValueFromPipeline = true)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ public Uri Endpoint
set { this.command.Endpoint = value; }
}

[Parameter(Mandatory = false, HelpMessage = "Rule for SSL errors with HDInsight client.",
ParameterSetName = AzureHdInsightPowerShellConstants.ParameterSetStartJobByNameWithSpecificSubscriptionCredentials)]
public bool IgnoreSslErrors
{
get { return this.command.IgnoreSslErrors; }
set { this.command.IgnoreSslErrors = value; }
}

/// <inheritdoc />
[Parameter(Mandatory = true, HelpMessage = "The JobID of the jobDetails to stop.", ValueFromPipeline = true)]
[Alias(AzureHdInsightPowerShellConstants.JobId)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ public Uri Endpoint
set { this.command.Endpoint = value; }
}

/// <inheritdoc />
[Parameter(Position = 5, Mandatory = false, HelpMessage = "Rule for SSL errors with HDInsight client.",
ParameterSetName = AzureHdInsightPowerShellConstants.ParameterSetClusterByNameWithSpecificSubscriptionCredentials)]
public bool IgnoreSslErrors
{
get { return this.command.IgnoreSslErrors; }
set { this.command.IgnoreSslErrors = value; }
}

/// <inheritdoc />
[Parameter(Position = 0, Mandatory = true, HelpMessage = "The name of the HDInsight cluster to locate.", ValueFromPipeline = true,
ParameterSetName = AzureHdInsightPowerShellConstants.ParameterSetClusterByNameWithSpecificSubscriptionCredentials)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ public Uri Endpoint
set { this.command.Endpoint = value; }
}

/// <inheritdoc />
[Parameter(Mandatory = false, HelpMessage = "Rule for SSL errors with HDInsight client.",
ParameterSetName = AzureHdInsightPowerShellConstants.ParameterSetJobHistoryByNameWithSpecificSubscriptionCredentials)]
public bool IgnoreSslErrors
{
get { return this.command.IgnoreSslErrors; }
set { this.command.IgnoreSslErrors = value; }
}

/// <inheritdoc />
[Parameter(Mandatory = true, HelpMessage = "The Jobs to wait for.", ValueFromPipeline = true,
ParameterSetName = AzureHdInsightPowerShellConstants.ParameterSetWaitJobByJob)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal class GetAzureHDInsightClusterCommand : AzureHDInsightClusterCommand<Az
{
public override async Task EndProcessing()
{
IHDInsightClient client = this.GetClient();
IHDInsightClient client = this.GetClient(this.IgnoreSslErrors);
if (!string.IsNullOrWhiteSpace(this.Name))
{
var azureCluster = await client.GetClusterAsync(this.Name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ internal class GetAzureHDInsightPropertiesCommand : AzureHDInsightClusterCommand

public override async Task EndProcessing()
{
IHDInsightClient client = this.GetClient();
IHDInsightClient client = this.GetClient(IgnoreSslErrors);
var capabilities = await client.ListResourceProviderPropertiesAsync();
capabilities = capabilities.ToList();
var azureCapabilities = new AzureHDInsightCapabilities(capabilities);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public override async Task EndProcessing()
this.Name.ArgumentNotNullOrEmpty("Name");
this.Location.ArgumentNotNullOrEmpty("Location");

IHDInsightClient client = this.GetClient();
IHDInsightClient client = this.GetClient(IgnoreSslErrors);
if (this.Enable)
{
this.Credential.ArgumentNotNull("Credential");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public NewAzureHDInsightClusterCommand()

public override async Task EndProcessing()
{
IHDInsightClient client = this.GetClient();
IHDInsightClient client = this.GetClient(IgnoreSslErrors);
client.ClusterProvisioning += this.ClientOnClusterProvisioning;
ClusterCreateParametersV2 createClusterRequest = this.GetClusterCreateParameters();
var cluster = await client.CreateClusterAsync(createClusterRequest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal class RemoveAzureHDInsightClusterCommand : AzureHDInsightClusterCommand

public override async Task EndProcessing()
{
IHDInsightClient client = this.GetClient();
IHDInsightClient client = this.GetClient(IgnoreSslErrors);
await client.DeleteClusterAsync(this.Name);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public override async Task EndProcessing()
{
Name.ArgumentNotNull("Name");
Location.ArgumentNotNull("Location");
var client = GetClient();
var client = GetClient(IgnoreSslErrors);
var cluster = await client.ChangeClusterSizeAsync(Name, Location, ClusterSizeInNodes);
if (cluster != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal class UseAzureHDInsightClusterCommand : AzureHDInsightClusterCommand<Az
public override async Task EndProcessing()
{
this.Name.ArgumentNotNullOrEmpty("Name");
IHDInsightClient client = this.GetClient();
IHDInsightClient client = this.GetClient(IgnoreSslErrors);
var cluster = await client.GetClusterAsync(this.Name);
var connection = new AzureHDInsightClusterConnection();
ProfileClient profileClient = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ namespace Microsoft.WindowsAzure.Management.HDInsight.Cmdlet.GetAzureHDInsightCl
{
internal class AzureHDInsightClusterManagementClientFactory : IAzureHDInsightClusterManagementClientFactory
{
public IHDInsightClient Create(IHDInsightSubscriptionCredentials credentials)
public IHDInsightClient Create(IHDInsightSubscriptionCredentials credentials, bool ignoreSslErrors)
{
return HDInsightClient.Connect(credentials);
var client = HDInsightClient.Connect(credentials);
client.IgnoreSslErrors = ignoreSslErrors;
return client;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public override void Cancel()
this.tokenSource.Cancel();
}

internal IHDInsightClient GetClient()
internal IHDInsightClient GetClient(bool ignoreSslErrors = false)
{
this.CurrentSubscription.ArgumentNotNull("CurrentSubscription");

Expand All @@ -55,7 +55,7 @@ internal IHDInsightClient GetClient()
subscriptionCredentials.Endpoint = this.Endpoint;
}

var clientInstance = ServiceLocator.Instance.Locate<IAzureHDInsightClusterManagementClientFactory>().Create(subscriptionCredentials);
var clientInstance = ServiceLocator.Instance.Locate<IAzureHDInsightClusterManagementClientFactory>().Create(subscriptionCredentials, ignoreSslErrors);
clientInstance.SetCancellationSource(this.tokenSource);
if (this.Logger.IsNotNull())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public virtual CancellationToken CancellationToken

public Uri Endpoint { get; set; }

public bool IgnoreSslErrors { get; set; }

public ILogWriter Logger { get; set; }

public string Subscription { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ namespace Microsoft.WindowsAzure.Management.HDInsight.Cmdlet.GetAzureHDInsightCl
{
internal interface IAzureHDInsightClusterManagementClientFactory
{
IHDInsightClient Create(IHDInsightSubscriptionCredentials credentials);
IHDInsightClient Create(IHDInsightSubscriptionCredentials credentials, bool ignoreSslErrors);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ internal interface IAzureHDInsightCommonCommandBase
/// </summary>
Uri Endpoint { get; set; }

/// <summary>
/// Gets or sets rule for client SSL errors.
/// </summary>
bool IgnoreSslErrors { get; set; }

/// <summary>
/// Gets or sets a logger to write log messages to.
/// </summary>
Expand Down