private static string GenerateAzureDocument(ClusterCreateParametersV2 clusterCreateParameters)
        {
            if (clusterCreateParameters == null)
            {
                throw new ArgumentNullException("clusterCreateParameters");
            }

            string document = VersionToDocumentMapper.GetAzureCsmDocument(!String.IsNullOrEmpty(clusterCreateParameters.SshPassword));
            AzureCsmDocumentManager azureCsmDocumentManager = new AzureCsmDocumentManager(document);

            // Set basic cluster parameters
            azureCsmDocumentManager.SetDnsName(clusterCreateParameters.Name);
            azureCsmDocumentManager.SetLocation(clusterCreateParameters.Location);
            azureCsmDocumentManager.SetWorkerNodeCount(clusterCreateParameters.ClusterSizeInNodes);
            azureCsmDocumentManager.SetHeadNodeVMSize(String.IsNullOrEmpty(clusterCreateParameters.HeadNodeSize) ? NodeVMSize.Large.ToString() : clusterCreateParameters.HeadNodeSize);
            azureCsmDocumentManager.SetDataNodeVMSize(String.IsNullOrEmpty(clusterCreateParameters.DataNodeSize) ? NodeVMSize.Large.ToString() : clusterCreateParameters.DataNodeSize);

            // Set SSH parameters
            if (!String.IsNullOrEmpty(clusterCreateParameters.SshUserName))
            {
                if (!String.IsNullOrEmpty(clusterCreateParameters.SshPassword))
                {
                    azureCsmDocumentManager.SetSshProfile(clusterCreateParameters.SshUserName, clusterCreateParameters.SshPassword);
                }
                else
                {
                    var x509cert = GetOpenSshCertificate(clusterCreateParameters.SshPublicKey, String.Format("CN={0}", clusterCreateParameters.Name));
                    azureCsmDocumentManager.SetSshProfile(clusterCreateParameters.SshUserName, x509cert);
                }
            }

            return(azureCsmDocumentManager.Document);
        }
        private static string GenerateAmbariConfigurationDocument(ClusterCreateParametersV2 clusterCreateParameters)
        {
            if (clusterCreateParameters == null)
            {
                throw new ArgumentNullException("clusterCreateParameters");
            }

            string document = VersionToDocumentMapper.GetAmbariConfigurationDocument(clusterCreateParameters.Version);
            AmbariConfigurationDocumentManager ambariConfigurationManager = new AmbariConfigurationDocumentManager(document);

            // Set password
            ambariConfigurationManager.SetPassword(clusterCreateParameters.Password);

            // Set default storage account information
            ambariConfigurationManager.RemoveStorageAccountEntries();
            ambariConfigurationManager.SetDefaultStorageAccount(clusterCreateParameters.DefaultStorageContainer, clusterCreateParameters.DefaultStorageAccountName, clusterCreateParameters.DefaultStorageAccountKey);

            // Set additional storage accounts
            foreach (var storageAccount in clusterCreateParameters.AdditionalStorageAccounts)
            {
                ambariConfigurationManager.SetAdditionalStorageAccount(storageAccount.Name, storageAccount.Key);
            }

            // Set custom metastores
            if (clusterCreateParameters.HiveMetastore != null)
            {
                ambariConfigurationManager.SetCustomHiveMetastore(clusterCreateParameters.HiveMetastore);
            }

            if (clusterCreateParameters.OozieMetastore != null)
            {
                ambariConfigurationManager.SetCustomOozieMetastore(clusterCreateParameters.OozieMetastore);
            }

            // Set user specified Hadoop configurations
            ambariConfigurationManager.SetCustomConfigurations(AmbariConfigurationDocumentManager.CoreConfigurationKeyName, clusterCreateParameters.CoreConfiguration);
            ambariConfigurationManager.SetCustomConfigurations(AmbariConfigurationDocumentManager.HdfsConfigurationKeyName, clusterCreateParameters.HdfsConfiguration);
            ambariConfigurationManager.SetCustomConfigurations(AmbariConfigurationDocumentManager.YarnConfigurationKeyName, clusterCreateParameters.YarnConfiguration);
            ambariConfigurationManager.SetCustomConfigurations(AmbariConfigurationDocumentManager.HiveConfigurationKeyName, clusterCreateParameters.HiveConfiguration.ConfigurationCollection);
            ambariConfigurationManager.SetCustomConfigurations(AmbariConfigurationDocumentManager.OozieConfigurationKeyName, clusterCreateParameters.OozieConfiguration.ConfigurationCollection);
            ambariConfigurationManager.SetCustomConfigurations(AmbariConfigurationDocumentManager.MapredConfigurationKeyName, clusterCreateParameters.MapReduceConfiguration.ConfigurationCollection);

            return(ambariConfigurationManager.Document);
        }