Esempio n. 1
0
        /// <summary>
        /// Shows the appropriate dialog (HA wizard if HA is disabled for the pool, or VM restart priority editor otherwise).
        /// </summary>
        /// <param name="pool">Must not be null.</param>
        internal static void EditHA(Pool pool)
        {
            // Do nothing if there is an HA action in progress
            if (HelpersGUI.FindActiveHaAction(pool.Connection) != null)
            {
                log.Debug("Not opening HA dialog: an HA action is in progress");
                return;
            }

            if (!pool.Connection.IsConnected)
            {
                log.Debug("Not opening HA dialog: the connection to the pool is now closed");
                return;
            }

            if (pool.ha_enabled)
            {
                // Show VM restart priority editor
                Program.MainWindow.ShowPerConnectionWizard(pool.Connection, new EditVmHaPrioritiesDialog(pool));
            }
            else
            {
                // Show wizard to enable HA
                Program.MainWindow.ShowPerConnectionWizard(pool.Connection, new HAWizard(pool));
            }
        }
Esempio n. 2
0
        protected override bool CanExecuteCore(SelectedItemCollection selection)
        {
            if (selection.Count != 1)
            {
                return(false);
            }

            Pool poolAncestor = selection[0].PoolAncestor;

            if (poolAncestor == null || poolAncestor.Locked)
            {
                return(false);
            }

            if (poolAncestor.Connection == null || !poolAncestor.Connection.IsConnected)
            {
                return(false);
            }

            if (HelpersGUI.FindActiveHaAction(poolAncestor.Connection) != null)
            {
                return(false);
            }

            Host master = Helpers.GetMaster(poolAncestor.Connection);

            if (master == null)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 3
0
        protected bool CanExecuteHACommand(SelectedItemCollection selection)
        {
            if (selection.Count != 1)
            {
                return(false);
            }

            Pool pool = selection[0].PoolAncestor;

            if (pool == null || pool.Locked ||
                pool.Connection == null || !pool.Connection.IsConnected ||
                Helpers.GetMaster(pool.Connection) == null ||
                HelpersGUI.FindActiveHaAction(pool.Connection) != null)
            {
                return(false);
            }

            return(CanExecute(pool));
        }
Esempio n. 4
0
        protected override string GetCantExecuteReasonCore(SelectedItem item)
        {
            Pool poolAncestor = item.PoolAncestor;
            bool inPool       = poolAncestor != null;

            if (inPool)
            {
                Host master = Helpers.GetMaster(poolAncestor.Connection);

                if (master == null)
                {
                    return(Messages.FIELD_DISABLED);
                }
                else if (HelpersGUI.FindActiveHaAction(poolAncestor.Connection) != null || poolAncestor.Locked)
                {
                    return(Messages.POOL_EDIT_IN_PROGRESS);
                }
            }
            return(base.GetCantExecuteReasonCore(item));
        }
Esempio n. 5
0
        protected override bool CanExecuteCore(SelectedItemCollection selection)
        {
            if (selection.Count == 1)
            {
                Pool poolAncestor = selection[0].PoolAncestor;
                bool inPool       = poolAncestor != null;

                if (inPool)
                {
                    Host master = Helpers.GetMaster(poolAncestor.Connection);

                    if (master == null || HelpersGUI.FindActiveHaAction(poolAncestor.Connection) != null || poolAncestor.Locked)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Esempio n. 6
0
        protected override string GetCantExecuteReasonCore(IXenObject item)
        {
            Pool pool = item == null ? null : Helpers.GetPoolOfOne(item.Connection);

            if (pool == null)
            {
                return(Messages.POOL_GONE);
            }

            if (!pool.IsVisible())
            {
                return(Messages.HA_STANDALONE_SERVER);
            }

            Host master = Helpers.GetMaster(pool.Connection);

            if (master == null)
            {
                return(Messages.POOL_MASTER_GONE);
            }

            if (pool.Locked)
            {
                return(Messages.POOL_EDIT_IN_PROGRESS);
            }

            var action = HelpersGUI.FindActiveHaAction(pool.Connection);

            if (action != null)
            {
                return(string.Format(action is EnableHAAction ? Messages.HA_PAGE_ENABLING : Messages.HA_PAGE_DISABLING,
                                     Helpers.GetName(pool.Connection)));
            }

            return(Messages.UNKNOWN);
        }
Esempio n. 7
0
        /// <summary>
        /// Rebuilds the panel contents. Must be called on the event thread.
        /// </summary>
        private void Rebuild()
        {
            Program.AssertOnEventThread();
            if (!this.Visible)
            {
                return;
            }
            customListPanel.BeginUpdate();
            try
            {
                customListPanel.ClearRows();
                tableLatencies.Controls.Clear();

                if (xenObject == null)
                {
                    return;
                }

                AsyncAction action = HelpersGUI.FindActiveHaAction(xenObject.Connection);
                if (action != null)
                {
                    // There is an EnableHAAction or DisableHAAction in progress relating to this connection.
                    // Show some text and disable editing
                    buttonConfigure.Visible       = true;
                    buttonConfigure.Enabled       = false;
                    buttonEnableDisableHa.Visible = true;
                    buttonEnableDisableHa.Enabled = false;

                    pictureBoxWarningTriangle.Visible = false;
                    labelStatus.Text = String.Format(action is EnableHAAction ? Messages.HA_PAGE_ENABLING : Messages.HA_PAGE_DISABLING,
                                                     Helpers.GetName(xenObject.Connection));
                }
                else
                {
                    // Generate the tab contents depending on what XenObject we're displaying

                    if (pool.ha_enabled)
                    {
                        buttonEnableDisableHa.Text = Messages.DISABLE_HA_ELLIPSIS;

                        if (PassedRbacChecks())
                        {
                            buttonConfigure.Visible       = true;
                            buttonConfigure.Enabled       = true;
                            buttonEnableDisableHa.Visible = true;
                            buttonEnableDisableHa.Enabled = true;

                            pictureBoxWarningTriangle.Visible = false;
                            labelStatus.Text = string.Format(Messages.HA_TAB_CONFIGURED_BLURB, Helpers.GetName(pool).Ellipsise(30));
                        }
                        else
                        {
                            buttonConfigure.Visible       = false;
                            buttonConfigure.Enabled       = false;
                            buttonEnableDisableHa.Visible = false;
                            buttonEnableDisableHa.Enabled = false;

                            pictureBoxWarningTriangle.Visible = true;
                            labelStatus.Text = String.Format(Messages.RBAC_HA_TAB_WARNING,
                                                             Role.FriendlyCSVRoleList(Role.ValidRoleList(HA_PERMISSION_CHECKS, pool.Connection)),
                                                             Role.FriendlyCSVRoleList(pool.Connection.Session.Roles));
                        }
                    }
                    else
                    {
                        buttonEnableDisableHa.Text = Messages.ENABLE_HA_ELLIPSIS;

                        buttonConfigure.Visible       = true;
                        buttonConfigure.Enabled       = true;
                        buttonEnableDisableHa.Visible = false;
                        buttonEnableDisableHa.Enabled = true;

                        pictureBoxWarningTriangle.Visible = false;
                        labelStatus.Text = String.Format(Messages.HAPANEL_BLURB, Helpers.GetName(pool).Ellipsise(30));
                    }

                    if (xenObject is SR)
                    {
                        // Currently unused
                        SR sr = (SR)xenObject;
                        generateSRHABox(sr);
                    }
                    else if (xenObject is Pool)
                    {
                        generatePoolHABox(pool);
                        tableLayoutPanel1.AutoScrollMinSize = new Size(0, tableLatencies.Height + customListPanel.Height);
                    }
                }
            }
            finally
            {
                customListPanel.EndUpdate();
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Rebuilds the panel contents. Must be called on the event thread.
        /// </summary>
        private void Rebuild()
        {
            Program.AssertOnEventThread();
            if (!this.Visible)
            {
                return;
            }
            customListPanel.BeginUpdate();
            try
            {
                customListPanel.ClearRows();
                tableLatencies.Controls.Clear();

                if (xenObject == null)
                {
                    return;
                }

                buttonConfigure.Command = new HAConfigureCommand(Program.MainWindow, xenObject.Connection);
                buttonDisableHa.Command = new HADisableCommand(Program.MainWindow, xenObject.Connection);

                AsyncAction action = HelpersGUI.FindActiveHaAction(xenObject.Connection);
                if (action != null)
                {
                    // There is an EnableHAAction or DisableHAAction in progress relating to this connection.

                    labelStatus.Text = String.Format(action is EnableHAAction ? Messages.HA_PAGE_ENABLING : Messages.HA_PAGE_DISABLING,
                                                     Helpers.GetName(xenObject.Connection));
                }
                else
                {
                    //CA-250234 no need to rebuild HA page if we lost connection to the pool
                    if (pool.Connection?.Session == null || !pool.Connection.IsConnected)
                    {
                        return;
                    }

                    if (pool.ha_enabled)
                    {
                        buttonConfigure.Visible = buttonDisableHa.Visible = true;
                        labelStatus.Text        = string.Format(Messages.HA_TAB_CONFIGURED_BLURB, Helpers.GetName(pool).Ellipsise(30));
                    }
                    else
                    {
                        buttonDisableHa.Visible = false;
                        labelStatus.Text        = String.Format(Messages.HAPANEL_BLURB, Helpers.GetName(pool).Ellipsise(30));
                    }

                    if (xenObject is SR sr)
                    {
                        // Currently unused
                        generateSRHABox(sr);
                    }
                    else if (xenObject is Pool)
                    {
                        generatePoolHABox(pool);
                        tableLayoutPanel1.AutoScrollMinSize = new Size(0, tableLatencies.Height + customListPanel.Height);
                    }
                }
            }
            finally
            {
                customListPanel.EndUpdate();
            }
        }