Skip to content

Commit add2821

Browse files
committed
First commit
1 parent f0b5063 commit add2821

File tree

10 files changed

+210
-19
lines changed

10 files changed

+210
-19
lines changed

src/ResourceManager/HDInsight/Commands.HDInsight.Test/Commands.HDInsight.Test.csproj

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@
3838
<Reference Include="Microsoft.Azure.Common">
3939
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.dll</HintPath>
4040
</Reference>
41-
<Reference Include="Microsoft.Azure.Common.Authentication">
42-
<HintPath>..\..\..\packages\Microsoft.Azure.Common.Authentication.1.0.26-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll</HintPath>
41+
<Reference Include="Microsoft.Azure.Common.Authentication, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
42+
<HintPath>..\..\..\packages\Microsoft.Azure.Common.Authentication.1.1.5-preview\lib\net45\Microsoft.Azure.Common.Authentication.dll</HintPath>
43+
<Private>True</Private>
4344
</Reference>
4445
<Reference Include="Microsoft.Azure.Common.NetFramework">
4546
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
@@ -62,17 +63,28 @@
6263
<Reference Include="Microsoft.Azure.ResourceManager">
6364
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.0-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
6465
</Reference>
65-
<Reference Include="Microsoft.Azure.Test.Framework">
66-
<HintPath>..\..\..\packages\Microsoft.Azure.Test.Framework.1.0.5571.32271-prerelease\lib\net45\Microsoft.Azure.Test.Framework.dll</HintPath>
66+
<Reference Include="Microsoft.Azure.Test.Framework, Version=1.0.5687.28567, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
67+
<HintPath>..\..\..\packages\Microsoft.Azure.Test.Framework.1.0.5687.28567-prerelease\lib\net45\Microsoft.Azure.Test.Framework.dll</HintPath>
68+
<Private>True</Private>
6769
</Reference>
6870
<Reference Include="Microsoft.Azure.Test.HttpRecorder">
6971
<HintPath>..\..\..\packages\Microsoft.Azure.Test.HttpRecorder.1.0.5513.27084-prerelease\lib\net45\Microsoft.Azure.Test.HttpRecorder.dll</HintPath>
7072
</Reference>
71-
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory">
72-
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.14.201151115\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
73+
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=2.18.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
74+
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.18.206251556\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
75+
<Private>True</Private>
7376
</Reference>
74-
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms">
75-
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.14.201151115\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
77+
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms, Version=2.18.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
78+
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.18.206251556\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
79+
<Private>True</Private>
80+
</Reference>
81+
<Reference Include="Microsoft.Rest.ClientRuntime, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
82+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.1.2.0\lib\net45\Microsoft.Rest.ClientRuntime.dll</HintPath>
83+
<Private>True</Private>
84+
</Reference>
85+
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication, Version=0.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
86+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.Authentication.0.9.3\lib\net45\Microsoft.Rest.ClientRuntime.Azure.Authentication.dll</HintPath>
87+
<Private>True</Private>
7688
</Reference>
7789
<Reference Include="Microsoft.Threading.Tasks">
7890
<HintPath>..\..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>

src/ResourceManager/HDInsight/Commands.HDInsight.Test/packages.config

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@
22
<packages>
33
<package id="Hyak.Common" version="1.0.2" targetFramework="net45" />
44
<package id="Microsoft.Azure.Common" version="2.1.0" targetFramework="net45" />
5-
<package id="Microsoft.Azure.Common.Authentication" version="1.0.26-preview" targetFramework="net45" />
5+
<package id="Microsoft.Azure.Common.Authentication" version="1.1.5-preview" targetFramework="net45" />
66
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
77
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
88
<package id="Microsoft.Azure.Management.Authorization" version="0.18.2-preview" targetFramework="net45" />
99
<package id="Microsoft.Azure.Management.HDInsight" version="1.0.1-preview" targetFramework="net45" />
1010
<package id="Microsoft.Azure.Management.HDInsight.Job" version="1.0.1-preview" targetFramework="net45" />
1111
<package id="Microsoft.Azure.Management.Resources" version="2.18.0-preview" targetFramework="net45" />
1212
<package id="Microsoft.Azure.Management.Storage" version="2.4.0-preview" targetFramework="net45" />
13-
<package id="Microsoft.Azure.Test.Framework" version="1.0.5571.32271-prerelease" targetFramework="net45" />
13+
<package id="Microsoft.Azure.Test.Framework" version="1.0.5687.28567-prerelease" targetFramework="net45" />
1414
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.0.5513.27084-prerelease" targetFramework="net45" />
1515
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
1616
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
1717
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" />
18-
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.14.201151115" targetFramework="net45" />
18+
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.18.206251556" targetFramework="net45" />
1919
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
20+
<package id="Microsoft.Rest.ClientRuntime" version="1.2.0" targetFramework="net45" />
21+
<package id="Microsoft.Rest.ClientRuntime.Azure.Authentication" version="0.9.3" targetFramework="net45" />
2022
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
2123
<package id="xunit" version="1.9.2" targetFramework="net45" />
2224
<package id="xunit.extensions" version="1.9.2" targetFramework="net45" />
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
//
2+
// Copyright Microsoft Corporation
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
// ----------------------------------------------------------------------------------
13+
14+
using System;
15+
using System.Collections.Generic;
16+
using System.Linq;
17+
18+
namespace Microsoft.Azure.Commands.HDInsight.Models
19+
{
20+
internal class ClusterConfigurationUtils
21+
{
22+
public static string GetResourceGroupFromClusterId(string clusterId)
23+
{
24+
string clusterGroup = null;
25+
int index = clusterId.IndexOf("resourceGroups", StringComparison.OrdinalIgnoreCase);
26+
27+
if (index >= 0)
28+
{
29+
index += "resourceGroups".Length;
30+
string[] parts = clusterId.Substring(index).Split(new [] { '/' }, StringSplitOptions.RemoveEmptyEntries);
31+
32+
if (parts.Length > 0)
33+
{
34+
clusterGroup = parts[0];
35+
}
36+
}
37+
38+
return clusterGroup;
39+
}
40+
41+
public static AzureHDInsightDefaultStorageAccount GetDefaultStorageAccountDetails(
42+
IDictionary<string, string> configuration,
43+
string version)
44+
{
45+
string key = Constants.ClusterConfiguration.DefaultStorageAccountNameKey;
46+
47+
if (version.Equals("2.1"))
48+
{
49+
key = Constants.ClusterConfiguration.DefaultStorageAccountNameKeyOld;
50+
}
51+
52+
string accountAndContainerStr;
53+
54+
if (configuration.TryGetValue(key, out accountAndContainerStr))
55+
{
56+
string[] accountAndContainer = accountAndContainerStr.Substring("wasb://".Length).Split('@');
57+
58+
return new AzureHDInsightDefaultStorageAccount
59+
{
60+
StorageContainerName = accountAndContainer[0],
61+
StorageAccountName = accountAndContainer[1],
62+
StorageAccountKey = configuration[Constants.ClusterConfiguration.StorageAccountKeyPrefix + accountAndContainer[1]]
63+
};
64+
}
65+
66+
return null;
67+
}
68+
69+
public static List<string> GetAdditionStorageAccounts(IDictionary<string, string> configuration, string defaultAccount)
70+
{
71+
return (from key in configuration.Keys
72+
where key.StartsWith(Constants.ClusterConfiguration.StorageAccountKeyPrefix) &&
73+
!key.EndsWith(defaultAccount)
74+
select key.Remove(0, Constants.ClusterConfiguration.StorageAccountKeyPrefix.Length)).ToList();
75+
}
76+
}
77+
}

src/ResourceManager/HDInsight/Commands.HDInsight/Commands.HDInsight.csproj

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,22 @@
7575
<Compile Include="Models\Management\AzureHDInsightCluster.cs" />
7676
<Compile Include="Models\Management\AzureHDInsightConfig.cs" />
7777
<Compile Include="Models\Job\AzureHdInsightJobManagementClient.cs" />
78+
<Compile Include="Models\Management\AzureHDInsightDefaultStorageAccount.cs" />
7879
<Compile Include="Models\Management\AzureHdInsightManagementClient.cs" />
7980
<Compile Include="Models\Management\AzureHDInsightMetastoreType.cs" />
8081
<Compile Include="Models\Management\AzureHDInsightMetastore.cs" />
8182
<Compile Include="ManagementCommands\NewAzureHDInsightClusterCommand.cs" />
83+
<Compile Include="ClusterConfigurationUtils.cs" />
8284
<Compile Include="Properties\AssemblyInfo.cs" />
8385
</ItemGroup>
8486
<ItemGroup>
8587
<None Include="Microsoft.Azure.Commands.HDInsight.dll-help.psd1">
8688
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
8789
</None>
8890
<None Include="MSSharedLibKey.snk" />
89-
<None Include="packages.config" />
91+
<None Include="packages.config">
92+
<SubType>Designer</SubType>
93+
</None>
9094
</ItemGroup>
9195
<ItemGroup>
9296
<Reference Include="Hyak.Common">
@@ -101,11 +105,13 @@
101105
<Reference Include="Microsoft.Azure.Common.NetFramework">
102106
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
103107
</Reference>
104-
<Reference Include="Microsoft.Azure.Management.HDInsight">
105-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.HDInsight.1.0.1-preview\lib\net40\Microsoft.Azure.Management.HDInsight.dll</HintPath>
108+
<Reference Include="Microsoft.Azure.Management.HDInsight, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
109+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.HDInsight.1.0.5-preview\lib\net40\Microsoft.Azure.Management.HDInsight.dll</HintPath>
110+
<Private>True</Private>
106111
</Reference>
107-
<Reference Include="Microsoft.Azure.Management.HDInsight.Job">
108-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.HDInsight.Job.1.0.1-preview\lib\net40\Microsoft.Azure.Management.HDInsight.Job.dll</HintPath>
112+
<Reference Include="Microsoft.Azure.Management.HDInsight.Job, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
113+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.HDInsight.Job.1.0.5-preview\lib\net40\Microsoft.Azure.Management.HDInsight.Job.dll</HintPath>
114+
<Private>True</Private>
109115
</Reference>
110116
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
111117
<SpecificVersion>False</SpecificVersion>

src/ResourceManager/HDInsight/Commands.HDInsight/Constants.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,12 @@ public static class JobDefinitions
4040
public const string AzureHDInsightMapReduceJobDefinition = "AzureHDInsightMapReduceJobDefinition";
4141
public const string AzureHDInsightStreamingMapReduceJobDefinition = "AzureHDInsightStreamingMapReduceJobDefinition";
4242
}
43+
44+
public static class ClusterConfiguration
45+
{
46+
public const string DefaultStorageAccountNameKey = "fs.defaultFS";
47+
public const string DefaultStorageAccountNameKeyOld = "fs.default.name";
48+
public const string StorageAccountKeyPrefix = "fs.azure.account.key.";
49+
}
4350
}
4451
}

src/ResourceManager/HDInsight/Commands.HDInsight/ManagementCommands/GetAzureHDInsightClusterCommand.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using System;
1516
using System.Collections.Generic;
1617
using System.Linq;
1718
using System.Management.Automation;
@@ -44,7 +45,13 @@ public class GetAzureHDInsightCommand : HDInsightCmdletBase
4445
public override void ExecuteCmdlet()
4546
{
4647
var result = HDInsightManagementClient.GetCluster(ResourceGroupName, ClusterName);
47-
var output = result.Select(cluster => new AzureHDInsightCluster(cluster)).ToList();
48+
49+
var output = result.Select(entry =>
50+
{
51+
var configuration = HDInsightManagementClient.GetClusterConfigurations(entry, "core-site");
52+
return new AzureHDInsightCluster(entry, configuration);
53+
}).ToList();
54+
4855
WriteObject(output, true);
4956
}
5057
}

src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHDInsightCluster.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using System;
16+
using System.Collections.Generic;
1617
using System.Linq;
1718
using Microsoft.Azure.Management.HDInsight.Models;
1819

@@ -34,6 +35,25 @@ public AzureHDInsightCluster(Cluster cluster)
3435
cluster.Properties.ConnectivityEndpoints.FirstOrDefault(c => c.Name.Equals("HTTPS", StringComparison.OrdinalIgnoreCase));
3536
HttpEndpoint = httpEndpoint != null ? httpEndpoint.Location : null;
3637

38+
ResourceGroup = ClusterConfigurationUtils.GetResourceGroupFromClusterId(cluster.Id);
39+
40+
}
41+
42+
public AzureHDInsightCluster(Cluster cluster, IDictionary<string, string> clusterConfiguration)
43+
: this(cluster)
44+
{
45+
if (clusterConfiguration != null)
46+
{
47+
var defaultAccount = ClusterConfigurationUtils.GetDefaultStorageAccountDetails(
48+
clusterConfiguration,
49+
cluster.Properties.ClusterVersion);
50+
51+
DefaultStorageAccount = defaultAccount.StorageAccountName;
52+
DefaultStorageContainer = defaultAccount.StorageContainerName;
53+
54+
AdditionalStorageAccounts = ClusterConfigurationUtils.GetAdditionStorageAccounts(clusterConfiguration, DefaultStorageAccount);
55+
}
56+
3757
}
3858

3959
/// <summary>
@@ -80,5 +100,25 @@ public AzureHDInsightCluster(Cluster cluster)
80100
/// The endpoint with which to connect to the cluster.
81101
/// </summary>
82102
public string HttpEndpoint { get; set; }
103+
104+
/// <summary>
105+
/// Default storage account for this cluster.
106+
/// </summary>
107+
public string DefaultStorageAccount { get; set; }
108+
109+
/// <summary>
110+
/// Default storage container for this cluster.
111+
/// </summary>
112+
public string DefaultStorageContainer { get; set; }
113+
114+
/// <summary>
115+
/// Default storage container for this cluster.
116+
/// </summary>
117+
public string ResourceGroup { get; set; }
118+
119+
/// <summary>
120+
/// Additional storage accounts for this cluster
121+
/// </summary>
122+
public List<string> AdditionalStorageAccounts { get; set; }
83123
}
84124
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// Copyright Microsoft Corporation
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
// ----------------------------------------------------------------------------------
13+
14+
namespace Microsoft.Azure.Commands.HDInsight.Models
15+
{
16+
public class AzureHDInsightDefaultStorageAccount
17+
{
18+
public string StorageAccountName { get; set; }
19+
20+
public string StorageAccountKey { get; set; }
21+
22+
public string StorageContainerName { get; set; }
23+
}
24+
}

src/ResourceManager/HDInsight/Commands.HDInsight/Models/Management/AzureHdInsightManagementClient.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,21 @@ public virtual CapabilitiesResponse GetCapabilities(string location)
109109
{
110110
return HdInsightManagementClient.Clusters.GetCapabilities(location);
111111
}
112+
113+
public virtual IDictionary<string, string> GetClusterConfigurations(Cluster cluster, string configurationName)
114+
{
115+
Dictionary<string, string> properties = new Dictionary<string, string>();
116+
117+
if(string.IsNullOrWhiteSpace(configurationName))
118+
{
119+
return properties;
120+
}
121+
122+
string resourceGroupName = ClusterConfigurationUtils.GetResourceGroupFromClusterId(cluster.Id);
123+
return HdInsightManagementClient.Clusters.GetClusterConfigurations(
124+
resourceGroupName,
125+
cluster.Name,
126+
configurationName).Configuration;
127+
}
112128
}
113129
}

src/ResourceManager/HDInsight/Commands.HDInsight/packages.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<package id="Microsoft.Azure.Common" version="2.1.0" targetFramework="net45" />
55
<package id="Microsoft.Azure.Common.Authentication" version="1.1.3-preview" targetFramework="net45" />
66
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
7-
<package id="Microsoft.Azure.Management.HDInsight" version="1.0.1-preview" targetFramework="net45" />
8-
<package id="Microsoft.Azure.Management.HDInsight.Job" version="1.0.1-preview" targetFramework="net45" />
7+
<package id="Microsoft.Azure.Management.HDInsight" version="1.0.5-preview" targetFramework="net45" />
8+
<package id="Microsoft.Azure.Management.HDInsight.Job" version="1.0.5-preview" targetFramework="net45" />
99
<package id="Microsoft.Azure.Management.Resources" version="2.18.7-preview" targetFramework="net45" />
1010
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.0.5687.28567-prerelease" targetFramework="net45" />
1111
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />

0 commit comments

Comments
 (0)