Skip to content

Commit 1584048

Browse files
committed
Merge pull request #109 from mumou/build
HDInsight Enable RDP access after cluster create and during cluster create
2 parents 6eae685 + 33461ff commit 1584048

23 files changed

+840
-30
lines changed

ChangeLog.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
2015.05.17 version 0.8.18
2+
* Azure HDInsight:
3+
* Added support for creating WindowsPaas cluster with RDP Access Enabled by default
4+
* Added cmdlets
5+
* Grant-AzureHdinsightRdpAccess
6+
* Revoke-AzureHdinsightRdpAccess
27
* Azure Network
38
* Added Cmdlets
49
* Get-AzureVirtualNetwork

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
1313
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
1414
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" />
15-
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.12.111071459" targetFramework="net45" />
15+
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.14.201151115" targetFramework="net45" />
1616
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
1717
<package id="Microsoft.WindowsAzure.Management" version="4.0.1" targetFramework="net45" />
1818
<package id="Moq" version="4.2.1402.2112" targetFramework="net45" />

src/ServiceManagement/HDInsight/Commands.HDInsight.Test/Commands.HDInsight.Test.csproj

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<TargetFrameworkProfile />
1616
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\</SolutionDir>
1717
<RestorePackages>true</RestorePackages>
18-
<NuGetPackageImportStamp>3042119d</NuGetPackageImportStamp>
18+
<NuGetPackageImportStamp>c29245bf</NuGetPackageImportStamp>
1919
</PropertyGroup>
2020
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2121
<DebugSymbols>true</DebugSymbols>
@@ -72,10 +72,10 @@
7272
<HintPath>..\..\..\packages\Microsoft.Data.Services.Client.5.6.0\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
7373
</Reference>
7474
<Reference Include="Microsoft.Hadoop.Client">
75-
<HintPath>..\..\..\packages\Microsoft.Hadoop.Client.1.5.5\lib\net45\Microsoft.Hadoop.Client.dll</HintPath>
75+
<HintPath>..\..\..\packages\Microsoft.Hadoop.Client.1.5.6\lib\net45\Microsoft.Hadoop.Client.dll</HintPath>
7676
</Reference>
7777
<Reference Include="Microsoft.HDInsight.Net.Http.Formatting">
78-
<HintPath>..\..\..\packages\Microsoft.Hadoop.Client.1.5.5\lib\net45\Microsoft.HDInsight.Net.Http.Formatting.dll</HintPath>
78+
<HintPath>..\..\..\packages\Microsoft.Hadoop.Client.1.5.6\lib\net45\Microsoft.HDInsight.Net.Http.Formatting.dll</HintPath>
7979
</Reference>
8080
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory">
8181
<SpecificVersion>False</SpecificVersion>
@@ -103,16 +103,16 @@
103103
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
104104
</Reference>
105105
<Reference Include="Microsoft.WindowsAzure.Management.HDInsight">
106-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.HDInsight.1.5.5\lib\net45\Microsoft.WindowsAzure.Management.HDInsight.dll</HintPath>
106+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.HDInsight.1.5.6\lib\net45\Microsoft.WindowsAzure.Management.HDInsight.dll</HintPath>
107107
</Reference>
108108
<Reference Include="Microsoft.WindowsAzure.Management.HDInsight.Contracts">
109-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.HDInsight.1.5.5\lib\net45\Microsoft.WindowsAzure.Management.HDInsight.Contracts.dll</HintPath>
109+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.HDInsight.1.5.6\lib\net45\Microsoft.WindowsAzure.Management.HDInsight.Contracts.dll</HintPath>
110110
</Reference>
111111
<Reference Include="Microsoft.WindowsAzure.Management.HDInsight.Framework">
112-
<HintPath>..\..\..\packages\Microsoft.Hadoop.Client.1.5.5\lib\net45\Microsoft.WindowsAzure.Management.HDInsight.Framework.dll</HintPath>
112+
<HintPath>..\..\..\packages\Microsoft.Hadoop.Client.1.5.6\lib\net45\Microsoft.WindowsAzure.Management.HDInsight.Framework.dll</HintPath>
113113
</Reference>
114114
<Reference Include="Microsoft.WindowsAzure.Management.HDInsight.Framework.Core">
115-
<HintPath>..\..\..\packages\Microsoft.Hadoop.Client.1.5.5\lib\net45\Microsoft.WindowsAzure.Management.HDInsight.Framework.Core.dll</HintPath>
115+
<HintPath>..\..\..\packages\Microsoft.Hadoop.Client.1.5.6\lib\net45\Microsoft.WindowsAzure.Management.HDInsight.Framework.Core.dll</HintPath>
116116
</Reference>
117117
<Reference Include="Microsoft.WindowsAzure.Storage, Version=3.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
118118
<HintPath>..\..\..\packages\WindowsAzure.Storage.3.0.3.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
@@ -149,6 +149,14 @@
149149
<Reference Include="Microsoft.CSharp" />
150150
<Reference Include="System.Data" />
151151
<Reference Include="System.Xml" />
152+
<Reference Include="xunit, Version=1.9.2.1705, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
153+
<SpecificVersion>False</SpecificVersion>
154+
<HintPath>..\..\..\packages\xunit.1.9.2\lib\net20\xunit.dll</HintPath>
155+
</Reference>
156+
<Reference Include="xunit.extensions, Version=1.9.2.1705, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
157+
<SpecificVersion>False</SpecificVersion>
158+
<HintPath>..\..\..\packages\xunit.extensions.1.9.2\lib\net20\xunit.extensions.dll</HintPath>
159+
</Reference>
152160
</ItemGroup>
153161
<ItemGroup>
154162
<Compile Include="HDInsight\CmdLetTests\AddConfigValuesCmdletTests.cs" />
@@ -163,6 +171,7 @@
163171
<Compile Include="HDInsight\CmdLetTests\GetJobOutputCmdletTests.cs" />
164172
<Compile Include="HDInsight\CmdLetTests\GetJobsCmdletTests.cs" />
165173
<Compile Include="HDInsight\CmdLetTests\GetPropertiesCmdletTests.cs" />
174+
<Compile Include="HDInsight\CmdLetTests\GrantRdpAccessCmdletTests.cs" />
166175
<Compile Include="HDInsight\CmdLetTests\GrantHttpAccessCmdletTests.cs" />
167176
<Compile Include="HDInsight\CmdLetTests\HDInsightTestCaseBase.cs" />
168177
<Compile Include="HDInsight\CmdLetTests\InvokeHiveCmdletTests.cs" />
@@ -187,6 +196,7 @@
187196
<Compile Include="HDInsight\CommandTests\HDInsightGetJobsCommandTests.cs" />
188197
<Compile Include="HDInsight\CommandTests\HDInsightGetPropertiesCommandTests.cs" />
189198
<Compile Include="HDInsight\CommandTests\InvokeHiveCommandTests.cs" />
199+
<Compile Include="HDInsight\CommandTests\ManageAzureHDInsightRdpAccessCommandTests.cs" />
190200
<Compile Include="HDInsight\CommandTests\ManageAzureHDInsightHttpAccessCommandTests.cs" />
191201
<Compile Include="HDInsight\CommandTests\NewHDInsightMapReduceJobCommandTests.cs" />
192202
<Compile Include="HDInsight\CommandTests\NewHDInsightPigJobCommandTests.cs" />

src/ServiceManagement/HDInsight/Commands.HDInsight.Test/HDInsight/CmdLetTests/CmdletHardCodes.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public static class CmdletConstants
2828
public const string Combiner = "Combiner";
2929
public const string CoreConfig = "Core";
3030
public const string Credential = "Credential";
31+
public const string RdpCredential = "RdpCredential";
32+
public const string RdpAccessExpiry = "RdpAccessExpiry";
3133
public const string DatabaseName = "DatabaseName";
3234
public const string Debug = "Debug";
3335
public const string DefaultStorageContainerName = "DefaultStorageContainerName";
@@ -39,6 +41,7 @@ public static class CmdletConstants
3941
public const string GetAzureHDInsightJobOutput = "Get-AzureHDInsightJobOutput";
4042
public const string GetAzureHDInsightProperties = "Get-AzureHDInsightProperties";
4143
public const string GrantAzureHDInsightHttpAccess = "Grant-AzureHDInsightHttpServicesAccess";
44+
public const string GrantAzureHDInsightRdpAccess = "Grant-AzureHDInsightRdpAccess";
4245
public const string HdfsConfig = "Hdfs";
4346
public const string HiveArgs = "Arguments";
4447
public const string HiveConfig = "Hive";
@@ -78,6 +81,7 @@ public static class CmdletConstants
7881
public const string Reducer = "Reducer";
7982
public const string RemoveAzureHDInsightCluster = "Remove-AzureHDInsightCluster";
8083
public const string RevokeAzureHDInsightHttpAccess = "Revoke-AzureHDInsightHttpServicesAccess";
84+
public const string RevokeAzureHDInsightRdpAccess = "Revoke-AzureHDInsightRdpAccess";
8185
public const string SetAzureHDInsightClusterSize = "Set-AzureHDInsightClusterSize";
8286
public const string SetAzureHDInsightDefaultStorage = "Set-AzureHDInsightDefaultStorage";
8387
public const string Show = "Show";
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using System.Collections.Generic;
17+
using System.Linq;
18+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
19+
using Xunit;
20+
using Microsoft.WindowsAzure.Commands.Test.Utilities.HDInsight.PowerShellTestAbstraction.Interfaces;
21+
using Microsoft.WindowsAzure.Commands.Test.Utilities.HDInsight.Utilities;
22+
using Microsoft.WindowsAzure.Management.HDInsight;
23+
using Microsoft.WindowsAzure.Management.HDInsight.Cmdlet.DataObjects;
24+
using Microsoft.WindowsAzure.Management.HDInsight.Cmdlet.GetAzureHDInsightClusters.Extensions;
25+
26+
namespace Microsoft.WindowsAzure.Commands.Test.HDInsight.CmdLetTests
27+
{
28+
public class GrantRdpAccessCmdletTests : HDInsightTestCaseBase, IDisposable
29+
{
30+
public new void Dispose()
31+
{
32+
base.TestCleanup();
33+
}
34+
35+
[Fact]
36+
[Trait(Category.AcceptanceType, Category.CheckIn)]
37+
public void CanGrantRdpAccessToHDInsightCluster()
38+
{
39+
IHDInsightCertificateCredential creds = GetValidCredentials();
40+
using (IRunspace runspace = this.GetPowerShellRunspace())
41+
{
42+
AzureHDInsightCluster cluster = GetClusterWithRdpAccessDisabled(runspace);
43+
IPipelineResult results =
44+
runspace.NewPipeline()
45+
.AddCommand(CmdletConstants.GrantAzureHDInsightRdpAccess)
46+
.WithParameter(CmdletConstants.Location, cluster.Location)
47+
.WithParameter(CmdletConstants.Name, cluster.Name)
48+
.WithParameter(CmdletConstants.RdpCredential, GetAzurePsCredentials())
49+
.WithParameter(CmdletConstants.RdpAccessExpiry, DateTime.UtcNow.AddDays(6))
50+
.Invoke();
51+
52+
AzureHDInsightCluster accessgrantedCluster = GetCluster(creds, cluster.Name, runspace);
53+
Assert.NotNull(accessgrantedCluster);
54+
Assert.Equal(accessgrantedCluster.RdpUserName, TestCredentials.AzureUserName);
55+
}
56+
}
57+
58+
public GrantRdpAccessCmdletTests()
59+
{
60+
base.Initialize();
61+
}
62+
63+
internal static AzureHDInsightCluster GetClusterWithRdpAccessDisabled(IRunspace runspace)
64+
{
65+
IHDInsightCertificateCredential creds = GetValidCredentials();
66+
IPipelineResult results =
67+
runspace.NewPipeline()
68+
.AddCommand(CmdletConstants.GetAzureHDInsightCluster)
69+
.Invoke();
70+
71+
List<AzureHDInsightCluster> testClusters = results.Results.ToEnumerable<AzureHDInsightCluster>().ToList();
72+
AzureHDInsightCluster testCluster = testClusters.FirstOrDefault(cluster => cluster.RdpUserName.IsNullOrEmpty());
73+
if (testCluster == null)
74+
{
75+
testCluster = testClusters.Last();
76+
RevokeRdpAccessToCluster(creds, testCluster, runspace);
77+
}
78+
79+
return testCluster;
80+
}
81+
82+
internal static void RevokeRdpAccessToCluster(
83+
IHDInsightCertificateCredential connectionCredentials, AzureHDInsightCluster cluster, IRunspace runspace)
84+
{
85+
IPipelineResult results =
86+
runspace.NewPipeline()
87+
.AddCommand(CmdletConstants.RevokeAzureHDInsightRdpAccess)
88+
.WithParameter(CmdletConstants.Location, cluster.Location)
89+
.WithParameter(CmdletConstants.Name, cluster.Name)
90+
.Invoke();
91+
92+
AzureHDInsightCluster accessRevokedCluster = GetCluster(connectionCredentials, cluster.Name, runspace);
93+
Assert.NotNull(accessRevokedCluster);
94+
Assert.True(string.IsNullOrEmpty(accessRevokedCluster.RdpUserName));
95+
}
96+
97+
internal static AzureHDInsightCluster GetCluster(
98+
IHDInsightCertificateCredential connectionCredentials, string clusterName, IRunspace runspace)
99+
{
100+
IPipelineResult results =
101+
runspace.NewPipeline()
102+
.AddCommand(CmdletConstants.GetAzureHDInsightCluster)
103+
.WithParameter(CmdletConstants.Name, clusterName)
104+
.Invoke();
105+
106+
List<AzureHDInsightCluster> clusters = results.Results.ToEnumerable<AzureHDInsightCluster>().ToList();
107+
return clusters.FirstOrDefault();
108+
}
109+
}
110+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using System.Collections.Generic;
17+
using System.Linq;
18+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
19+
using Xunit;
20+
using Microsoft.WindowsAzure.Commands.Test.HDInsight.CmdLetTests;
21+
using Microsoft.WindowsAzure.Management.HDInsight;
22+
using Microsoft.WindowsAzure.Management.HDInsight.Cmdlet.Commands.CommandInterfaces;
23+
using Microsoft.WindowsAzure.Management.HDInsight.Cmdlet.DataObjects;
24+
using Microsoft.WindowsAzure.Management.HDInsight.Cmdlet.GetAzureHDInsightClusters;
25+
using Microsoft.WindowsAzure.Management.HDInsight.Cmdlet.GetAzureHDInsightClusters.Extensions;
26+
using Microsoft.WindowsAzure.Management.HDInsight.Cmdlet.ServiceLocation;
27+
28+
namespace Microsoft.WindowsAzure.Commands.Test.HDInsight.CommandTests
29+
{
30+
public class ManageAzureHDInsightRdpAccessCommandTests : HDInsightTestCaseBase, IDisposable
31+
{
32+
public void Dispose()
33+
{
34+
base.TestCleanup();
35+
}
36+
37+
[Fact]
38+
[Trait(Category.AcceptanceType, Category.CheckIn)]
39+
public void CanGrantHDInsightRdpAccess()
40+
{
41+
var rdpUserName = "rdpuser";
42+
IHDInsightCertificateCredential creds = GetValidCredentials();
43+
AzureHDInsightCluster testCluster = GetClusterWithRdpAccessDisabled(creds);
44+
AzureHDInsightCluster cluster = EnableRdpAccessToCluster(
45+
creds, testCluster, rdpUserName, TestCredentials.AzurePassword, DateTime.UtcNow.AddDays(6));
46+
Assert.NotNull(cluster);
47+
Assert.Equal(cluster.RdpUserName, rdpUserName);
48+
}
49+
50+
[Fact]
51+
[Trait(Category.AcceptanceType, Category.CheckIn)]
52+
public void CanRevokeAccessToRdpServices()
53+
{
54+
IHDInsightCertificateCredential creds = GetValidCredentials();
55+
AzureHDInsightCluster testCluster = GetClusterWithRdpAccessDisabled(creds);
56+
EnableRdpAccessToCluster(creds, testCluster, TestCredentials.AzureUserName, TestCredentials.AzurePassword,
57+
DateTime.UtcNow.AddDays(6));
58+
AzureHDInsightCluster cluster = DisableRdpAccessToCluster(creds, testCluster);
59+
Assert.NotNull(cluster);
60+
Assert.True(string.IsNullOrEmpty(cluster.RdpUserName));
61+
}
62+
63+
public ManageAzureHDInsightRdpAccessCommandTests()
64+
{
65+
base.Initialize();
66+
}
67+
68+
private static AzureHDInsightCluster GetClusterWithRdpAccessDisabled(IHDInsightCertificateCredential creds)
69+
{
70+
IGetAzureHDInsightClusterCommand client = ServiceLocator.Instance.Locate<IAzureHDInsightCommandFactory>().CreateGet();
71+
client.CurrentSubscription = GetCurrentSubscription();
72+
client.EndProcessing();
73+
List<AzureHDInsightCluster> clusters = client.Output.ToList();
74+
AzureHDInsightCluster containerWithRdpAccessDisabled = clusters.FirstOrDefault(cluster => cluster.RdpUserName.IsNullOrEmpty());
75+
if (containerWithRdpAccessDisabled == null)
76+
{
77+
containerWithRdpAccessDisabled = clusters.Last();
78+
DisableRdpAccessToCluster(creds, containerWithRdpAccessDisabled);
79+
}
80+
81+
return containerWithRdpAccessDisabled;
82+
}
83+
84+
private static AzureHDInsightCluster DisableRdpAccessToCluster(
85+
IHDInsightCertificateCredential creds, AzureHDInsightCluster containerWithRdpAccessDisabled)
86+
{
87+
IManageAzureHDInsightRdpAccessCommand rdpManagementClient =
88+
ServiceLocator.Instance.Locate<IAzureHDInsightCommandFactory>().CreateManageRdpAccess();
89+
rdpManagementClient.CurrentSubscription = GetCurrentSubscription();
90+
rdpManagementClient.RdpCredential = GetAzurePsCredentials();
91+
rdpManagementClient.Name = containerWithRdpAccessDisabled.Name;
92+
rdpManagementClient.Location = containerWithRdpAccessDisabled.Location;
93+
rdpManagementClient.Enable = false;
94+
rdpManagementClient.EndProcessing();
95+
return rdpManagementClient.Output.First();
96+
}
97+
98+
private static AzureHDInsightCluster EnableRdpAccessToCluster(
99+
IHDInsightCertificateCredential creds, AzureHDInsightCluster containerWithRdpAccessDisabled, string rdpUserName, string rdpPassword, DateTime expiry)
100+
{
101+
IManageAzureHDInsightRdpAccessCommand rdpManagementClient =
102+
ServiceLocator.Instance.Locate<IAzureHDInsightCommandFactory>().CreateManageRdpAccess();
103+
rdpManagementClient.CurrentSubscription = GetCurrentSubscription();
104+
rdpManagementClient.RdpCredential = GetPSCredential(rdpUserName, rdpPassword);
105+
rdpManagementClient.Name = containerWithRdpAccessDisabled.Name;
106+
rdpManagementClient.Location = containerWithRdpAccessDisabled.Location;
107+
rdpManagementClient.RdpAccessExpiry = expiry;
108+
rdpManagementClient.Enable = true;
109+
110+
rdpManagementClient.EndProcessing();
111+
return rdpManagementClient.Output.First();
112+
}
113+
}
114+
}

0 commit comments

Comments
 (0)