コード例 #1
0
            public AsyncAction Solve()
            {
                AsyncAction a = null;

                switch (solution)
                {
                case Solution.EjectCD:
                    a = new ChangeVMISOAction(vm.Connection, vm, null, vm.FindVMCDROM());
                    dialog.SetSession(a);
                    dialog.DoAction(a);
                    break;

                case Solution.Suspend:
                    a = new VMSuspendAction(vm);
                    dialog.SetSession(a);
                    dialog.DoAction(a);
                    break;

                case Solution.InstallPVDrivers:
                    a = new InstallToolsCommand(Program.MainWindow, vm).ExecuteGetAction();
                    // The install pv tools action is marked as complete after they have taken the user to the console and loaded the disc
                    // Rescanning when the action is 'complete' in this case doesn't gain us anything then. Keep showing the "Click here to install PV drivers" text.
                    dialog.SetSession(a);
                    solutionAction = a;
                    return(a);
                }
                solutionAction = a;
                solution       = Solution.None;
                // we show this, then register an event handler on the action completed to re-update the text/solution
                this.error = Messages.EVACUATE_SOLUTION_IN_PROGRESS;
                return(a);
            }
コード例 #2
0
ファイル: EvacuateHostDialog.cs プロジェクト: ywscr/xenadmin
        private void UpdateVMWithError(string[] errorDescription, string vmRef = null)
        {
            if (errorDescription.Length == 0)
            {
                return;
            }

            Solution solution;
            string   error = "";

            switch (errorDescription[0])
            {
            case Failure.VM_REQUIRES_SR:
                vmRef = errorDescription[1];
                SR sr = connection.Resolve(new XenRef <SR>(errorDescription[2]));

                if (sr != null && sr.content_type == SR.Content_Type_ISO)
                {
                    error    = Messages.EVACUATE_HOST_LOCAL_CD;
                    solution = Solution.EjectCD;
                }
                else
                {
                    error    = Messages.EVACUATE_HOST_LOCAL_STORAGE;
                    solution = CanSuspendVm(vmRef) ? Solution.Suspend : Solution.Shutdown;
                }
                break;

            case Failure.VM_MISSING_PV_DRIVERS:
                vmRef = errorDescription[1];
                VM vm = connection.Resolve(new XenRef <VM>(vmRef));
                solution = InstallToolsCommand.CanExecute(vm) && !Helpers.StockholmOrGreater(connection)
                        ? Solution.InstallPVDrivers
                        : Solution.InstallPVDriversNoSolution;
                break;

            case Failure.HA_NO_PLAN:
                dataGridViewVms.Rows.Cast <VmPrecheckRow>().ToList().ForEach(r =>
                                                                             r.SetError("", CanSuspendVm(r.vm.opaque_ref) ? Solution.Suspend : Solution.Shutdown));
                return;     //exit the method

            case Failure.HOST_NOT_ENOUGH_FREE_MEMORY:
            case Failure.VM_FAILED_SHUTDOWN_ACKNOWLEDGMENT:
                vmRef    = errorDescription[1];
                solution = CanSuspendVm(vmRef) ? Solution.Suspend : Solution.Shutdown;
                break;

            default:
                solution = CanSuspendVm(vmRef) ? Solution.Suspend : Solution.Shutdown;
                break;
            }

            var row = dataGridViewVms.Rows.Cast <VmPrecheckRow>().FirstOrDefault(r => r.vm.opaque_ref == vmRef);

            row?.SetError(error, solution);
        }
コード例 #3
0
        private void InstallTools_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            if (vms.All(v => Helpers.StockholmOrGreater(v.Connection)))
            {
                Help.HelpManager.Launch("InstallToolsWarningDialog");
                return;
            }

            var cmd = new InstallToolsCommand(Program.MainWindow, vms);

            cmd.InstallTools += _ => InstallTools?.Invoke();
            cmd.Execute();
        }
コード例 #4
0
ファイル: EvacuateHostDialog.cs プロジェクト: ywscr/xenadmin
        private void dataGridViewVms_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex >= 0 && e.RowIndex < dataGridViewVms.RowCount &&
                e.ColumnIndex == columnAction.Index &&
                dataGridViewVms.Rows[e.RowIndex] is VmPrecheckRow row && row.HasSolution())
            {
                AsyncAction action = null;
                switch (row.Solution)
                {
                case Solution.EjectCD:
                    action = new ChangeVMISOAction(row.vm.Connection, row.vm, null, row.vm.FindVMCDROM());
                    break;

                case Solution.Suspend:
                    action = new VMSuspendAction(row.vm);
                    break;

                case Solution.Shutdown:
                    action = new VMHardShutdown(row.vm);
                    break;

                case Solution.InstallPVDrivers:
                    var cmd = new InstallToolsCommand(Program.MainWindow, row.vm, dataGridViewVms);
                    cmd.Execute();
                    // The install pv tools action is marked as complete after they have taken the user to the
                    // console and loaded the disc. Rescanning when the action is 'complete' in this case
                    // doesn't gain us anything then. Keep showing the "Click here to install PV drivers" text.
                    return;
                }

                if (action != null)
                {
                    action.Completed += a => Rebuild();
                    action.RunAsync(GetSudoElevationResult());
                }
                //set this after starting the action so that the row is updated correctly
                row.SolutionAction = action;
            }
        }
コード例 #5
0
ファイル: EvacuateHostDialog.cs プロジェクト: ywwseu/xenadmin
        private void ProcessError(String vmRef, String[] ErrorDescription)
        {
            try
            {
                if (ErrorDescription.Length == 0)
                {
                    return;
                }

                switch (ErrorDescription[0])
                {
                case Failure.VM_REQUIRES_SR:
                    vmRef = ErrorDescription[1];
                    SR sr = connection.Resolve(new XenRef <SR>(ErrorDescription[2]));
                    if (sr == null)
                    {
                        return;
                    }

                    if (sr.content_type == SR.Content_Type_ISO)
                    {
                        UpdateVMWithError(vmRef, Messages.EVACUATE_HOST_LOCAL_CD, Solution.EjectCD);
                    }
                    else
                    {
                        UpdateVMWithError(vmRef, Messages.EVACUATE_HOST_LOCAL_STORAGE, CanSuspendVm(vmRef) ? Solution.Suspend : Solution.Shutdown);
                    }

                    break;

                case Failure.VM_MISSING_PV_DRIVERS:
                    vmRef = ErrorDescription[1];

                    VM vm = connection.Resolve(new XenRef <VM>(vmRef));
                    if (vm != null && InstallToolsCommand.CanExecute(vm))
                    {
                        UpdateVMWithError(vmRef, String.Empty, Solution.InstallPVDrivers);
                    }
                    else
                    {
                        UpdateVMWithError(vmRef, String.Empty, Solution.InstallPVDriversNoSolution);
                    }

                    break;

                case Failure.HOST_NOT_ENOUGH_FREE_MEMORY:
                    if (vmRef == null)
                    {
                        using (var dlg = new ThreeButtonDialog(
                                   new ThreeButtonDialog.Details(
                                       SystemIcons.Error,
                                       Messages.EVACUATE_HOST_NOT_ENOUGH_MEMORY,
                                       Messages.EVACUATE_HOST_NOT_ENOUGH_MEMORY_TITLE)))
                        {
                            dlg.ShowDialog(this);
                        }
                    }

                    vmRef = ErrorDescription[1];
                    UpdateVMWithError(vmRef, String.Empty, CanSuspendVm(vmRef) ? Solution.Suspend : Solution.Shutdown);

                    break;

                case Failure.HA_NO_PLAN:

                    foreach (string _vmRef in vms.Keys)
                    {
                        UpdateVMWithError(_vmRef, String.Empty, CanSuspendVm(_vmRef) ? Solution.Suspend : Solution.Shutdown);
                    }

                    if (vmRef == null)
                    {
                        using (var dlg = new ThreeButtonDialog(
                                   new ThreeButtonDialog.Details(
                                       SystemIcons.Error,
                                       Messages.EVACUATE_HOST_NO_OTHER_HOSTS,
                                       Messages.EVACUATE_HOST_NO_OTHER_HOSTS_TITLE)))
                        {
                            dlg.ShowDialog(this);
                        }
                    }

                    break;

                case Failure.VM_FAILED_SHUTDOWN_ACKNOWLEDGMENT:
                    if (ErrorDescription.Length > 1)
                    {
                        vmRef = ErrorDescription[1];
                    }
                    AddDefaultSuspendOperation(vmRef);
                    break;

                default:
                    AddDefaultSuspendOperation(vmRef);
                    break;
                }
            }
            catch (Exception e)
            {
                log.Debug("Exception processing exception", e);
                log.Debug(e, e);

                AddDefaultSuspendOperation(vmRef);
            }
        }
コード例 #6
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;
        }
コード例 #7
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);
        }
コード例 #8
0
ファイル: Columns.cs プロジェクト: zhaoyingpu/xenadmin
        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);
        }
コード例 #9
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;
        }
コード例 #10
0
ファイル: Columns.cs プロジェクト: heiden-deng/xenadmin
        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);
        }