11
11
// limitations under the License.
12
12
// ----------------------------------------------------------------------------------
13
13
14
- using Microsoft . Azure . Commands . HDInsight . Models . Management ;
15
14
using Microsoft . Azure . Management . HDInsight . Models ;
16
15
using Microsoft . WindowsAzure . Commands . Common ;
17
16
using System ;
@@ -25,7 +24,7 @@ public static class ClusterCreateHelper
25
24
{
26
25
public static void AddClusterCredentialToGatewayConfig ( PSCredential httpCredential , IDictionary < string , Dictionary < string , string > > configurations )
27
26
{
28
- Dictionary < string , string > gatewayConfig = GetExistingConfigurationsForType ( configurations , ConfigurationKey . Gateway ) ;
27
+ Dictionary < string , string > gatewayConfig = GetExistingConfigurationsForType ( configurations , Constants . ConfigurationKey . Gateway ) ;
29
28
if ( ! string . IsNullOrEmpty ( httpCredential ? . UserName ) )
30
29
{
31
30
gatewayConfig [ Constants . GatewayConfigurations . CredentialIsEnabledKey ] = "true" ;
@@ -37,7 +36,7 @@ public static void AddClusterCredentialToGatewayConfig(PSCredential httpCredenti
37
36
gatewayConfig [ Constants . GatewayConfigurations . CredentialIsEnabledKey ] = "false" ;
38
37
}
39
38
40
- configurations [ ConfigurationKey . Gateway ] = gatewayConfig ;
39
+ configurations [ Constants . ConfigurationKey . Gateway ] = gatewayConfig ;
41
40
}
42
41
43
42
public static void AddAzureDataLakeStorageGen1ToCoreConfig ( string storageResourceId , string storageRootPath , string defaultAzureDataLakeStoreFileSystemEndpointSuffix , IDictionary < string , Dictionary < string , string > > configurations )
@@ -56,28 +55,28 @@ public static void AddAzureDataLakeStorageGen1ToCoreConfig(string storageResourc
56
55
}
57
56
58
57
// Get existing core configs.
59
- Dictionary < string , string > coreConfig = GetExistingConfigurationsForType ( configurations , ConfigurationKey . CoreSite ) ;
58
+ Dictionary < string , string > coreConfig = GetExistingConfigurationsForType ( configurations , Constants . ConfigurationKey . CoreSite ) ;
60
59
61
60
// Add configurations for default ADL storage.
62
61
coreConfig [ Constants . StorageConfigurations . DefaultFsKey ] = Constants . StorageConfigurations . DefaultFsAdlValue ;
63
62
coreConfig [ Constants . StorageConfigurations . AdlHostNameKey ] = storageAccountName ;
64
63
coreConfig [ Constants . StorageConfigurations . AdlMountPointKey ] = storageRootPath ;
65
64
66
- configurations [ ConfigurationKey . CoreSite ] = coreConfig ;
65
+ configurations [ Constants . ConfigurationKey . CoreSite ] = coreConfig ;
67
66
}
68
67
69
68
public static void AddAdditionalStorageAccountsToCoreConfig ( Dictionary < string , string > additionalStorageAccounts , IDictionary < string , Dictionary < string , string > > configurations )
70
69
{
71
70
// Get existing core configs.
72
- Dictionary < string , string > coreConfig = GetExistingConfigurationsForType ( configurations , ConfigurationKey . CoreSite ) ;
71
+ Dictionary < string , string > coreConfig = GetExistingConfigurationsForType ( configurations , Constants . ConfigurationKey . CoreSite ) ;
73
72
74
73
foreach ( KeyValuePair < string , string > storageAccount in additionalStorageAccounts )
75
74
{
76
75
string configKey = string . Format ( Constants . StorageConfigurations . WasbStorageAccountKeyFormat , storageAccount . Key ) ;
77
76
coreConfig [ configKey ] = storageAccount . Value ;
78
77
}
79
78
80
- configurations [ ConfigurationKey . CoreSite ] = coreConfig ;
79
+ configurations [ Constants . ConfigurationKey . CoreSite ] = coreConfig ;
81
80
}
82
81
83
82
public static void AddDataLakeStorageGen1IdentityToIdentityConfig ( Guid applicationId , Guid aadTenantId , byte [ ] certificateFileBytes , string certificatePassword ,
@@ -95,7 +94,7 @@ public static void AddDataLakeStorageGen1IdentityToIdentityConfig(Guid applicati
95
94
{ Constants . DataLakeConfigurations . ResourceUriKey , dataLakeEndpointResourceId }
96
95
} ;
97
96
98
- configurations [ ConfigurationKey . ClusterIdentity ] = datalakeConfig ;
97
+ configurations [ Constants . ConfigurationKey . ClusterIdentity ] = datalakeConfig ;
99
98
}
100
99
101
100
public static StorageAccount CreateAzureStorageAccount ( string clusterName , string storageResourceId , string storageAccountkey , string storageContainer , string defaultStorageSuffix )
@@ -142,15 +141,15 @@ public static void AddHiveMetastoreToConfigurations(AzureHDInsightMetastore hive
142
141
string connectionUrl =
143
142
string . Format ( Constants . MetastoreConfigurations . ConnectionUrlFormat , hiveMetastore . SqlAzureServerName , hiveMetastore . DatabaseName ) ;
144
143
145
- configurations . AddOrCombineConfigurations ( ConfigurationKey . HiveSite , new Dictionary < string , string >
144
+ configurations . AddOrCombineConfigurations ( Constants . ConfigurationKey . HiveSite , new Dictionary < string , string >
146
145
{
147
146
{ Constants . MetastoreConfigurations . HiveSite . ConnectionUrlKey , connectionUrl } ,
148
147
{ Constants . MetastoreConfigurations . HiveSite . ConnectionUserNameKey , hiveMetastore . Credential . UserName } ,
149
148
{ Constants . MetastoreConfigurations . HiveSite . ConnectionPasswordKey , hiveMetastore . Credential . Password . ConvertToString ( ) } ,
150
149
{ Constants . MetastoreConfigurations . HiveSite . ConnectionDriverNameKey , Constants . MetastoreConfigurations . HiveSite . ConnectionDriverNameValue }
151
150
} ) ;
152
151
153
- configurations . AddOrCombineConfigurations ( ConfigurationKey . HiveEnv , new Dictionary < string , string >
152
+ configurations . AddOrCombineConfigurations ( Constants . ConfigurationKey . HiveEnv , new Dictionary < string , string >
154
153
{
155
154
{ Constants . MetastoreConfigurations . HiveEnv . DatabaseKey , Constants . MetastoreConfigurations . DatabaseValue } ,
156
155
{ Constants . MetastoreConfigurations . HiveEnv . DatabaseNameKey , hiveMetastore . DatabaseName } ,
@@ -169,7 +168,7 @@ public static void AddOozieMetastoreToConfigurations(AzureHDInsightMetastore ooz
169
168
}
170
169
string connectionUrl = string . Format ( Constants . MetastoreConfigurations . ConnectionUrlFormat , oozieMetastore . SqlAzureServerName , oozieMetastore . DatabaseName ) ;
171
170
172
- configurations . AddOrCombineConfigurations ( ConfigurationKey . OozieSite , new Dictionary < string , string >
171
+ configurations . AddOrCombineConfigurations ( Constants . ConfigurationKey . OozieSite , new Dictionary < string , string >
173
172
{
174
173
{ Constants . MetastoreConfigurations . OozieSite . UrlKey , connectionUrl } ,
175
174
{ Constants . MetastoreConfigurations . OozieSite . UserNameKey , oozieMetastore . Credential . UserName } ,
@@ -178,7 +177,7 @@ public static void AddOozieMetastoreToConfigurations(AzureHDInsightMetastore ooz
178
177
{ Constants . MetastoreConfigurations . OozieSite . SchemaKey , Constants . MetastoreConfigurations . OozieSite . SchemaValue }
179
178
} ) ;
180
179
181
- configurations . AddOrCombineConfigurations ( ConfigurationKey . OozieEnv , new Dictionary < string , string >
180
+ configurations . AddOrCombineConfigurations ( Constants . ConfigurationKey . OozieEnv , new Dictionary < string , string >
182
181
{
183
182
{ Constants . MetastoreConfigurations . OozieEnv . DatabaseKey , Constants . MetastoreConfigurations . DatabaseValue } ,
184
183
{ Constants . MetastoreConfigurations . OozieEnv . DatabaseNameKey , oozieMetastore . DatabaseName } ,
@@ -189,6 +188,22 @@ public static void AddOozieMetastoreToConfigurations(AzureHDInsightMetastore ooz
189
188
} ) ;
190
189
}
191
190
191
+ public static void AddCustomAmbariDatabaseToConfigurations ( AzureHDInsightMetastore ambariDatabase , IDictionary < string , Dictionary < string , string > > configurations )
192
+ {
193
+ if ( Uri . CheckHostName ( ambariDatabase . SqlAzureServerName ) != UriHostNameType . Dns )
194
+ {
195
+ throw new ArgumentException ( "Please provide the fully qualified sql server name." ) ;
196
+ }
197
+
198
+ configurations . AddOrCombineConfigurations ( Constants . ConfigurationKey . AmbariConf , new Dictionary < string , string >
199
+ {
200
+ { Constants . AmbariConfiguration . SqlServerKey , ambariDatabase . SqlAzureServerName } ,
201
+ { Constants . AmbariConfiguration . DatabaseNameKey , ambariDatabase . DatabaseName } ,
202
+ { Constants . AmbariConfiguration . DatabaseUserKey , ambariDatabase . Credential . UserName } ,
203
+ { Constants . AmbariConfiguration . DatabasePasswordKey , ambariDatabase . Credential . Password . ConvertToString ( ) }
204
+ } ) ;
205
+ }
206
+
192
207
public static VirtualNetworkProfile CreateVirtualNetworkProfile ( string virtualNetworkId , string subnetName )
193
208
{
194
209
if ( string . IsNullOrEmpty ( virtualNetworkId ) && string . IsNullOrEmpty ( subnetName ) )
0 commit comments