protected override void ExecuteCore(SelectedItemCollection selection)
        {
            VM vm = (VM)selection[0].XenObject;

            using (var dlg = new ThreeButtonDialog(
                       new ThreeButtonDialog.Details(
                           SystemIcons.Warning,
                           string.Format(Messages.CONVERT_TEMPLATE_DIALOG_TEXT, vm.Name().Ellipsise(25)),
                           Messages.CONVERT_TO_TEMPLATE),
                       new ThreeButtonDialog.TBDButton(Messages.CONVERT, DialogResult.OK, ThreeButtonDialog.ButtonType.ACCEPT, true),
                       ThreeButtonDialog.ButtonCancel))
            {
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    List <AsyncAction> actions = new List <AsyncAction>();
                    actions.Add(new SetVMOtherConfigAction(vm.Connection, vm, "instant", "true"));
                    actions.Add(new VMToTemplateAction(vm));

                    MainWindowCommandInterface.CloseActiveWizards(vm);

                    RunMultipleActions(actions, string.Format(Messages.ACTION_VM_TEMPLATIZING_TITLE, vm.Name()),
                                       Messages.ACTION_VM_TEMPLATIZING, Messages.ACTION_VM_TEMPLATIZED, true);
                }
            }
        }
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            var actions   = new List <AsyncAction>();
            var liveHosts = selection.AsXenObjects <Host>().Where(h => h.IsLive());

            foreach (Host host in liveHosts)
            {
                MainWindowCommandInterface.CloseActiveWizards(host.Connection);
                var action = new RestartToolstackAction(host);
                actions.Add(action);
            }
            RunMultipleActions(actions, null, Messages.ACTION_TOOLSTACK_RESTARTING, Messages.ACTION_TOOLSTACK_RESTARTED, true);
        }
Esempio n. 3
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            List <AsyncAction> actions = new List <AsyncAction>();

            foreach (Host host in selection.AsXenObjects <Host>(CanExecute))
            {
                MainWindowCommandInterface.CloseActiveWizards(host.Connection);
                RebootHostAction action = new RebootHostAction(host, AddHostToPoolCommand.NtolDialog);
                action.Completed += s => MainWindowCommandInterface.RequestRefreshTreeView();
                actions.Add(action);
            }
            RunMultipleActions(actions, null, Messages.ACTION_HOSTS_REBOOTING, Messages.ACTION_HOSTS_REBOOTED, true);
        }
        private void DoDisconnect(IXenConnection connection)
        {
            string     msg    = string.Format(Messages.CONNECTION_CLOSED_NOTICE_TEXT, connection.Hostname);
            ActionBase notice = new ActionBase(msg, msg, false, true);

            notice.Pool = Helpers.GetPoolOfOne(connection);
            notice.Host = Helpers.GetMaster(connection);
            log.Warn($"Connection to {connection.Hostname} closed.");

            MainWindowCommandInterface.CloseActiveWizards(connection);
            XenDialogBase.CloseAll(connection);
            connection.EndConnect();
            MainWindowCommandInterface.SaveServerList();
        }
        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.AllowHistorySwitch();
            MainWindowCommandInterface.CloseActiveWizards(host.Connection);
            var action = new EnableHostAction(host, result == DialogResult.Yes, AddHostToPoolCommand.EnableNtolDialog);

            action.Completed += delegate { MainWindowCommandInterface.Refresh(); };
            action.RunAsync();
            MainWindowCommandInterface.Refresh();
        }
Esempio n. 6
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            MainWindowCommandInterface.SelectObjectInTree(null);

            foreach (Host host in selection.AsXenObjects <Host>())
            {
                string msg = string.Format(Messages.MAINWINDOW_LOG_REMOVECONNECTION, host.Connection.Hostname);
                log.Info($"Removed connection to {host.Connection.Hostname}");
                new ActionBase(msg, msg, false, true);
                MainWindowCommandInterface.CloseActiveWizards(host.Connection);
                host.Connection.EndConnect();
                MainWindowCommandInterface.RemoveConnection(host.Connection);
            }

            MainWindowCommandInterface.SaveServerList();
        }