Пример #1
0
        private void buttonDisableHa_Click(object sender, EventArgs e)
        {
            if (pool == null)
            {
                return;
            }

            if (!pool.ha_enabled)
            {
                // Start HA wizard
                EditHA(pool);
                return;
            }

            if (pool.ha_statefiles.All(sf => pool.Connection.Resolve(new XenRef <VDI>(sf)) == null)) //empty gives true, which is correct
            {
                using (var dlg = new ThreeButtonDialog(
                           new ThreeButtonDialog.Details(
                               SystemIcons.Error,
                               string.Format(Messages.HA_DISABLE_NO_STATEFILE, Helpers.GetName(pool).Ellipsise(30)),
                               Messages.DISABLE_HA),
                           "HADisable",
                           ThreeButtonDialog.ButtonOK))
                {
                    dlg.ShowDialog(this);
                    return;
                }
            }

            // Confirm the user wants to disable HA
            using (var dlg = new ThreeButtonDialog(
                       new ThreeButtonDialog.Details(
                           null,
                           string.Format(Messages.HA_DISABLE_QUERY, Helpers.GetName(pool).Ellipsise(30)),
                           Messages.DISABLE_HA),
                       "HADisable",
                       ThreeButtonDialog.ButtonYes,
                       ThreeButtonDialog.ButtonNo))
            {
                if (dlg.ShowDialog(this) != DialogResult.Yes)
                {
                    return;
                }
            }

            DisableHAAction action = new DisableHAAction(pool);

            // We will need to re-enable buttons when the action completes
            action.Completed += Program.MainWindow.action_Completed;
            action.RunAsync();
        }
Пример #2
0
        protected override void ExecuteCore(SelectedItemCollection selection)
        {
            Pool pool = selection.Count == 1 ? selection[0].PoolAncestor : null;

            if (pool == null || !pool.ha_enabled)
            {
                return;
            }

            if (pool.ha_statefiles.All(sf => pool.Connection.Resolve(new XenRef <VDI>(sf)) == null)) //empty gives true, which is correct
            {
                using (var dlg = new ErrorDialog(string.Format(Messages.HA_DISABLE_NO_STATEFILE,
                                                               Helpers.GetName(pool).Ellipsise(30)),
                                                 ThreeButtonDialog.ButtonOK)
                {
                    WindowTitle = Messages.DISABLE_HA
                })
                {
                    dlg.ShowDialog(Parent);
                    return;
                }
            }

            // Confirm the user wants to disable HA
            using (var dlg = new NoIconDialog(string.Format(Messages.HA_DISABLE_QUERY,
                                                            Helpers.GetName(pool).Ellipsise(30)),
                                              ThreeButtonDialog.ButtonYes, ThreeButtonDialog.ButtonNo)
            {
                HelpNameSetter = "HADisable",
                WindowTitle = Messages.DISABLE_HA
            })
            {
                if (dlg.ShowDialog(Parent) != DialogResult.Yes)
                {
                    return;
                }
            }

            var action = new DisableHAAction(pool);

            // We will need to re-enable buttons when the action completes
            action.Completed += Program.MainWindow.action_Completed;
            action.RunAsync();
        }
Пример #3
0
        private void buttonEnableDisableHa_Click(object sender, EventArgs e)
        {
            if (pool == null)
            {
                return;
            }

            if (!pool.ha_enabled)
            {
                // Start HA wizard
                EditHA(pool);
                return;
            }

            // Offer to disable HA
            DialogResult dr;

            using (var dlg = new ThreeButtonDialog(
                       new ThreeButtonDialog.Details(
                           null,
                           string.Format(Messages.HA_DISABLE_QUERY, Helpers.GetName(pool).Ellipsise(30)),
                           Messages.DISABLE_HA),
                       "HADisable",
                       ThreeButtonDialog.ButtonYes,
                       ThreeButtonDialog.ButtonNo))
            {
                dr = dlg.ShowDialog(this);
            }
            if (dr != DialogResult.Yes)
            {
                return;
            }

            DisableHAAction action = new DisableHAAction(pool);

            // We will need to re-enable buttons when the action completes
            action.Completed += Program.MainWindow.action_Completed;
            action.RunAsync();
            Program.MainWindow.UpdateToolbars();
        }
Пример #4
0
        /// <summary>
        /// Finds the EnableHAAction or DisableHAAction in progress that pertains to the given connection, or null
        /// if there is no such action.
        /// Must be called on the event thread.
        /// </summary>
        /// <param name="connection">May not be null.</param>
        /// <returns></returns>
        internal static AsyncAction FindActiveHaAction(IXenConnection connection)
        {
            Program.AssertOnEventThread();
            foreach (ActionBase action in ConnectionsManager.History)
            {
                if (action.IsCompleted)
                {
                    continue;
                }

                EnableHAAction enableAction = action as EnableHAAction;
                if (enableAction != null && !enableAction.Cancelled && enableAction.Connection == connection)
                {
                    return(enableAction);
                }

                DisableHAAction disableAction = action as DisableHAAction;
                if (disableAction != null && !disableAction.Cancelled && disableAction.Connection == connection)
                {
                    return(disableAction);
                }
            }
            return(null);
        }