1111// limitations under the License.
1212// ----------------------------------------------------------------------------------
1313
14- using Microsoft . Azure . Commands . HDInsight . Models . Management ;
1514using Microsoft . Azure . Management . HDInsight . Models ;
1615using Microsoft . WindowsAzure . Commands . Common ;
1716using System ;
@@ -25,7 +24,7 @@ public static class ClusterCreateHelper
2524 {
2625 public static void AddClusterCredentialToGatewayConfig ( PSCredential httpCredential , IDictionary < string , Dictionary < string , string > > configurations )
2726 {
28- Dictionary < string , string > gatewayConfig = GetExistingConfigurationsForType ( configurations , ConfigurationKey . Gateway ) ;
27+ Dictionary < string , string > gatewayConfig = GetExistingConfigurationsForType ( configurations , Constants . ConfigurationKey . Gateway ) ;
2928 if ( ! string . IsNullOrEmpty ( httpCredential ? . UserName ) )
3029 {
3130 gatewayConfig [ Constants . GatewayConfigurations . CredentialIsEnabledKey ] = "true" ;
@@ -37,7 +36,7 @@ public static void AddClusterCredentialToGatewayConfig(PSCredential httpCredenti
3736 gatewayConfig [ Constants . GatewayConfigurations . CredentialIsEnabledKey ] = "false" ;
3837 }
3938
40- configurations [ ConfigurationKey . Gateway ] = gatewayConfig ;
39+ configurations [ Constants . ConfigurationKey . Gateway ] = gatewayConfig ;
4140 }
4241
4342 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
5655 }
5756
5857 // Get existing core configs.
59- Dictionary < string , string > coreConfig = GetExistingConfigurationsForType ( configurations , ConfigurationKey . CoreSite ) ;
58+ Dictionary < string , string > coreConfig = GetExistingConfigurationsForType ( configurations , Constants . ConfigurationKey . CoreSite ) ;
6059
6160 // Add configurations for default ADL storage.
6261 coreConfig [ Constants . StorageConfigurations . DefaultFsKey ] = Constants . StorageConfigurations . DefaultFsAdlValue ;
6362 coreConfig [ Constants . StorageConfigurations . AdlHostNameKey ] = storageAccountName ;
6463 coreConfig [ Constants . StorageConfigurations . AdlMountPointKey ] = storageRootPath ;
6564
66- configurations [ ConfigurationKey . CoreSite ] = coreConfig ;
65+ configurations [ Constants . ConfigurationKey . CoreSite ] = coreConfig ;
6766 }
6867
6968 public static void AddAdditionalStorageAccountsToCoreConfig ( Dictionary < string , string > additionalStorageAccounts , IDictionary < string , Dictionary < string , string > > configurations )
7069 {
7170 // Get existing core configs.
72- Dictionary < string , string > coreConfig = GetExistingConfigurationsForType ( configurations , ConfigurationKey . CoreSite ) ;
71+ Dictionary < string , string > coreConfig = GetExistingConfigurationsForType ( configurations , Constants . ConfigurationKey . CoreSite ) ;
7372
7473 foreach ( KeyValuePair < string , string > storageAccount in additionalStorageAccounts )
7574 {
7675 string configKey = string . Format ( Constants . StorageConfigurations . WasbStorageAccountKeyFormat , storageAccount . Key ) ;
7776 coreConfig [ configKey ] = storageAccount . Value ;
7877 }
7978
80- configurations [ ConfigurationKey . CoreSite ] = coreConfig ;
79+ configurations [ Constants . ConfigurationKey . CoreSite ] = coreConfig ;
8180 }
8281
8382 public static void AddDataLakeStorageGen1IdentityToIdentityConfig ( Guid applicationId , Guid aadTenantId , byte [ ] certificateFileBytes , string certificatePassword ,
@@ -95,7 +94,7 @@ public static void AddDataLakeStorageGen1IdentityToIdentityConfig(Guid applicati
9594 { Constants . DataLakeConfigurations . ResourceUriKey , dataLakeEndpointResourceId }
9695 } ;
9796
98- configurations [ ConfigurationKey . ClusterIdentity ] = datalakeConfig ;
97+ configurations [ Constants . ConfigurationKey . ClusterIdentity ] = datalakeConfig ;
9998 }
10099
101100 public static StorageAccount CreateAzureStorageAccount ( string clusterName , string storageResourceId , string storageAccountkey , string storageContainer , string defaultStorageSuffix )
@@ -142,15 +141,15 @@ public static void AddHiveMetastoreToConfigurations(AzureHDInsightMetastore hive
142141 string connectionUrl =
143142 string . Format ( Constants . MetastoreConfigurations . ConnectionUrlFormat , hiveMetastore . SqlAzureServerName , hiveMetastore . DatabaseName ) ;
144143
145- configurations . AddOrCombineConfigurations ( ConfigurationKey . HiveSite , new Dictionary < string , string >
144+ configurations . AddOrCombineConfigurations ( Constants . ConfigurationKey . HiveSite , new Dictionary < string , string >
146145 {
147146 { Constants . MetastoreConfigurations . HiveSite . ConnectionUrlKey , connectionUrl } ,
148147 { Constants . MetastoreConfigurations . HiveSite . ConnectionUserNameKey , hiveMetastore . Credential . UserName } ,
149148 { Constants . MetastoreConfigurations . HiveSite . ConnectionPasswordKey , hiveMetastore . Credential . Password . ConvertToString ( ) } ,
150149 { Constants . MetastoreConfigurations . HiveSite . ConnectionDriverNameKey , Constants . MetastoreConfigurations . HiveSite . ConnectionDriverNameValue }
151150 } ) ;
152151
153- configurations . AddOrCombineConfigurations ( ConfigurationKey . HiveEnv , new Dictionary < string , string >
152+ configurations . AddOrCombineConfigurations ( Constants . ConfigurationKey . HiveEnv , new Dictionary < string , string >
154153 {
155154 { Constants . MetastoreConfigurations . HiveEnv . DatabaseKey , Constants . MetastoreConfigurations . DatabaseValue } ,
156155 { Constants . MetastoreConfigurations . HiveEnv . DatabaseNameKey , hiveMetastore . DatabaseName } ,
@@ -169,7 +168,7 @@ public static void AddOozieMetastoreToConfigurations(AzureHDInsightMetastore ooz
169168 }
170169 string connectionUrl = string . Format ( Constants . MetastoreConfigurations . ConnectionUrlFormat , oozieMetastore . SqlAzureServerName , oozieMetastore . DatabaseName ) ;
171170
172- configurations . AddOrCombineConfigurations ( ConfigurationKey . OozieSite , new Dictionary < string , string >
171+ configurations . AddOrCombineConfigurations ( Constants . ConfigurationKey . OozieSite , new Dictionary < string , string >
173172 {
174173 { Constants . MetastoreConfigurations . OozieSite . UrlKey , connectionUrl } ,
175174 { Constants . MetastoreConfigurations . OozieSite . UserNameKey , oozieMetastore . Credential . UserName } ,
@@ -178,7 +177,7 @@ public static void AddOozieMetastoreToConfigurations(AzureHDInsightMetastore ooz
178177 { Constants . MetastoreConfigurations . OozieSite . SchemaKey , Constants . MetastoreConfigurations . OozieSite . SchemaValue }
179178 } ) ;
180179
181- configurations . AddOrCombineConfigurations ( ConfigurationKey . OozieEnv , new Dictionary < string , string >
180+ configurations . AddOrCombineConfigurations ( Constants . ConfigurationKey . OozieEnv , new Dictionary < string , string >
182181 {
183182 { Constants . MetastoreConfigurations . OozieEnv . DatabaseKey , Constants . MetastoreConfigurations . DatabaseValue } ,
184183 { Constants . MetastoreConfigurations . OozieEnv . DatabaseNameKey , oozieMetastore . DatabaseName } ,
@@ -189,6 +188,22 @@ public static void AddOozieMetastoreToConfigurations(AzureHDInsightMetastore ooz
189188 } ) ;
190189 }
191190
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+
192207 public static VirtualNetworkProfile CreateVirtualNetworkProfile ( string virtualNetworkId , string subnetName )
193208 {
194209 if ( string . IsNullOrEmpty ( virtualNetworkId ) && string . IsNullOrEmpty ( subnetName ) )
0 commit comments