Ejemplo n.º 1
0
        /// <summary>
        /// Rollback all imported resources.
        /// </summary>
        internal void RollBackResources()
        {
            string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;

            Logger.Info(methodName, ProgressResources.ExecutionStarted);
            Logger.Info(methodName, ProgressResources.RollbackStarted);
            dcMigrationManager.ReportProgress(ProgressResources.RollbackStarted);
            List <string> listOfImportedResources = new List <string>();

            foreach (var datacenter in subscription.DataCenters)
            {
                // Rollback all services.
                RollBackServices(datacenter.CloudServices.Where(csImported => csImported.IsImported == true).Select(cs =>
                                                                                                                    resourceImporter.GetDestinationResourceName(ResourceType.CloudService, cs.CloudServiceDetails.ServiceName)
                                                                                                                    ).ToList());
                int stageCount = 1;
                Logger.Info(methodName, string.Format(ProgressResources.RollbackCompletedStages, stageCount,
                                                      Constants.RollBackTotalStages), ResourceType.CloudService.ToString());
                dcMigrationManager.ReportProgress(string.Format(ProgressResources.RollbackCompletedStages, stageCount,
                                                                Constants.RollBackTotalStages));

                // Rollback all storage accounts.
                RollBackStorageAccounts(datacenter.StorageAccounts.Where(saImported => saImported.IsImported == true).Select(sa =>
                                                                                                                             resourceImporter.GetDestinationResourceName(ResourceType.StorageAccount, sa.StorageAccountDetails.Name)
                                                                                                                             ).ToList());
                Logger.Info(methodName, string.Format(ProgressResources.RollbackCompletedStages, stageCount++,
                                                      Constants.RollBackTotalStages), ResourceType.StorageAccount.ToString());
                dcMigrationManager.ReportProgress(string.Format(ProgressResources.RollbackCompletedStages, stageCount,
                                                                Constants.RollBackTotalStages));

                dcMigrationManager.ReportProgress(ProgressResources.RollbackVirtualNetworks);
                Logger.Info(methodName, ProgressResources.RollbackVirtualNetworks, ResourceType.NetworkConfiguration.ToString());
                // Rollback all virtual networks.
                if (datacenter.NetworkConfiguration != null && datacenter.NetworkConfiguration.IsImported)
                {
                    RollBackVirtualNetworks(datacenter.NetworkConfiguration);
                }
                Logger.Info(methodName, string.Format(ProgressResources.RollbackCompletedStages, stageCount++,
                                                      Constants.RollBackTotalStages), ResourceType.NetworkConfiguration.ToString());
                dcMigrationManager.ReportProgress(string.Format(ProgressResources.RollbackCompletedStages, stageCount,
                                                                Constants.RollBackTotalStages));

                // Rollback all affinity groups.
                RollBackAffinityGroups(datacenter.AffinityGroups.Where(agImported => agImported.IsImported == true).Select(ag =>
                                                                                                                           resourceImporter.GetDestinationResourceName(ResourceType.AffinityGroup, ag.AffinityGroupDetails.Name)
                                                                                                                           ).ToList());

                Logger.Info(methodName, string.Format(ProgressResources.RollbackCompletedStages, stageCount++,
                                                      Constants.RollBackTotalStages), ResourceType.AffinityGroup.ToString());
                dcMigrationManager.ReportProgress(string.Format(ProgressResources.RollbackCompletedStages, stageCount,
                                                                Constants.RollBackTotalStages));

                Logger.Info(methodName, ProgressResources.RollbackCompleted);
                dcMigrationManager.ReportProgress(ProgressResources.RollbackCompleted);

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