Esempio n. 1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (vms == null || vms.Count == 0)
            {
                return;
            }

            // If !firstPaint, don't re-intialize, because it will pull the rug from under our own edits.
            if (!firstPaint)
            {
                return;
            }

            // Layout because of different fonts. I tried putting this in the constructor but it didn't take effect that early.
            memorySpinnerFixed.Left = radioOff.Right + radioOff.Margin.Right;

            // Calculate the maximum legal value of dynamic minimum
            CalcMaxDynMin();

            // Shiny bar
            vmShinyBar.Initialize(vm0, vms.Count > 1, CalcMemoryUsed(), true);

            // Radio buttons and "DMC Unavailable" warning
            if (ballooning)
            {
                if (vm0.memory_dynamic_min == vm0.memory_static_max)
                {
                    radioOff.Checked = true;
                }
                else
                {
                    radioOn.Checked = true;
                }
                iconDMCUnavailable.Visible = labelDMCUnavailable.Visible = linkInstallTools.Visible = false;
            }
            else
            {
                radioOff.Checked   = true;
                radioOn.Enabled    = false;
                groupBoxOn.Enabled = false;

                if (vms.Count > 1)
                {
                    // If all the Virtualisation Statuses are the same, report that reason.
                    // Otherwise give a generic message.
                    VM.VirtualisationStatus vs0 = vm0.GetVirtualisationStatus;
                    bool identical = true;
                    foreach (VM vm in vms)
                    {
                        if (vm.GetVirtualisationStatus != vs0)
                        {
                            identical = false;
                            break;
                        }
                    }
                    if (identical)
                    {
                        var status = vm0.GetVirtualisationStatus;
                        if (status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED))
                        {
                            labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_NOTSUPPORTED_PLURAL;
                        }
                        else if (!status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED))
                        {
                            labelDMCUnavailable.Text = vm0.HasNewVirtualisationStates ? Messages.DMC_UNAVAILABLE_NO_IO_NO_MGMNT_PLURAL : Messages.DMC_UNAVAILABLE_NOTOOLS_PLURAL;
                        }
                        else if (status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE))
                        {
                            labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_OLDTOOLS_PLURAL;
                        }
                        else
                        {
                            labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_VMS;
                        }
                    }
                    else
                    {
                        labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_VMS;
                    }
                    linkInstallTools.Visible = InstallToolsCommand.CanExecuteAll(vms);
                }
                else if (vm0.is_a_template)
                {
                    labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_TEMPLATE;
                    linkInstallTools.Visible = false;
                }
                else
                {
                    var status = vm0.GetVirtualisationStatus;

                    if (status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED))
                    {
                        labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_NOTSUPPORTED;
                    }
                    else if (!status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED))
                    {
                        labelDMCUnavailable.Text = vm0.HasNewVirtualisationStates ? Messages.DMC_UNAVAILABLE_NO_IO_NO_MGMNT : Messages.DMC_UNAVAILABLE_NOTOOLS;
                    }
                    else if (status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE))
                    {
                        labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_OLDTOOLS;
                    }
                    else
                    {
                        labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_VM;
                    }

                    linkInstallTools.Visible = InstallToolsCommand.CanExecute(vm0);
                }
            }

            // Spinners
            FreeSpinnerRanges();
            static_min = vm0.memory_static_min;
            memorySpinnerDynMin.Initialize(Messages.DYNAMIC_MIN_AMP, ballooning ? XenAdmin.Properties.Resources.memory_dynmin_slider_small : null, vm0.memory_dynamic_min, vm0.memory_static_max);
            memorySpinnerDynMax.Initialize(Messages.DYNAMIC_MAX_AMP, ballooning ? XenAdmin.Properties.Resources.memory_dynmax_slider_small : null, vm0.memory_dynamic_max, vm0.memory_static_max);
            memorySpinnerFixed.Initialize("", null, vm0.memory_static_max, vm0.memory_static_max);
            SetIncrements();
            SetSpinnerRanges();
            firstPaint = false;
        }
Esempio n. 2
0
        /// <remarks>
        /// For Non-Windows VMs and for Windows VMs pre-Dundee:
        ///   - Memory, Disk and Network values are not available if XenServer Tools are not installed
        ///
        /// For Windows VMs on Dundee or higher:
        ///  - Memory value is not available if the Management agent is not installed;
        ///  - Disk and Network vlaues are not available if I/O drivers are not installed
        /// </remarks>
        protected bool CheckVMTools(IXenObject o, out GridItemBase item)
        {
            item = null;

            if (!checkTools)
            {
                return(false);
            }

            VM vm = o as VM;

            if (vm != null)
            {
                VM.VirtualisationStatus status = vm.virtualisation_status;
                if (vm.power_state != vm_power_state.Running ||
                    status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_INSTALLED) ||
                    status.HasFlag(VM.VirtualisationStatus.UNKNOWN))
                {
                    return(false);
                }

                if (property == PropertyNames.memoryValue && status.HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED))
                {
                    return(false);
                }

                if ((property == PropertyNames.diskText || property == PropertyNames.networkText) && status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED))
                {
                    return(false);
                }

                string warningMessage;
                int    colSpan;

                if (property == PropertyNames.memoryValue && !status.HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED))
                {
                    if (vm.HasNewVirtualisationStates)
                    {
                        warningMessage = Messages.VIRTUALIZATION_STATE_VM_MANAGEMENT_AGENT_NOT_INSTALLED;
                        colSpan        = 1;
                    }
                    else
                    {
                        warningMessage = vm.GetVirtualisationWarningMessages();
                        colSpan        = 3;
                    }

                    if (InstallToolsCommand.CanExecute(vm))
                    {
                        item = new GridStringItem(warningMessage,
                                                  HorizontalAlignment.Center,
                                                  VerticalAlignment.Middle,
                                                  false,
                                                  false,
                                                  QueryPanel.LinkBrush,
                                                  Program.DefaultFontUnderline,
                                                  QueryPanel.LinkBrush,
                                                  Program.DefaultFontUnderline,
                                                  colSpan,
                                                  (sender, args) => new InstallToolsCommand(Program.MainWindow, vm).Execute(), null);
                    }
                    else
                    {
                        item = new GridStringItem(warningMessage,
                                                  HorizontalAlignment.Center,
                                                  VerticalAlignment.Middle,
                                                  false,
                                                  false,
                                                  QueryPanel.TextBrush,
                                                  Program.DefaultFont,
                                                  colSpan);
                    }
                }

                if (property == PropertyNames.diskText && vm.HasNewVirtualisationStates && !status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED))
                {
                    warningMessage = Messages.VIRTUALIZATION_STATE_VM_IO_NOT_OPTIMIZED;
                    colSpan        = 2;

                    if (InstallToolsCommand.CanExecute(vm))
                    {
                        item = new GridStringItem(warningMessage,
                                                  HorizontalAlignment.Center,
                                                  VerticalAlignment.Middle,
                                                  false,
                                                  false,
                                                  QueryPanel.LinkBrush,
                                                  Program.DefaultFontUnderline,
                                                  QueryPanel.LinkBrush,
                                                  Program.DefaultFontUnderline,
                                                  colSpan,
                                                  (sender, args) => new InstallToolsCommand(Program.MainWindow, vm).Execute(), null);
                    }
                    else
                    {
                        item = new GridStringItem(warningMessage,
                                                  HorizontalAlignment.Center,
                                                  VerticalAlignment.Middle,
                                                  false,
                                                  false,
                                                  QueryPanel.TextBrush,
                                                  Program.DefaultFont,
                                                  colSpan);
                    }
                }
                return(true);
            }

            SR sr = o as SR;

            if (sr != null && sr.NeedsUpgrading)
            {
                if (property == PropertyNames.memoryValue)
                {
                    item = new GridStringItem(Messages.UPGRADE_SR_WARNING,
                                              HorizontalAlignment.Center, VerticalAlignment.Middle, false, false,
                                              QueryPanel.LinkBrush, Program.DefaultFontUnderline, QueryPanel.LinkBrush, Program.DefaultFontUnderline, 3,
                                              (sender, args) => new UpgradeSRCommand(Program.MainWindow, sr).Execute(), null);
                }

                return(true);
            }

            Pool pool = o as Pool;

            if (pool != null && !pool.IsPoolFullyUpgraded)
            {
                if (property == PropertyNames.memoryValue)
                {
                    var master = pool.Connection.Resolve(pool.master);

                    item = new GridStringItem(string.Format(Messages.POOL_VERSIONS_LINK_TEXT, master.ProductVersionText),
                                              HorizontalAlignment.Center, VerticalAlignment.Middle, false, false,
                                              QueryPanel.LinkBrush, Program.DefaultFontUnderline, QueryPanel.LinkBrush,
                                              Program.DefaultFontUnderline, 3,
                                              (sender, args) => new RollingUpgradeCommand(Program.MainWindow).Execute(),
                                              null);
                }

                return(true);
            }

            return(false);
        }
Esempio n. 3
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (vms == null || vms.Count == 0)
            {
                return;
            }

            // If !firstPaint, don't re-intialize, because it will pull the rug from under our own edits.
            if (!firstPaint)
            {
                return;
            }

            // Calculate the maximum legal value of dynamic minimum
            CalcMaxDynMin();

            vmShinyBar.Populate(vms, true);

            bool licenseRestriction = Helpers.FeatureForbidden(vm0.Connection, Host.RestrictDMC);

            // Radio buttons and "DMC Unavailable" warning
            if (ballooning && !licenseRestriction)
            {
                if (vm0.memory_dynamic_min == vm0.memory_static_max)
                {
                    radioFixed.Checked = true;
                }
                else
                {
                    radioDynamic.Checked = true;
                }
                iconDMCUnavailable.Visible = labelDMCUnavailable.Visible = linkInstallTools.Visible = false;
            }
            else
            {
                radioFixed.Checked   = true;
                radioDynamic.Enabled = false;
                groupBoxOn.Enabled   = false;

                if (licenseRestriction)
                {
                    labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_LICENSE_RESTRICTION;
                    linkInstallTools.Visible = false;
                }
                else if (vms.Count > 1)
                {
                    // If all the Virtualisation Statuses are the same, report that reason.
                    // Otherwise give a generic message.
                    VM.VirtualisationStatus vs0 = vm0.GetVirtualisationStatus();
                    bool identical = true;
                    foreach (VM vm in vms)
                    {
                        if (vm.GetVirtualisationStatus() != vs0)
                        {
                            identical = false;
                            break;
                        }
                    }
                    if (identical)
                    {
                        var status = vm0.GetVirtualisationStatus();
                        if (status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED))
                        {
                            labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_NOTSUPPORTED_PLURAL;
                        }
                        else if (!status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED))
                        {
                            labelDMCUnavailable.Text = vm0.HasNewVirtualisationStates()
                                ? Messages.DMC_UNAVAILABLE_NO_IO_NO_MGMNT_PLURAL
                                : Messages.DMC_UNAVAILABLE_NOTOOLS_PLURAL;
                        }
                        else if (status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE))
                        {
                            labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_OLDTOOLS_PLURAL;
                        }
                        else
                        {
                            labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_VMS;
                        }
                    }
                    else
                    {
                        labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_VMS;
                    }
                    linkInstallTools.Visible = InstallToolsCommand.CanExecuteAll(vms);
                }
                else if (vm0.is_a_template)
                {
                    labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_TEMPLATE;
                    linkInstallTools.Visible = false;
                }
                else
                {
                    var status = vm0.GetVirtualisationStatus();

                    if (status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED))
                    {
                        labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_NOTSUPPORTED;
                    }
                    else if (!status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED))
                    {
                        labelDMCUnavailable.Text = vm0.HasNewVirtualisationStates()
                            ? Messages.DMC_UNAVAILABLE_NO_IO_NO_MGMNT
                            : Messages.DMC_UNAVAILABLE_NOTOOLS;
                    }
                    else if (status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE))
                    {
                        labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_OLDTOOLS;
                    }
                    else
                    {
                        labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_VM;
                    }

                    linkInstallTools.Visible = InstallToolsCommand.CanExecute(vm0);
                }
            }

            // Spinners
            FreeSpinnerRanges();
            memorySpinnerDynMin.Initialize(vm0.memory_dynamic_min, vm0.memory_static_max);
            memorySpinnerDynMax.Initialize(vm0.memory_dynamic_max, vm0.memory_static_max);
            memorySpinnerFixed.Initialize(vm0.memory_static_max, vm0.memory_static_max);
            SetIncrements();
            SetSpinnerRanges();
            firstPaint = false;
        }
Esempio n. 4
0
        protected bool CheckVMTools(IXenObject o, out GridItemBase item)
        {
            item = null;

            if (!checkTools)
            {
                return(false);
            }

            VM vm = o as VM;

            if (vm != null)
            {
                VM.VirtualisationStatus status = vm.virtualisation_status;
                if (vm.power_state != vm_power_state.Running ||
                    status == VM.VirtualisationStatus.OPTIMIZED ||
                    status == VM.VirtualisationStatus.UNKNOWN)
                {
                    return(false);
                }

                if (property == PropertyNames.memoryValue)
                {
                    if (InstallToolsCommand.CanExecute(vm))
                    {
                        item = new GridStringItem(vm.GetVirtualisationWarningMessages(),
                                                  HorizontalAlignment.Center,
                                                  VerticalAlignment.Middle,
                                                  false,
                                                  false,
                                                  QueryPanel.LinkBrush,
                                                  Program.DefaultFontUnderline,
                                                  QueryPanel.LinkBrush,
                                                  Program.DefaultFontUnderline,
                                                  3,
                                                  (sender, args) => new InstallToolsCommand(Program.MainWindow, vm).Execute(), null);
                    }
                    else
                    {
                        item = new GridStringItem(vm.GetVirtualisationWarningMessages(),
                                                  HorizontalAlignment.Center,
                                                  VerticalAlignment.Middle,
                                                  false,
                                                  false,
                                                  QueryPanel.TextBrush,
                                                  Program.DefaultFont,
                                                  3);
                    }
                }
                return(true);
            }

            SR sr = o as SR;

            if (sr != null && sr.NeedsUpgrading)
            {
                if (property == PropertyNames.memoryValue)
                {
                    item = new GridStringItem(Messages.UPGRADE_SR_WARNING,
                                              HorizontalAlignment.Center, VerticalAlignment.Middle, false, false,
                                              QueryPanel.LinkBrush, Program.DefaultFontUnderline, QueryPanel.LinkBrush, Program.DefaultFontUnderline, 3,
                                              (sender, args) => new UpgradeSRCommand(Program.MainWindow, sr).Execute(), null);
                }

                return(true);
            }

            Pool pool = o as Pool;

            if (pool != null && !pool.IsPoolFullyUpgraded)
            {
                if (property == PropertyNames.memoryValue)
                {
                    var master = pool.Connection.Resolve(pool.master);

                    item = new GridStringItem(string.Format(Messages.POOL_VERSIONS_LINK_TEXT, master.ProductVersionText),
                                              HorizontalAlignment.Center, VerticalAlignment.Middle, false, false,
                                              QueryPanel.LinkBrush, Program.DefaultFontUnderline, QueryPanel.LinkBrush,
                                              Program.DefaultFontUnderline, 3,
                                              (sender, args) => new RollingUpgradeCommand(Program.MainWindow).Execute(),
                                              null);
                }

                return(true);
            }

            return(false);
        }
Esempio n. 5
0
        protected bool CheckVMTools(IXenObject o, out GridItemBase item)
        {
            item = null;

            if (!checkTools)
            {
                return(false);
            }

            VM vm = o as VM;

            if (vm != null)
            {
                VM.VirtualisationStatus status = vm.virtualisation_status;
                if (vm.power_state != vm_power_state.Running ||
                    status == VM.VirtualisationStatus.OPTIMIZED ||
                    status == VM.VirtualisationStatus.UNKNOWN)
                {
                    return(false);
                }

                if (property == PropertyNames.memoryValue)
                {
                    if (InstallToolsCommand.CanExecute(vm))
                    {
                        item = new GridStringItem(vm.GetVirtualisationWarningMessages(),
                                                  HorizontalAlignment.Center,
                                                  VerticalAlignment.Middle,
                                                  false,
                                                  false,
                                                  QueryPanel.LinkBrush,
                                                  Program.DefaultFontUnderline,
                                                  QueryPanel.LinkBrush,
                                                  Program.DefaultFontUnderline,
                                                  3,
                                                  new EventHandler(delegate
                        {
                            new InstallToolsCommand(Program.MainWindow.CommandInterface, vm).Execute();
                        }), null);
                    }
                    else
                    {
                        item = new GridStringItem(vm.GetVirtualisationWarningMessages(),
                                                  HorizontalAlignment.Center,
                                                  VerticalAlignment.Middle,
                                                  false,
                                                  false,
                                                  QueryPanel.TextBrush,
                                                  Program.DefaultFont,
                                                  3);
                    }
                }
                return(true);
            }

            SR sr = o as SR;

            if (sr != null && sr.NeedsUpgrading)
            {
                if (property == PropertyNames.memoryValue)
                {
                    item = new GridStringItem(Messages.UPGRADE_SR_WARNING,
                                              HorizontalAlignment.Center, VerticalAlignment.Middle, false, false,
                                              QueryPanel.LinkBrush, Program.DefaultFontUnderline, QueryPanel.LinkBrush, Program.DefaultFontUnderline, 3,
                                              new EventHandler(delegate
                    {
                        new UpgradeSRCommand(Program.MainWindow.CommandInterface, sr).Execute();
                    }), null);
                }

                return(true);
            }

            return(false);
        }