private void ExitMaintenanceMode(Host host) { List<VM> vmsToUnEvacuate = new List<VM>(); vmsToUnEvacuate.AddRange(host.GetHaltedEvacuatedVMs()); vmsToUnEvacuate.AddRange(host.GetMigratedEvacuatedVMs()); vmsToUnEvacuate.AddRange(host.GetSuspendedEvacuatedVMs()); List<VM> to_remove = new List<VM>(); foreach (VM vm in vmsToUnEvacuate) { if (vm.resident_on == host.opaque_ref) to_remove.Add(vm); } foreach (VM vm in to_remove) { vmsToUnEvacuate.Remove(vm); } DialogResult result = DialogResult.No; if (vmsToUnEvacuate.Count > 0 && !MainWindowCommandInterface.RunInAutomatedTestMode) { result = new RestoreVMsDialog(vmsToUnEvacuate, host).ShowDialog(); if (result == DialogResult.Cancel) return; if (!host.Connection.IsConnected) { MainWindow.ShowDisconnectedMessage(null); return; } } MainWindowCommandInterface.CloseActiveWizards(host.Connection); var action = new EnableHostAction(host, result == DialogResult.Yes,AddHostToPoolCommand.EnableNtolDialog); action.Completed += delegate { MainWindowCommandInterface.RequestRefreshTreeView(); }; action.RunAsync(); MainWindowCommandInterface.RequestRefreshTreeView(); }