diff --git a/XenAdmin/Commands/ActivateVBDCommand.cs b/XenAdmin/Commands/ActivateVBDCommand.cs index 2328b0268..a530c4bdd 100644 --- a/XenAdmin/Commands/ActivateVBDCommand.cs +++ b/XenAdmin/Commands/ActivateVBDCommand.cs @@ -85,7 +85,7 @@ namespace XenAdmin.Commands return false; if (vdi.type == vdi_type.system) return false; - if (vm.virtualisation_status != VM.VirtualisationStatus.OPTIMIZED) + if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) return false; if (vbd.currently_attached) return false; @@ -121,9 +121,9 @@ namespace XenAdmin.Commands if (vdi.type == vdi_type.system) return Messages.TOOLTIP_DEACTIVATE_SYSVDI; - if (vm.virtualisation_status != VM.VirtualisationStatus.OPTIMIZED) + if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) return string.Format( - Messages.CANNOT_ACTIVATE_VD_VM_NEEDS_TOOLS, + vm.HasNewVirtualisationStates ? Messages.CANNOT_ACTIVATE_VD_VM_NEEDS_IO_DRIVERS : Messages.CANNOT_ACTIVATE_VD_VM_NEEDS_TOOLS, Helpers.GetName(vm).Ellipsise(50)); if (vbd.currently_attached) diff --git a/XenAdmin/Commands/DeactivateVBDCommand.cs b/XenAdmin/Commands/DeactivateVBDCommand.cs index d5f3a5bc3..3ba9de900 100644 --- a/XenAdmin/Commands/DeactivateVBDCommand.cs +++ b/XenAdmin/Commands/DeactivateVBDCommand.cs @@ -87,7 +87,7 @@ namespace XenAdmin.Commands return false; if (vdi.type == vdi_type.system && vbd.IsOwner) return false; - if (vm.virtualisation_status != VM.VirtualisationStatus.OPTIMIZED) + if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) return false; if (!vbd.currently_attached) return false; @@ -124,9 +124,9 @@ namespace XenAdmin.Commands if (vdi.type == vdi_type.system && vbd.IsOwner) return Messages.TOOLTIP_DEACTIVATE_SYSVDI; - if (vm.virtualisation_status != VM.VirtualisationStatus.OPTIMIZED) + if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) return string.Format( - Messages.CANNOT_DEACTIVATE_VDI_NEEDS_TOOLS, + vm.HasNewVirtualisationStates ? Messages.CANNOT_DEACTIVATE_VDI_NEEDS_IO_DRIVERS : Messages.CANNOT_DEACTIVATE_VDI_NEEDS_TOOLS, Helpers.GetName(vm).Ellipsise(50)); if (!vbd.currently_attached) diff --git a/XenAdmin/Commands/InstallToolsCommand.cs b/XenAdmin/Commands/InstallToolsCommand.cs index 364b0e25e..caa609a55 100644 --- a/XenAdmin/Commands/InstallToolsCommand.cs +++ b/XenAdmin/Commands/InstallToolsCommand.cs @@ -289,8 +289,8 @@ namespace XenAdmin.Commands public static bool CanExecute(VM vm) { return vm != null && !vm.is_a_template && !vm.Locked && - vm.GetVirtualisationStatus != VM.VirtualisationStatus.UNKNOWN && - vm.GetVirtualisationStatus != VM.VirtualisationStatus.OPTIMIZED && + !vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.UNKNOWN) && + (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED) || !vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) && vm.power_state == vm_power_state.Running && CanViewVMConsole(vm.Connection); } diff --git a/XenAdmin/Commands/RebootVMCommand.cs b/XenAdmin/Commands/RebootVMCommand.cs index 6502ea495..2cba7718d 100644 --- a/XenAdmin/Commands/RebootVMCommand.cs +++ b/XenAdmin/Commands/RebootVMCommand.cs @@ -198,18 +198,8 @@ namespace XenAdmin.Commands case vm_power_state.unknown: return base.GetCantExecuteReasonCore(item); } - - if (vm.virtualisation_status == VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED || vm.virtualisation_status == VM.VirtualisationStatus.UNKNOWN) - { - return FriendlyErrorNames.VM_MISSING_PV_DRIVERS; - } - - if (vm.virtualisation_status == VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE) - { - return FriendlyErrorNames.VM_OLD_PV_DRIVERS; - } - return base.GetCantExecuteReasonCore(item); + return GetCantExecuteNoToolsOrDriversReasonCore(item) ?? base.GetCantExecuteReasonCore(item); } protected override AsyncAction BuildAction(VM vm) diff --git a/XenAdmin/Commands/ResumeVMCommand.cs b/XenAdmin/Commands/ResumeVMCommand.cs index b3a911906..a5b67a52d 100644 --- a/XenAdmin/Commands/ResumeVMCommand.cs +++ b/XenAdmin/Commands/ResumeVMCommand.cs @@ -179,15 +179,8 @@ namespace XenAdmin.Commands { return Messages.VM_NOT_SUSPENDED; } - else if (vm.virtualisation_status == VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED || vm.virtualisation_status == VM.VirtualisationStatus.UNKNOWN) - { - return FriendlyErrorNames.VM_MISSING_PV_DRIVERS; - } - else if (vm.virtualisation_status == VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE) - { - return FriendlyErrorNames.VM_OLD_PV_DRIVERS; - } - return base.GetCantExecuteReasonCore(item); + + return GetCantExecuteNoToolsOrDriversReasonCore(item) ?? base.GetCantExecuteReasonCore(item); } protected override AsyncAction BuildAction(VM vm) diff --git a/XenAdmin/Commands/ShutDownVMCommand.cs b/XenAdmin/Commands/ShutDownVMCommand.cs index 8a57444a8..ba0f79d00 100644 --- a/XenAdmin/Commands/ShutDownVMCommand.cs +++ b/XenAdmin/Commands/ShutDownVMCommand.cs @@ -168,17 +168,8 @@ namespace XenAdmin.Commands case vm_power_state.unknown: return base.GetCantExecuteReasonCore(item); } - - if (vm.virtualisation_status == VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED || vm.virtualisation_status == VM.VirtualisationStatus.UNKNOWN) - { - return FriendlyErrorNames.VM_MISSING_PV_DRIVERS; - } - - if (vm.virtualisation_status == VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE) - { - return FriendlyErrorNames.VM_OLD_PV_DRIVERS; - } - return base.GetCantExecuteReasonCore(item); + + return GetCantExecuteNoToolsOrDriversReasonCore(item) ?? base.GetCantExecuteReasonCore(item); } protected override CommandErrorDialog GetErrorDialogCore(IDictionary cantExecuteReasons) diff --git a/XenAdmin/Commands/SuspendVMCommand.cs b/XenAdmin/Commands/SuspendVMCommand.cs index a2d8694cf..079a27b20 100644 --- a/XenAdmin/Commands/SuspendVMCommand.cs +++ b/XenAdmin/Commands/SuspendVMCommand.cs @@ -205,15 +205,8 @@ namespace XenAdmin.Commands { return Messages.VM_ALREADY_SUSPENDED; } - else if (vm.virtualisation_status == VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED || vm.virtualisation_status == VM.VirtualisationStatus.UNKNOWN) - { - return FriendlyErrorNames.VM_MISSING_PV_DRIVERS; - } - else if (vm.virtualisation_status == VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE) - { - return FriendlyErrorNames.VM_OLD_PV_DRIVERS; - } - return base.GetCantExecuteReasonCore(item); + + return GetCantExecuteNoToolsOrDriversReasonCore(item) ?? base.GetCantExecuteReasonCore(item); } diff --git a/XenAdmin/Commands/VMLifeCycleCommand.cs b/XenAdmin/Commands/VMLifeCycleCommand.cs index f7355f7a5..c4256df37 100644 --- a/XenAdmin/Commands/VMLifeCycleCommand.cs +++ b/XenAdmin/Commands/VMLifeCycleCommand.cs @@ -162,5 +162,29 @@ namespace XenAdmin.Commands return atLeastOneCanExecute; } + + protected string GetCantExecuteNoToolsOrDriversReasonCore(SelectedItem item) + { + VM vm = item.XenObject as VM; + if (vm == null) + return null; + + //trying to guess the reason + if (vm.HasNewVirtualisationStates) + { + if (!vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) //note: this will also be true when the enum is in Unknown state + return Messages.VM_MISSING_IO_DRIVERS; + } + else + { + if (vm.virtualisation_status == 0 || vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.UNKNOWN)) + return FriendlyErrorNames.VM_MISSING_PV_DRIVERS; + + if (vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE)) + return FriendlyErrorNames.VM_OLD_PV_DRIVERS; + } + + return null; + } } } diff --git a/XenAdmin/Controls/Ballooning/VMMemoryControlsBasic.cs b/XenAdmin/Controls/Ballooning/VMMemoryControlsBasic.cs index a99b844b4..8b20d3ee8 100644 --- a/XenAdmin/Controls/Ballooning/VMMemoryControlsBasic.cs +++ b/XenAdmin/Controls/Ballooning/VMMemoryControlsBasic.cs @@ -50,7 +50,7 @@ namespace XenAdmin.Controls.Ballooning { InitializeComponent(); } - + protected override void OnPaint(PaintEventArgs e) { if (vms == null || vms.Count == 0) @@ -100,21 +100,15 @@ namespace XenAdmin.Controls.Ballooning } if (identical) { - switch (vm0.GetVirtualisationStatus) - { - case VM.VirtualisationStatus.OPTIMIZED: - labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_NOTSUPPORTED_PLURAL; - break; - case VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED: - labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_NOTOOLS_PLURAL; - break; - case VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE: - labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_OLDTOOLS_PLURAL; - break; - default: // VM.VirtualisationStatus.UNKNOWN - labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_VMS; - break; - } + 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; @@ -127,21 +121,17 @@ namespace XenAdmin.Controls.Ballooning } else { - switch (vm0.GetVirtualisationStatus) - { - case VM.VirtualisationStatus.OPTIMIZED: + var status = vm0.GetVirtualisationStatus; + + if (status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_NOTSUPPORTED; - break; - case VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED: - labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_NOTOOLS; - break; - case VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE: + 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; - break; - default: // VM.VirtualisationStatus.UNKNOWN - labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_VM; - break; - } + else + labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_VM; + linkInstallTools.Visible = InstallToolsCommand.CanExecute(vm0); } } diff --git a/XenAdmin/Controls/Ballooning/VMMemoryControlsNoEdit.cs b/XenAdmin/Controls/Ballooning/VMMemoryControlsNoEdit.cs index 9cd611225..afc6b3ef8 100644 --- a/XenAdmin/Controls/Ballooning/VMMemoryControlsNoEdit.cs +++ b/XenAdmin/Controls/Ballooning/VMMemoryControlsNoEdit.cs @@ -75,7 +75,7 @@ namespace XenAdmin.Controls.Ballooning // So "good" VMs are ones which are halted, or running with known virtualisation status. editButton.Visible = (null == vms.Find(vm => !(vm.power_state == vm_power_state.Halted || - vm.power_state == vm_power_state.Running && vm.virtualisation_status != VM.VirtualisationStatus.UNKNOWN))); + vm.power_state == vm_power_state.Running && !vm.virtualisation_status.HasFlag(XenAPI.VM.VirtualisationStatus.UNKNOWN)))); // Shiny bar vmShinyBar.Initialize(vm0, vms.Count > 1, CalcMemoryUsed(), false); diff --git a/XenAdmin/Controls/NetworkingTab/NetworkList.cs b/XenAdmin/Controls/NetworkingTab/NetworkList.cs index 08d03f5db..457ac32d0 100644 --- a/XenAdmin/Controls/NetworkingTab/NetworkList.cs +++ b/XenAdmin/Controls/NetworkingTab/NetworkList.cs @@ -433,16 +433,16 @@ namespace XenAdmin.Controls.NetworkingTab if (vm.power_state == vm_power_state.Suspended) { RemoveButtonContainer.SetToolTip(Messages.TOOLTIP_REMOVE_NETWORK_SUSPENDED); - EditButtonContainer.SetToolTip(Messages.TOOLTIP_EDIT_NETWORK_TOOLS); + EditButtonContainer.SetToolTip(vm.HasNewVirtualisationStates ? Messages.TOOLTIP_EDIT_NETWORK_IO_DRIVERS : Messages.TOOLTIP_EDIT_NETWORK_TOOLS); toolTipContainerActivateToggle.SetToolTip(vif.currently_attached ? Messages.TOOLTIP_DEACTIVATE_VIF_SUSPENDED : Messages.TOOLTIP_ACTIVATE_VIF_SUSPENDED); } else { - if (vm.power_state == vm_power_state.Running && vm.GetVirtualisationStatus != XenAPI.VM.VirtualisationStatus.OPTIMIZED) + if (vm.power_state == vm_power_state.Running && !vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) { - RemoveButtonContainer.SetToolTip(Messages.TOOLTIP_REMOVE_NETWORK_TOOLS); - EditButtonContainer.SetToolTip(Messages.TOOLTIP_EDIT_NETWORK_TOOLS); + RemoveButtonContainer.SetToolTip(vm.HasNewVirtualisationStates ? Messages.TOOLTIP_REMOVE_NETWORK_IO_DRIVERS : Messages.TOOLTIP_REMOVE_NETWORK_TOOLS); + EditButtonContainer.SetToolTip(vm.HasNewVirtualisationStates ? Messages.TOOLTIP_EDIT_NETWORK_IO_DRIVERS : Messages.TOOLTIP_EDIT_NETWORK_TOOLS); toolTipContainerActivateToggle.SetToolTip(vif.currently_attached ? Messages.TOOLTIP_DEACTIVATE_VIF_TOOLS : Messages.TOOLTIP_ACTIVATE_VIF_TOOLS); } diff --git a/XenAdmin/Dialogs/EvacuateHostDialog.Designer.cs b/XenAdmin/Dialogs/EvacuateHostDialog.Designer.cs index df891ab32..2f2ebc5c0 100644 --- a/XenAdmin/Dialogs/EvacuateHostDialog.Designer.cs +++ b/XenAdmin/Dialogs/EvacuateHostDialog.Designer.cs @@ -44,10 +44,10 @@ namespace XenAdmin.Dialogs this.labelMasterBlurb = new System.Windows.Forms.Label(); this.panel2 = new System.Windows.Forms.Panel(); this.dataGridViewVms = new XenAdmin.Controls.DataGridViewEx.DataGridViewEx(); - this.lableWLBEnabled = new System.Windows.Forms.Label(); this.columnImage = new System.Windows.Forms.DataGridViewImageColumn(); this.columnVm = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.columnAction = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.lableWLBEnabled = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.panel2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridViewVms)).BeginInit(); @@ -164,11 +164,6 @@ namespace XenAdmin.Dialogs this.dataGridViewVms.CellMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dataGridViewVms_CellMouseClick); this.dataGridViewVms.CellMouseMove += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dataGridViewVms_CellMouseMove); // - // lableWLBEnabled - // - resources.ApplyResources(this.lableWLBEnabled, "lableWLBEnabled"); - this.lableWLBEnabled.Name = "lableWLBEnabled"; - // // columnImage // this.columnImage.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; @@ -196,6 +191,11 @@ namespace XenAdmin.Dialogs resources.ApplyResources(this.columnAction, "columnAction"); this.columnAction.Name = "columnAction"; // + // lableWLBEnabled + // + resources.ApplyResources(this.lableWLBEnabled, "lableWLBEnabled"); + this.lableWLBEnabled.Name = "lableWLBEnabled"; + // // EvacuateHostDialog // this.AcceptButton = this.EvacuateButton; diff --git a/XenAdmin/Dialogs/EvacuateHostDialog.cs b/XenAdmin/Dialogs/EvacuateHostDialog.cs index ab9707bfa..d40743760 100644 --- a/XenAdmin/Dialogs/EvacuateHostDialog.cs +++ b/XenAdmin/Dialogs/EvacuateHostDialog.cs @@ -539,13 +539,13 @@ namespace XenAdmin.Dialogs break; case Solution.InstallPVDrivers: - error = String.Format(Messages.EVACUATE_HOST_INSTALL_TOOLS_PROMPT, message); + error = String.Format(vm.HasNewVirtualisationStates ? Messages.EVACUATE_HOST_INSTALL_MGMNT_PROMPT : Messages.EVACUATE_HOST_INSTALL_TOOLS_PROMPT, message); break; case Solution.InstallPVDriversNoSolution: // if the state is not unknown we have metrics and can show a detailed message. // Otherwise go with the server and just say they aren't installed - error = vm.GetVirtualisationStatus != VM.VirtualisationStatus.UNKNOWN + error = !vm.GetVirtualisationStatus.HasFlag(XenAPI.VM.VirtualisationStatus.UNKNOWN) ? vm.GetVirtualisationWarningMessages() : Messages.PV_DRIVERS_NOT_INSTALLED; break; diff --git a/XenAdmin/Dialogs/VmSnapshotDialog.cs b/XenAdmin/Dialogs/VmSnapshotDialog.cs index e607ad272..0f6d7f2cb 100644 --- a/XenAdmin/Dialogs/VmSnapshotDialog.cs +++ b/XenAdmin/Dialogs/VmSnapshotDialog.cs @@ -151,8 +151,8 @@ namespace XenAdmin.Dialogs tt = Messages.FIELD_DISABLED; else if (_VM.power_state != vm_power_state.Running) tt = Messages.INFO_QUIESCE_MODE_POWER_STATE.Replace("\\n", "\n"); - else if (_VM.virtualisation_status != VM.VirtualisationStatus.OPTIMIZED) - tt = Messages.INFO_QUIESCE_MODE_NO_TOOLS.Replace("\\n", "\n"); + else if (!_VM.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) + tt = (_VM.HasNewVirtualisationStates ? Messages.INFO_QUIESCE_MODE_NO_MGMNT : Messages.INFO_QUIESCE_MODE_NO_TOOLS).Replace("\\n", "\n"); else tt = Messages.INFO_QUIESCE_MODE.Replace("\\n","\n"); // This says that VSS must be enabled. This is a guess, because we can't tell whether it is or not. toolTip.Show(tt ,pictureBoxQuiesceInfo, 20, 0); @@ -184,8 +184,8 @@ namespace XenAdmin.Dialogs tt = Messages.INFO_DISKMEMORY_MODE_POWER_STATE.Replace("\\n", "\n"); else if (_VM.HasVGPUs) tt = Messages.INFO_DISKMEMORY_MODE_GPU.Replace("\\n", "\n"); - else if (_VM.virtualisation_status != VM.VirtualisationStatus.OPTIMIZED) - tt = Messages.INFO_DISKMEMORY_MODE_NO_TOOLS.Replace("\\n", "\n"); + else if (!_VM.virtualisation_status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) + tt = (_VM.HasNewVirtualisationStates ? Messages.INFO_DISKMEMORY_MODE_NO_IO_DRIVERS : Messages.INFO_DISKMEMORY_MODE_NO_TOOLS).Replace("\\n", "\n"); else tt = Messages.INFO_DISKMEMORY_MODE_MISC.Replace("\\n", "\n"); toolTip.Show(tt, CheckpointInfoPictureBox, 20, 0); diff --git a/XenAdmin/SettingsPanels/EditNetworkPage.cs b/XenAdmin/SettingsPanels/EditNetworkPage.cs index 815359061..df237e523 100644 --- a/XenAdmin/SettingsPanels/EditNetworkPage.cs +++ b/XenAdmin/SettingsPanels/EditNetworkPage.cs @@ -380,7 +380,7 @@ namespace XenAdmin.SettingsPanels foreach (VIF v in network.Connection.ResolveAll(network.VIFs)) { VM vm = network.Connection.Resolve(v.VM); - if (vm.power_state != vm_power_state.Running || vm.GetVirtualisationStatus == VM.VirtualisationStatus.OPTIMIZED) + if (vm.power_state != vm_power_state.Running || vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) continue; runningVMsWithoutTools = true; diff --git a/XenAdmin/TabPages/GeneralTabPage.cs b/XenAdmin/TabPages/GeneralTabPage.cs index 7eadacf56..ba55fc2d1 100644 --- a/XenAdmin/TabPages/GeneralTabPage.cs +++ b/XenAdmin/TabPages/GeneralTabPage.cs @@ -1356,7 +1356,7 @@ namespace XenAdmin.TabPages bool canInstallManagementAgentOnly = InstallToolsCommand.CanExecute(vm) && isIoOptimized && !isManagementAgentInstalled; //canInstallIoDriversOnly is missing - management agent communicates with XS using the I/O drivers - if (vm.virtualisation_status == VM.VirtualisationStatus.UNKNOWN) + if (vm.virtualisation_status.HasFlag(XenAPI.VM.VirtualisationStatus.UNKNOWN)) { s.AddEntry(FriendlyName("VM.VirtualizationState"), vm.VirtualisationStatusString); } @@ -1434,8 +1434,7 @@ namespace XenAdmin.TabPages //for everything else (All VMs on pre-Dundee hosts & All non-Windows VMs on any host) else { - if (vm.virtualisation_status == VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED - || vm.virtualisation_status == VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE) + if (vm.virtualisation_status == 0 || vm.virtualisation_status.HasFlag(XenAPI.VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE)) { if (InstallToolsCommand.CanExecute(vm)) { diff --git a/XenAdmin/XenSearch/Columns.cs b/XenAdmin/XenSearch/Columns.cs index eecfe2970..a64722b1b 100644 --- a/XenAdmin/XenSearch/Columns.cs +++ b/XenAdmin/XenSearch/Columns.cs @@ -94,8 +94,8 @@ namespace XenAdmin.XenSearch { VM.VirtualisationStatus status = vm.virtualisation_status; if (vm.power_state != vm_power_state.Running || - status == VM.VirtualisationStatus.OPTIMIZED || - status == VM.VirtualisationStatus.UNKNOWN) + status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED ) || + status.HasFlag(VM.VirtualisationStatus.UNKNOWN)) return false; if (property == PropertyNames.memoryValue) diff --git a/XenAdminTests/CommandTests/VMLifecycleCommandTest.cs b/XenAdminTests/CommandTests/VMLifecycleCommandTest.cs index 76aa06ce3..1921f8c2b 100644 --- a/XenAdminTests/CommandTests/VMLifecycleCommandTest.cs +++ b/XenAdminTests/CommandTests/VMLifecycleCommandTest.cs @@ -188,7 +188,7 @@ namespace XenAdminTests.CommandTests { var curRow = row;//closure VM vm = curSelection.AsXenObjects().Find(v => v.Name == curRow.Cells[1].Value.ToString()); - Assert.IsFalse(vm.virtualisation_status == VM.VirtualisationStatus.OPTIMIZED, "PV drivers installed on " + vm + " but it couldn't suspend."); + Assert.IsFalse(vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED), "PV drivers installed on " + vm + " but it couldn't suspend."); } TestUtils.GetButton(dialog, "btnClose").PerformClick(); }); diff --git a/XenAdminTests/TabsAndMenus/TabsAndMenus.cs b/XenAdminTests/TabsAndMenus/TabsAndMenus.cs index b7a0b1fb6..7f51010af 100644 --- a/XenAdminTests/TabsAndMenus/TabsAndMenus.cs +++ b/XenAdminTests/TabsAndMenus/TabsAndMenus.cs @@ -302,8 +302,8 @@ namespace XenAdminTests.TabsAndMenus protected static bool HasTools(VM vm) { return !vm.is_a_template && vm.IsRunning&& - vm.virtualisation_status != VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED && - vm.virtualisation_status != VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE; + vm.virtualisation_status != 0 && + !vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE); } protected static bool NoTools(VM vm) diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index 23d40b935..e5a82b2b0 100644 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -5986,6 +5986,15 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to You must install I/O drivers on VM '{0}' before you can activate this virtual disk for the VM.. + /// + public static string CANNOT_ACTIVATE_VD_VM_NEEDS_IO_DRIVERS { + get { + return ResourceManager.GetString("CANNOT_ACTIVATE_VD_VM_NEEDS_IO_DRIVERS", resourceCulture); + } + } + /// /// Looks up a localized string similar to You must install XenServer Tools on VM '{0}' before you can activate this virtual disk for the VM.. /// @@ -6076,6 +6085,15 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to You must install I/O drivers on VM '{0}' before you can deactivate this virtual disk for the VM.. + /// + public static string CANNOT_DEACTIVATE_VDI_NEEDS_IO_DRIVERS { + get { + return ResourceManager.GetString("CANNOT_DEACTIVATE_VDI_NEEDS_IO_DRIVERS", resourceCulture); + } + } + /// /// Looks up a localized string similar to You must install XenServer Tools on VM '{0}' before you can deactivate this virtual disk for the VM.. /// @@ -10842,6 +10860,24 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to A memory range cannot be set because I/O drivers are not installed on this VM.. + /// + public static string DMC_UNAVAILABLE_NO_IO_NO_MGMNT { + get { + return ResourceManager.GetString("DMC_UNAVAILABLE_NO_IO_NO_MGMNT", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to A memory range cannot be set because I/O drivers are not installed on these VMs.. + /// + public static string DMC_UNAVAILABLE_NO_IO_NO_MGMNT_PLURAL { + get { + return ResourceManager.GetString("DMC_UNAVAILABLE_NO_IO_NO_MGMNT_PLURAL", resourceCulture); + } + } + /// /// Looks up a localized string similar to A memory range cannot be set because XenServer Tools are not installed on this VM.. /// @@ -13564,6 +13600,15 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to {0} Install Management Agent. + /// + public static string EVACUATE_HOST_INSTALL_MGMNT_PROMPT { + get { + return ResourceManager.GetString("EVACUATE_HOST_INSTALL_MGMNT_PROMPT", resourceCulture); + } + } + /// /// Looks up a localized string similar to {0} Install XenServer Tools. /// @@ -18165,6 +18210,15 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to Disk and memory snapshots need I/O drivers to be installed. + /// + public static string INFO_DISKMEMORY_MODE_NO_IO_DRIVERS { + get { + return ResourceManager.GetString("INFO_DISKMEMORY_MODE_NO_IO_DRIVERS", resourceCulture); + } + } + /// /// Looks up a localized string similar to Disk and memory snapshots need XenServer Tools to be installed. /// @@ -18192,6 +18246,15 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to Quiesced snapshots need Management Agent to be installed. + /// + public static string INFO_QUIESCE_MODE_NO_MGMNT { + get { + return ResourceManager.GetString("INFO_QUIESCE_MODE_NO_MGMNT", resourceCulture); + } + } + /// /// Looks up a localized string similar to Quiesced snapshots need XenServer Tools to be installed. /// @@ -32012,6 +32075,15 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to I/O drivers must be installed to edit a network on a running VM. + /// + public static string TOOLTIP_EDIT_NETWORK_IO_DRIVERS { + get { + return ResourceManager.GetString("TOOLTIP_EDIT_NETWORK_IO_DRIVERS", resourceCulture); + } + } + /// /// Looks up a localized string similar to XenServer Tools must be installed to edit a network on a running VM. /// @@ -32048,6 +32120,15 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to I/O drivers must be installed to remove a network on a running VM. + /// + public static string TOOLTIP_REMOVE_NETWORK_IO_DRIVERS { + get { + return ResourceManager.GetString("TOOLTIP_REMOVE_NETWORK_IO_DRIVERS", resourceCulture); + } + } + /// /// Looks up a localized string similar to Networks cannot be removed from suspended VMs. /// @@ -34406,6 +34487,15 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to I/O drivers and Management Agent installed. + /// + public static string VIRTUALIZATION_STATE_VM_IO_DRIVERS_AND_MANAGEMENT_AGENT_INSTALLED { + get { + return ResourceManager.GetString("VIRTUALIZATION_STATE_VM_IO_DRIVERS_AND_MANAGEMENT_AGENT_INSTALLED", resourceCulture); + } + } + /// /// Looks up a localized string similar to I/O not optimized. /// @@ -34730,6 +34820,15 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to I/O drivers not installed.. + /// + public static string VM_MISSING_IO_DRIVERS { + get { + return ResourceManager.GetString("VM_MISSING_IO_DRIVERS", resourceCulture); + } + } + /// /// Looks up a localized string similar to A&ctivate. /// diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index b8977f80e..fe70ef790 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -2173,6 +2173,9 @@ Deleting this bond will disrupt traffic through the secondary interface on the b It is not possible to activate this virtual disk on VM '{0}' as the VM is not running. + + You must install I/O drivers on VM '{0}' before you can activate this virtual disk for the VM. + You must install XenServer Tools on VM '{0}' before you can activate this virtual disk for the VM. @@ -2203,6 +2206,9 @@ Deleting this bond will disrupt traffic through the secondary interface on the b This virtual disk is in use and cannot be deactivated. + + You must install I/O drivers on VM '{0}' before you can deactivate this virtual disk for the VM. + You must install XenServer Tools on VM '{0}' before you can deactivate this virtual disk for the VM. @@ -3857,6 +3863,12 @@ This will also delete its subfolders. A memory range cannot be set because the operating systems on these VMs do not support it. + + A memory range cannot be set because I/O drivers are not installed on this VM. + + + A memory range cannot be set because I/O drivers are not installed on these VMs. + A memory range cannot be set because XenServer Tools are out of date on this VM. @@ -4761,6 +4773,9 @@ Would you like to eject these ISOs before continuing? {0} Eject the CD + + {0} Install Management Agent + {0} Install XenServer Tools @@ -6321,6 +6336,9 @@ Click Configure HA to alter the settings displayed below. Disk and memory snapshots are not currently available for this VM + + Disk and memory snapshots need I/O drivers to be installed + Disk and memory snapshots need XenServer Tools to be installed @@ -6333,6 +6351,9 @@ Click Configure HA to alter the settings displayed below. Quiesced snapshots need the VSS service to be enabled on the VM + + Quiesced snapshots need Management Agent to be installed + Quiesced snapshots need XenServer Tools to be installed @@ -11088,6 +11109,9 @@ Refer to the "XenServer Administrator's Guide" for instructions on how to manual Disks cannot be removed from running VMs without XenServer Tools installed + + I/O drivers must be installed to edit a network on a running VM + XenServer Tools must be installed to edit a network on a running VM @@ -11100,6 +11124,9 @@ Refer to the "XenServer Administrator's Guide" for instructions on how to manual XenServer only supports {0} NICs per Bond. + + I/O drivers must be installed to remove a network on a running VM + Networks cannot be removed from suspended VMs @@ -11904,6 +11931,9 @@ To learn more about the XenServer Dynamic Workload Balancing feature or to start Install Management Agent + + I/O drivers and Management Agent installed + I/O not optimized @@ -12036,6 +12066,9 @@ To learn more about the XenServer Dynamic Workload Balancing feature or to start VM General Changes + + I/O drivers not installed. + A&ctivate diff --git a/XenModel/XenAPI-Extensions/VM.cs b/XenModel/XenAPI-Extensions/VM.cs index 0da74efde..b28938df8 100644 --- a/XenModel/XenAPI-Extensions/VM.cs +++ b/XenModel/XenAPI-Extensions/VM.cs @@ -683,7 +683,13 @@ namespace XenAPI private Timer VirtualizationTimer = null; [Flags] - public enum VirtualisationStatus { UNKNOWN = 0, OPTIMIZED = 1, PV_DRIVERS_NOT_INSTALLED = 2, PV_DRIVERS_OUT_OF_DATE = 4 }; + public enum VirtualisationStatus + { + UNKNOWN = 1, + PV_DRIVERS_OUT_OF_DATE = 2, + IO_DRIVERS_INSTALLED = 4, + MANAGEMENT_INSTALLED = 8, + }; public VirtualisationStatus virtualisation_status { @@ -710,14 +716,13 @@ namespace XenAPI { VirtualisationStatus status = GetVirtualisationStatus; - switch (status) - { - case VirtualisationStatus.OPTIMIZED: - case VirtualisationStatus.UNKNOWN: + if (virtualisation_status.HasFlag(VirtualisationStatus.IO_DRIVERS_INSTALLED) && virtualisation_status.HasFlag(VirtualisationStatus.MANAGEMENT_INSTALLED) + || virtualisation_status.HasFlag(VM.VirtualisationStatus.UNKNOWN)) // calling function shouldn't send us here if tools are, or might be, present: used to assert here but it can sometimes happen (CA-51460) return ""; - case VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE: + if (virtualisation_status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE)) + { VM_guest_metrics guestMetrics = Connection.Resolve(guest_metrics); if (guestMetrics != null && guestMetrics.PV_drivers_version.ContainsKey("major") @@ -729,12 +734,91 @@ namespace XenAPI } else return Messages.PV_DRIVERS_OUT_OF_DATE_UNKNOWN_VERSION; + } - default: // VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED: - return Messages.PV_DRIVERS_NOT_INSTALLED; + return HasNewVirtualisationStates ? Messages.VIRTUALIZATION_STATE_VM_MANAGEMENT_AGENT_NOT_INSTALLED : Messages.PV_DRIVERS_NOT_INSTALLED; + } + + private VirtualisationStatus GetVirtualisationStatusOldVM + { + get + { + Debug.Assert(!HasNewVirtualisationStates); + + VM_guest_metrics vm_guest_metrics = Connection.Resolve(guest_metrics); + + if ((DateTime.UtcNow - BodgeStartupTime).TotalMinutes < 2) + { + // check to see if the metrics object has appeared, if so cancel the timer, no need to notify the property changed as this should be picked up on vm_guest_metrics being created. + if (vm_guest_metrics != null && vm_guest_metrics.PV_drivers_installed) + { + if (vm_guest_metrics.PV_drivers_up_to_date) + return VirtualisationStatus.IO_DRIVERS_INSTALLED | VirtualisationStatus.MANAGEMENT_INSTALLED; + else + return VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE; + } + + return VirtualisationStatus.UNKNOWN; + } + + if (vm_guest_metrics == null || !vm_guest_metrics.PV_drivers_installed) + { + return 0; + } + else if (!vm_guest_metrics.PV_drivers_up_to_date) + { + return VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE; + } + else + { + return VirtualisationStatus.IO_DRIVERS_INSTALLED | VirtualisationStatus.MANAGEMENT_INSTALLED; + } } } + private VirtualisationStatus GetVirtualisationStatusNewVM + { + get + { + Debug.Assert(HasNewVirtualisationStates); + + var flags = HasRDP ? VirtualisationStatus.MANAGEMENT_INSTALLED : 0; + + var vm_guest_metrics = Connection.Resolve(guest_metrics); + if (vm_guest_metrics != null && vm_guest_metrics.storage_paths_optimized && vm_guest_metrics.network_paths_optimized) + flags |= VirtualisationStatus.IO_DRIVERS_INSTALLED; + + if ((DateTime.UtcNow - BodgeStartupTime).TotalMinutes < 2) + { + if (flags.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) + return flags; + + return VirtualisationStatus.UNKNOWN; + } + + return flags; + } + } + + /// + /// Virtualization Status of the VM + /// + /// + /// + /// Following states are expected: + /// + /// For Non-Windows VMs and for Windows VMs pre-Dundee: + /// 0 = Not installed + /// 1 = Unknown + /// 2 = Out of date + /// 12 = Tools installed (Optimized) + /// + /// For Windows VMs on Dundee or higher: + /// 0 = Not installed + /// 1 = Unknown + /// 4 = I/O Optimized + /// 12 = I/O and Management installed + /// public VirtualisationStatus GetVirtualisationStatus { get @@ -748,38 +832,24 @@ namespace XenAPI return VirtualisationStatus.UNKNOWN; } - VM_guest_metrics vm_guest_metrics = Connection.Resolve(guest_metrics); - - if ((DateTime.UtcNow - BodgeStartupTime).TotalMinutes < 2) - { - // check to see if the metrics object has appeared, if so cancel the timer, no need to notify the property changed as this should be picked up on vm_guest_metrics being created. - if (vm_guest_metrics != null && vm_guest_metrics.PV_drivers_installed) - { - if (vm_guest_metrics.PV_drivers_up_to_date) - return VirtualisationStatus.OPTIMIZED; - else - return VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE; - } - - return VirtualisationStatus.UNKNOWN; - } - - if (vm_guest_metrics == null || !vm_guest_metrics.PV_drivers_installed) - { - return VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED; - } - else if (!vm_guest_metrics.PV_drivers_up_to_date) - { - return VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE; - } - else - { - return VirtualisationStatus.OPTIMIZED; - } - + return HasNewVirtualisationStates ? GetVirtualisationStatusNewVM : GetVirtualisationStatusOldVM; } } + /// + /// Is this a Windows VM on Dundee or higher host? + /// We need to know this, because for those VMs virtualization status is defined differently. + /// This does not mean new(ly created) VM + /// + public bool HasNewVirtualisationStates + { + get + { + return IsWindows && XenAdmin.Core.Helpers.DundeeOrGreater(Connection); + } + } + + /// /// Does this VM support ballooning? I.e., are tools installed, on a ballonable OS? /// Doesn't check for Midnight Ride or licensing constraints. @@ -1461,17 +1531,25 @@ namespace XenAPI { get { - switch (virtualisation_status) + if (virtualisation_status.HasFlag(VirtualisationStatus.IO_DRIVERS_INSTALLED | VirtualisationStatus.MANAGEMENT_INSTALLED)) { - case VM.VirtualisationStatus.OPTIMIZED: + if (!HasNewVirtualisationStates) return string.Format(Messages.VIRTUALIZATION_OPTIMIZED, VirtualisationVersion); - case VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE: - return string.Format(Messages.VIRTUALIZATION_OUT_OF_DATE, VirtualisationVersion); - case VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED: - return Messages.PV_DRIVERS_NOT_INSTALLED; - default: - return Messages.VIRTUALIZATION_UNKNOWN; + else + return Messages.VIRTUALIZATION_STATE_VM_IO_DRIVERS_AND_MANAGEMENT_AGENT_INSTALLED; } + + if (virtualisation_status.HasFlag(VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE)) + return string.Format(Messages.VIRTUALIZATION_OUT_OF_DATE, VirtualisationVersion); + + if (virtualisation_status == 0) + return Messages.PV_DRIVERS_NOT_INSTALLED; + + if (virtualisation_status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED) + && !virtualisation_status.HasFlag(VirtualisationStatus.MANAGEMENT_INSTALLED)) + return Messages.VIRTUALIZATION_STATE_VM_MANAGEMENT_AGENT_NOT_INSTALLED; + + return Messages.VIRTUALIZATION_UNKNOWN; } } diff --git a/XenModel/XenSearch/Common.cs b/XenModel/XenSearch/Common.cs index 41d7d577b..ee5a9dd85 100644 --- a/XenModel/XenSearch/Common.cs +++ b/XenModel/XenSearch/Common.cs @@ -230,11 +230,14 @@ namespace XenAdmin.XenSearch foreach (SR.SRTypes type in Enum.GetValues(typeof(SR.SRTypes))) SRType_i18n[SR.getFriendlyTypeName(type)] = type; - VirtualisationStatus_i18n[Messages.OPTIMIZED] = VM.VirtualisationStatus.OPTIMIZED; - VirtualisationStatus_i18n[Messages.PV_DRIVERS_NOT_INSTALLED] = VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED; + VirtualisationStatus_i18n[Messages.PV_DRIVERS_NOT_INSTALLED] = 0; VirtualisationStatus_i18n[Messages.OUT_OF_DATE] = VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE; VirtualisationStatus_i18n[Messages.UNKNOWN] = VM.VirtualisationStatus.UNKNOWN; + VirtualisationStatus_i18n[Messages.VIRTUALIZATION_STATE_VM_IO_OPTIMIZED] = VM.VirtualisationStatus.IO_DRIVERS_INSTALLED; + VirtualisationStatus_i18n[Messages.VIRTUALIZATION_STATE_VM_MANAGEMENT_AGENT_INSTALLED] = VM.VirtualisationStatus.MANAGEMENT_INSTALLED; + VirtualisationStatus_i18n[Messages.VIRTUALIZATION_STATE_VM_IO_DRIVERS_AND_MANAGEMENT_AGENT_INSTALLED] = VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_INSTALLED; + ObjectTypes_i18n[Messages.VMS] = ObjectTypes.VM; ObjectTypes_i18n[Messages.XENSERVER_TEMPLATES] = ObjectTypes.DefaultTemplate; ObjectTypes_i18n[Messages.CUSTOM_TEMPLATES] = ObjectTypes.UserTemplate; @@ -646,7 +649,7 @@ namespace XenAdmin.XenSearch vm.power_state != vm_power_state.Running) return null; - if (vm.virtualisation_status != VM.VirtualisationStatus.OPTIMIZED) + if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) return null; return PropertyAccessorHelper.vmMemoryUsageString(vm); @@ -680,7 +683,7 @@ namespace XenAdmin.XenSearch vm.power_state != vm_power_state.Running) return null; - if (vm.virtualisation_status != VM.VirtualisationStatus.OPTIMIZED) + if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) return null; return PropertyAccessorHelper.vmMemoryUsageRank(vm); @@ -714,7 +717,7 @@ namespace XenAdmin.XenSearch vm.power_state != vm_power_state.Running) return null; - if (vm.virtualisation_status != VM.VirtualisationStatus.OPTIMIZED) + if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) return null; return PropertyAccessorHelper.vmMemoryUsageValue(vm); @@ -748,7 +751,7 @@ namespace XenAdmin.XenSearch vm.power_state != vm_power_state.Running) return null; - if (vm.virtualisation_status != VM.VirtualisationStatus.OPTIMIZED) + if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) return null; return PropertyAccessorHelper.vmNetworkUsageString(vm); @@ -775,7 +778,7 @@ namespace XenAdmin.XenSearch if (vm.power_state != vm_power_state.Running) return null; - if (vm.virtualisation_status != VM.VirtualisationStatus.OPTIMIZED) + if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) return null; return PropertyAccessorHelper.vmDiskUsageString(vm); @@ -1370,20 +1373,13 @@ namespace XenAdmin.XenSearch case PropertyNames.virtualisation_status: return (ImageDelegate)delegate(VM.VirtualisationStatus status) { - switch (status) - { - case VM.VirtualisationStatus.OPTIMIZED: - return Icons.ToolInstalled; + if (status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) + return Icons.ToolInstalled; - case VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED: - return Icons.ToolsNotInstalled; + if (status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE)) + return Icons.ToolsOutOfDate; - case VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE: - return Icons.ToolsOutOfDate; - - default: - return Icons.ToolsNotInstalled; - } + return Icons.ToolsNotInstalled; }; case PropertyNames.sr_type: diff --git a/XenModel/XenSearch/GroupingTypes.cs b/XenModel/XenSearch/GroupingTypes.cs index 455f352e1..4e19fec83 100644 --- a/XenModel/XenSearch/GroupingTypes.cs +++ b/XenModel/XenSearch/GroupingTypes.cs @@ -36,6 +36,7 @@ using XenAdmin.Model; using XenAPI; using System.Xml; using XenAdmin.Core; +using System.Diagnostics; namespace XenAdmin.XenSearch @@ -277,7 +278,9 @@ namespace XenAdmin.XenSearch public override String GetGroupName(Object group) { - if (!(group is T) || i18ns == null) + Debug.Assert(i18ns == null || i18ns.ContainsKey((T)group)); //if i18ns is specified, it should contain an item for the group + + if (!(group is T) || i18ns == null || !i18ns.ContainsKey((T)group)) return base.GetGroupName(group); return i18ns[(T)group]; diff --git a/XenModel/XenSearch/Search.cs b/XenModel/XenSearch/Search.cs index 7f28313cb..95cd57103 100644 --- a/XenModel/XenSearch/Search.cs +++ b/XenModel/XenSearch/Search.cs @@ -815,7 +815,7 @@ namespace XenAdmin.XenSearch new GroupQuery( new QueryFilter[] { new EnumPropertyQuery(PropertyNames.power_state, vm_power_state.Running, true), - new EnumPropertyQuery(PropertyNames.virtualisation_status, VM.VirtualisationStatus.OPTIMIZED, false) + new EnumPropertyQuery(PropertyNames.virtualisation_status, VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_INSTALLED, false) }, GroupQuery.GroupQueryType.And)), new PropertyGrouping(PropertyNames.virtualisation_status, null), false, Messages.DEFAULT_SEARCH_VMS_WO_XS_TOOLS, "dead-beef-1234-vmswotools", true