コード例 #1
0
ファイル: RollBack.cs プロジェクト: clone278/adcms
 public RollBack(ImportParameters importParameters, Subscription subscription, DCMigrationManager dcMigrationManager,
     ResourceImporter resourceImporter)
 {
     this.subscription = subscription;
     this.importParameters = importParameters;
     this.dcMigrationManager = dcMigrationManager;
     this.resourceImporter = resourceImporter;
 }
コード例 #2
0
ファイル: DCMigrationManager.cs プロジェクト: clone278/adcms
        /// <summary>
        /// Reads exported metadata json file and deploys all the source resources into destination subscription.
        /// </summary>
        /// <param name="parameters"> Collection of key value paired input parameters <example> 
        /// Operation "Import" SourceSubscriptionID "5d14d4a2-8c5a-4fc5-8d7d-86efb48b3a07" DestinationSubscriptionID "5d14d4a2-8c5a-4fc5-8d7d-86efb48b3a07" 
        /// DestinationDCName "West US" SourcePublishSettingsFilePath "D:\\PublishSettings.PublishSettings" SourceCertificateThumbprint "2180d782768926ee0e5ddbcc6e8d2efa8ddb98c7" 
        /// DestinationPublishSettingsFilePath "D:\\PublishSettings.PublishSettings" DestinationCertificateThumbprint "2180d782768926ee0e5ddbcc6e8d2efa8ddb98c7" 
        /// ImportMetadataFilePath "D:\\DataCenterMigration\mydata.json" MapperXmlFilePath "D:\\DataCenterMigration\mydata.xml" DestinationPrefixName "dc" 
        /// RetryCount "5" MinBackoff "3" MaxBackoff "3" DeltaBackoff "90" QuietMode "True" RollBackOnFailure "True" ResumeImport "True" </example></param>
        public void ImportSubscriptionMetadata(IDictionary<string, string> parameters)
        {
            string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
            Logger.Info(methodName, ProgressResources.ExecutionStarted);
            bool boolValue;
            if (!parameters.Keys.Contains(Constants.Parameters.QuietMode))
            {
                quietMode = false;
            }
            else
            {
                quietMode = bool.TryParse(parameters[Constants.Parameters.QuietMode], out boolValue) ? boolValue : false;
            }

            Logger.Info(methodName, string.Format(ProgressResources.ImportMetadataStarted, parameters[Constants.Parameters.ImportMetadataFilePath]));
            ReportProgress(string.Format(ProgressResources.ImportMetadataStarted, parameters[Constants.Parameters.ImportMetadataFilePath]));

            // Validate the input paramters and export them into parameters class.
            ImportParameters importParameters = ConfigurationReader.ValidateAndConvertImportParameters(parameters, true);

            // Import metadata.
            ResourceImporter importer = new ResourceImporter(importParameters, this);
            importer.ImportSubscriptionMetadata();

            ReportProgress(ProgressResources.ImportMetadataCompleted);

            Logger.Info(methodName, ProgressResources.ImportMetadataCompleted);
            Logger.Info(methodName, ProgressResources.ExecutionCompleted);
        }
コード例 #3
0
ファイル: DCMigrationManager.cs プロジェクト: clone278/adcms
        /// <summary>
        /// Combination of Export and Import functionality. 
        /// Exports information about source subscription and stores the metadata into 'SourceDataCenterName-MM-DD-YYYY-hh-mm.json format 
        /// on specified ExportMetadataFolderPath.
        /// Reads exported metadata json file and deploys all the source resources into destination subscription.
        /// </summary>
        /// <param name="parameters"> Collection of key value paired input parameters <example> Operation "Migrate" 
        /// SourceSubscriptionID "5d14d4a2-8c5a-4fc5-8d7d-86efb48b3a07" DestinationSubscriptionID "5d14d4a2-8c5a-4fc5-8d7d-86efb48b3a07" SourceDCName "East Asia" 
        /// DestinationDCName "West US" SourcePublishSettingsFilePath "D:\\PublishSettings.PublishSettings" SourceCertificateThumbprint "2180d782768926ee0e5ddbcc6e8d2efa8ddb98c7" 
        /// DestinationPublishSettingsFilePath "D:\\PublishSettings.PublishSettings" DestinationCertificateThumbprint "2180d782768926ee0e5ddbcc6e8d2efa8ddb98c7" 
        /// ExportMetadataFolderPath "D:\\DataCenterMigration" DestinationPrefixName "dc" RetryCount "5" MinBackoff "3" MaxBackoff "3" DeltaBackoff "90"
        /// QuietMode "True" RollBackOnFailure "True" </example></param>
        public void MigrateSubscription(IDictionary<string, string> parameters)
        {
            string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
            Logger.Info(methodName, ProgressResources.ExecutionStarted);
            bool boolValue;
            if (!parameters.Keys.Contains(Constants.Parameters.QuietMode))
            {
                quietMode = false;
            }
            else
            {
                quietMode = bool.TryParse(parameters[Constants.Parameters.QuietMode], out boolValue) ? boolValue : false;
            }

            ReportProgress(ProgressResources.ExportMetadataStarted);
            Logger.Info(methodName, ProgressResources.ExportMetadataStarted);

            // Validate the input paramters and export them into parameters class.
            ExportParameters exportParameters = ConfigurationReader.ValidateAndConvertExportParameters(parameters);

            // Validate the input paramters and export them into parameters class.
            ImportParameters importParameters = ConfigurationReader.ValidateAndConvertImportParameters(parameters, false);

            // Export metadata.
            ResourceExporter exporter = new ResourceExporter(exportParameters, this);
            Subscription subscription = exporter.ExportSubscriptionMetadata();

            File.WriteAllText(exportParameters.ExportMetadataFolderPath,
               JsonConvert.SerializeObject(subscription, Formatting.Indented));
            ReportProgress(string.Format(ProgressResources.ExportMetadataCompleted, exportParameters.ExportMetadataFolderPath));
            Logger.Info(methodName, string.Format(ProgressResources.ExportMetadataCompleted, exportParameters.ExportMetadataFolderPath));
            Logger.Info(methodName, ProgressResources.ExecutionCompleted);

            importParameters.ImportMetadataFilePath = exportParameters.ExportMetadataFolderPath;
            // Import metadata.     
            Logger.Info(methodName, string.Format(ProgressResources.ImportMetadataStarted, importParameters.ImportMetadataFilePath));
            ReportProgress(string.Format(ProgressResources.ImportMetadataStarted, importParameters.ImportMetadataFilePath));

            ResourceImporter importer = new ResourceImporter(importParameters, this);
            importer.ImportSubscriptionMetadata();

            ReportProgress(ProgressResources.ImportMetadataCompleted);
            Logger.Info(methodName, ProgressResources.ImportMetadataCompleted);

            Logger.Info(methodName, ProgressResources.ExecutionCompleted);
        }