From 463d3e79df2afb8dda337c821d7c9c09cc238031 Mon Sep 17 00:00:00 2001 From: Gabor Apati-Nagy Date: Wed, 9 Sep 2015 13:56:11 +0100 Subject: [PATCH 01/11] CP-13786: PV drivers onto Windows update: Check all uses of GetVirtualisationStatus Extended the enum, aimed for minimal changes, also using Flags on the enum now Signed-off-by: Gabor Apati-Nagy Signed-off-by: Gabor Apati-Nagy --- XenAdmin/Commands/ActivateVBDCommand.cs | 4 +- XenAdmin/Commands/DeactivateVBDCommand.cs | 4 +- XenAdmin/Commands/InstallToolsCommand.cs | 4 +- XenAdmin/Commands/RebootVMCommand.cs | 9 +- XenAdmin/Commands/ResumeVMCommand.cs | 8 +- XenAdmin/Commands/ShutDownVMCommand.cs | 12 +- XenAdmin/Commands/SuspendVMCommand.cs | 8 +- .../Ballooning/VMMemoryControlsNoEdit.cs | 2 +- .../Controls/NetworkingTab/NetworkList.cs | 2 +- .../Controls/XenSearch/GroupingControl.cs | 2 +- XenAdmin/Controls/XenSearch/QueryElement.cs | 2 +- XenAdmin/Dialogs/EvacuateHostDialog.cs | 2 +- XenAdmin/Dialogs/VmSnapshotDialog.cs | 4 +- XenAdmin/SettingsPanels/EditNetworkPage.cs | 2 +- XenAdmin/TabPages/GeneralTabPage.cs | 6 +- XenAdmin/XenSearch/Columns.cs | 4 +- .../CommandTests/VMLifecycleCommandTest.cs | 2 +- XenAdminTests/TabsAndMenus/TabsAndMenus.cs | 4 +- XenModel/Messages.Designer.cs | 25 ++-- XenModel/Messages.resx | 24 ++-- XenModel/XenAPI-Extensions/VM.cs | 118 ++++++++++++++---- XenModel/XenSearch/Common.cs | 46 ++++--- XenModel/XenSearch/Search.cs | 4 +- 23 files changed, 199 insertions(+), 99 deletions(-) diff --git a/XenAdmin/Commands/ActivateVBDCommand.cs b/XenAdmin/Commands/ActivateVBDCommand.cs index 2328b0268..c82728602 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,7 +121,7 @@ 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, Helpers.GetName(vm).Ellipsise(50)); diff --git a/XenAdmin/Commands/DeactivateVBDCommand.cs b/XenAdmin/Commands/DeactivateVBDCommand.cs index d5f3a5bc3..8a4625ac9 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,7 +124,7 @@ 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, Helpers.GetName(vm).Ellipsise(50)); diff --git a/XenAdmin/Commands/InstallToolsCommand.cs b/XenAdmin/Commands/InstallToolsCommand.cs index 364b0e25e..804d6096c 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.OPTIMIZED) || !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..cca09b3cf 100644 --- a/XenAdmin/Commands/RebootVMCommand.cs +++ b/XenAdmin/Commands/RebootVMCommand.cs @@ -198,17 +198,20 @@ 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) + + if (vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED) || vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.UNKNOWN)) { return FriendlyErrorNames.VM_MISSING_PV_DRIVERS; } - if (vm.virtualisation_status == VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE) + if (vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE)) { return FriendlyErrorNames.VM_OLD_PV_DRIVERS; } + if (!vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) + return Messages.VM_MISSING_IO_DRIVERS; + return base.GetCantExecuteReasonCore(item); } diff --git a/XenAdmin/Commands/ResumeVMCommand.cs b/XenAdmin/Commands/ResumeVMCommand.cs index b3a911906..c516de608 100644 --- a/XenAdmin/Commands/ResumeVMCommand.cs +++ b/XenAdmin/Commands/ResumeVMCommand.cs @@ -179,14 +179,18 @@ 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) + else if (vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED) || vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.UNKNOWN)) { return FriendlyErrorNames.VM_MISSING_PV_DRIVERS; } - else if (vm.virtualisation_status == VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE) + else if (vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE)) { return FriendlyErrorNames.VM_OLD_PV_DRIVERS; } + + if (!vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) + return Messages.VM_MISSING_IO_DRIVERS; + return base.GetCantExecuteReasonCore(item); } diff --git a/XenAdmin/Commands/ShutDownVMCommand.cs b/XenAdmin/Commands/ShutDownVMCommand.cs index 8a57444a8..48e83b529 100644 --- a/XenAdmin/Commands/ShutDownVMCommand.cs +++ b/XenAdmin/Commands/ShutDownVMCommand.cs @@ -168,16 +168,20 @@ 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) + + if (vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED) || vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.UNKNOWN)) { return FriendlyErrorNames.VM_MISSING_PV_DRIVERS; } - - if (vm.virtualisation_status == VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE) + + if (vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE)) { return FriendlyErrorNames.VM_OLD_PV_DRIVERS; } + + if (!vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) + return Messages.VM_MISSING_IO_DRIVERS; + return base.GetCantExecuteReasonCore(item); } diff --git a/XenAdmin/Commands/SuspendVMCommand.cs b/XenAdmin/Commands/SuspendVMCommand.cs index a2d8694cf..ffa380bdd 100644 --- a/XenAdmin/Commands/SuspendVMCommand.cs +++ b/XenAdmin/Commands/SuspendVMCommand.cs @@ -205,14 +205,18 @@ 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) + else if (vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED) || vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.UNKNOWN)) { return FriendlyErrorNames.VM_MISSING_PV_DRIVERS; } - else if (vm.virtualisation_status == VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE) + if (vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE)) { return FriendlyErrorNames.VM_OLD_PV_DRIVERS; } + + if (!vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) + return Messages.VM_MISSING_IO_DRIVERS; + return base.GetCantExecuteReasonCore(item); } 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..9aa1331f0 100644 --- a/XenAdmin/Controls/NetworkingTab/NetworkList.cs +++ b/XenAdmin/Controls/NetworkingTab/NetworkList.cs @@ -439,7 +439,7 @@ namespace XenAdmin.Controls.NetworkingTab } 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.OPTIMIZED)) { RemoveButtonContainer.SetToolTip(Messages.TOOLTIP_REMOVE_NETWORK_TOOLS); EditButtonContainer.SetToolTip(Messages.TOOLTIP_EDIT_NETWORK_TOOLS); diff --git a/XenAdmin/Controls/XenSearch/GroupingControl.cs b/XenAdmin/Controls/XenSearch/GroupingControl.cs index a8fc20e74..2c690b853 100644 --- a/XenAdmin/Controls/XenSearch/GroupingControl.cs +++ b/XenAdmin/Controls/XenSearch/GroupingControl.cs @@ -70,7 +70,7 @@ namespace XenAdmin.Controls.XenSearch potentialGroups.Add(hostGroup); potentialGroups.Add(new PropertyGroupingType(ObjectTypes.VM, PropertyNames.os_name)); potentialGroups.Add(new PropertyGroupingType(ObjectTypes.VM, PropertyNames.power_state)); - potentialGroups.Add(new PropertyGroupingType(ObjectTypes.VM, PropertyNames.virtualisation_status)); + potentialGroups.Add(new PropertyGroupingType(ObjectTypes.VM, PropertyNames.virtualisation_status_for_search)); potentialGroups.Add(new PropertyGroupingType(ObjectTypes.AllExcFolders, PropertyNames.type)); potentialGroups.Add(new XenModelObjectPropertyGroupingType(ObjectTypes.VM, PropertyNames.networks, poolGroup)); XenModelObjectPropertyGroupingType srGroup = diff --git a/XenAdmin/Controls/XenSearch/QueryElement.cs b/XenAdmin/Controls/XenSearch/QueryElement.cs index 2074c3c49..deb4b878e 100644 --- a/XenAdmin/Controls/XenSearch/QueryElement.cs +++ b/XenAdmin/Controls/XenSearch/QueryElement.cs @@ -74,7 +74,7 @@ namespace XenAdmin.Controls.XenSearch queryTypes.Add(new IPAddressQueryType(3, ObjectTypes.VM | ObjectTypes.Server | ObjectTypes.LocalSR | ObjectTypes.RemoteSR, PropertyNames.ip_address)); queryTypes.Add(new DatePropertyQueryType(3, ObjectTypes.VM, PropertyNames.start_time)); queryTypes.Add(new EnumPropertyQueryType(3, ObjectTypes.VM, PropertyNames.power_state)); - queryTypes.Add(new EnumPropertyQueryType(3, ObjectTypes.VM, PropertyNames.virtualisation_status)); + queryTypes.Add(new EnumPropertyQueryType(3, ObjectTypes.VM, PropertyNames.virtualisation_status_for_search)); queryTypes.Add(new ValuePropertyQueryType(3, ObjectTypes.VM, PropertyNames.os_name)); queryTypes.Add(new EnumPropertyQueryType(3, ObjectTypes.VM, PropertyNames.ha_restart_priority)); queryTypes.Add(new BooleanQueryType(3, ObjectTypes.VM, PropertyNames.read_caching_enabled)); diff --git a/XenAdmin/Dialogs/EvacuateHostDialog.cs b/XenAdmin/Dialogs/EvacuateHostDialog.cs index ab9707bfa..64ee50af9 100644 --- a/XenAdmin/Dialogs/EvacuateHostDialog.cs +++ b/XenAdmin/Dialogs/EvacuateHostDialog.cs @@ -545,7 +545,7 @@ namespace XenAdmin.Dialogs 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..f4dfa8359 100644 --- a/XenAdmin/Dialogs/VmSnapshotDialog.cs +++ b/XenAdmin/Dialogs/VmSnapshotDialog.cs @@ -151,7 +151,7 @@ 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) + else if (!_VM.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.OPTIMIZED)) tt = 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. @@ -184,7 +184,7 @@ 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) + else if (!_VM.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.OPTIMIZED)) tt = Messages.INFO_DISKMEMORY_MODE_NO_TOOLS.Replace("\\n", "\n"); else tt = Messages.INFO_DISKMEMORY_MODE_MISC.Replace("\\n", "\n"); diff --git a/XenAdmin/SettingsPanels/EditNetworkPage.cs b/XenAdmin/SettingsPanels/EditNetworkPage.cs index 815359061..612996753 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.OPTIMIZED)) continue; runningVMsWithoutTools = true; diff --git a/XenAdmin/TabPages/GeneralTabPage.cs b/XenAdmin/TabPages/GeneralTabPage.cs index 20db79881..58b37f9db 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,8 @@ 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.HasFlag(XenAPI.VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED) + || 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..194aa935f 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) + vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.OPTIMIZED) || + 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..20fb12f0a 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.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.OPTIMIZED), "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..314b6d803 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.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED) && + !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 7c990df91..097759099 100644 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -5968,7 +5968,7 @@ namespace XenAdmin { } /// - /// 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.. + /// Looks up a localized string similar to You must install XenServer Tools or the I/O drivers on VM '{0}' before you can activate this virtual disk for the VM.. /// public static string CANNOT_ACTIVATE_VD_VM_NEEDS_TOOLS { get { @@ -6058,7 +6058,7 @@ namespace XenAdmin { } /// - /// 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.. + /// Looks up a localized string similar to You must install XenServer Tools or the I/O drivers on VM '{0}' before you can deactivate this virtual disk for the VM.. /// public static string CANNOT_DEACTIVATE_VDI_NEEDS_TOOLS { get { @@ -10824,7 +10824,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to A memory range cannot be set because XenServer Tools are not installed on this VM.. + /// Looks up a localized string similar to A memory range cannot be set because XenServer Tools or I/O drivers and Management Agent are not installed on this VM.. /// public static string DMC_UNAVAILABLE_NOTOOLS { get { @@ -10869,7 +10869,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to A memory range cannot be set because XenServer Tools are out of date on these VMs.. + /// Looks up a localized string similar to A memory range cannot be set because XenServer Tools or I/O drivers and Management Agent are out of date on these VMs.. /// public static string DMC_UNAVAILABLE_OLDTOOLS_PLURAL { get { @@ -18147,7 +18147,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to Disk and memory snapshots need XenServer Tools to be installed. + /// Looks up a localized string similar to Disk and memory snapshots need XenServer Tools or I/O drivers to be installed. /// public static string INFO_DISKMEMORY_MODE_NO_TOOLS { get { @@ -18174,7 +18174,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to Quiesced snapshots need XenServer Tools to be installed. + /// Looks up a localized string similar to Quiesced snapshots need XenServer Tools or I/O drivers and Management Agent to be installed. /// public static string INFO_QUIESCE_MODE_NO_TOOLS { get { @@ -31995,7 +31995,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to XenServer Tools must be installed to edit a network on a running VM. + /// Looks up a localized string similar to XenServer Tools or the I/O drivers must be installed to edit a network on a running VM. /// public static string TOOLTIP_EDIT_NETWORK_TOOLS { get { @@ -32040,7 +32040,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to XenServer Tools must be installed to remove a network on a running VM. + /// Looks up a localized string similar to XenServer Tools or the I/O drivers must be installed to remove a network on a running VM. /// public static string TOOLTIP_REMOVE_NETWORK_TOOLS { get { @@ -34712,6 +34712,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 b3f55467c..0fc1bce3f 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -2167,7 +2167,8 @@ 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 XenServer Tools on VM '{0}' before you can activate this virtual disk for the VM. + You must install XenServer Tools or the I/O drivers on VM '{0}' before you can activate this virtual disk for the VM. + Tools or I/O (The network's MTU cannot be changed as it is in use as the management interface '{0}') @@ -2197,7 +2198,8 @@ 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 XenServer Tools on VM '{0}' before you can deactivate this virtual disk for the VM. + You must install XenServer Tools or the I/O drivers on VM '{0}' before you can deactivate this virtual disk for the VM. + Tools or I/O It is not possible to deactivate this virtual disk on VM '{0}' as the VM is not running. @@ -3839,7 +3841,7 @@ This will also delete its subfolders. Only dismiss &visible - A memory range cannot be set because XenServer Tools are not installed on this VM. + A memory range cannot be set because XenServer Tools or I/O drivers and Management Agent are not installed on this VM. A memory range cannot be set because XenServer Tools are not installed on these VMs. @@ -3854,7 +3856,7 @@ This will also delete its subfolders. A memory range cannot be set because XenServer Tools are out of date on this VM. - A memory range cannot be set because XenServer Tools are out of date on these VMs. + A memory range cannot be set because XenServer Tools or I/O drivers and Management Agent are out of date on these VMs. A memory range cannot be set for this template. @@ -6315,7 +6317,7 @@ 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 XenServer Tools to be installed + Disk and memory snapshots need XenServer Tools or I/O drivers to be installed Disk and memory snapshots need the VM to be running @@ -6327,7 +6329,8 @@ Click Configure HA to alter the settings displayed below. Quiesced snapshots need the VSS service to be enabled on the VM - Quiesced snapshots need XenServer Tools to be installed + Quiesced snapshots need XenServer Tools or I/O drivers and Management Agent to be installed + needs both I/O drivers and Management Agent Quiesced snapshots need the VM to be running @@ -11083,7 +11086,8 @@ Refer to the "XenServer Administrator's Guide" for instructions on how to manual Disks cannot be removed from running VMs without XenServer Tools installed - XenServer Tools must be installed to edit a network on a running VM + XenServer Tools or the I/O drivers must be installed to edit a network on a running VM + Tools or I/O drivers Default templates support a maximum of {0} networks at VM creation @@ -11098,7 +11102,8 @@ Refer to the "XenServer Administrator's Guide" for instructions on how to manual Networks cannot be removed from suspended VMs - XenServer Tools must be installed to remove a network on a running VM + XenServer Tools or the I/O drivers must be installed to remove a network on a running VM + Tools or I/O drivers This network cannot be removed because it is a physical device @@ -12030,6 +12035,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..9a6860a05 100644 --- a/XenModel/XenAPI-Extensions/VM.cs +++ b/XenModel/XenAPI-Extensions/VM.cs @@ -683,7 +683,15 @@ 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, + OPTIMIZED = 1 << 1, + PV_DRIVERS_NOT_INSTALLED = 1 << 2, + PV_DRIVERS_OUT_OF_DATE = 1 << 3, + IO_DRIVERS_INSTALLED = 1 << 4, + MANAGEMENT_INSTALLED = 1 << 5, + }; public VirtualisationStatus virtualisation_status { @@ -693,6 +701,28 @@ namespace XenAPI } } + public VirtualisationStatus virtualisation_status_for_search + { + get + { + var status = virtualisation_status; + + if (status.HasFlag(VirtualisationStatus.UNKNOWN)) + return VirtualisationStatus.UNKNOWN; + + if (status.HasFlag(VirtualisationStatus.OPTIMIZED)) + return VirtualisationStatus.OPTIMIZED; + + if (status.HasFlag(VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED)) + return VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED; + + if (status.HasFlag(VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE)) + return VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE; + + return VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED; + } + } + public string VirtualisationVersion { get @@ -710,14 +740,12 @@ namespace XenAPI { VirtualisationStatus status = GetVirtualisationStatus; - switch (status) - { - case VirtualisationStatus.OPTIMIZED: - case VirtualisationStatus.UNKNOWN: + if (virtualisation_status.HasFlag(VirtualisationStatus.OPTIMIZED) || 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,10 +757,12 @@ namespace XenAPI } else return Messages.PV_DRIVERS_OUT_OF_DATE_UNKNOWN_VERSION; - - default: // VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED: - 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 IsNewVM ? Messages.VIRTUALIZATION_STATE_VM_MANAGEMENT_AGENT_NOT_INSTALLED : Messages.PV_DRIVERS_NOT_INSTALLED; } public VirtualisationStatus GetVirtualisationStatus @@ -756,9 +786,13 @@ namespace XenAPI if (vm_guest_metrics != null && vm_guest_metrics.PV_drivers_installed) { if (vm_guest_metrics.PV_drivers_up_to_date) - return VirtualisationStatus.OPTIMIZED; + { + return VirtualisationStatus.OPTIMIZED | VirtualisationStatus.IO_DRIVERS_INSTALLED | VirtualisationStatus.MANAGEMENT_INSTALLED; + } else - return VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE; + { + return VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE | GetNewVirtualisationFlags(); + } } return VirtualisationStatus.UNKNOWN; @@ -766,20 +800,55 @@ namespace XenAPI if (vm_guest_metrics == null || !vm_guest_metrics.PV_drivers_installed) { - return VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED; + return VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED | GetNewVirtualisationFlags(); } else if (!vm_guest_metrics.PV_drivers_up_to_date) { - return VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE; + return VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE | GetNewVirtualisationFlags(); } else { - return VirtualisationStatus.OPTIMIZED; + if (!IsNewVM) + return VirtualisationStatus.OPTIMIZED; + else + return GetNewVirtualisationFlags(); } } } + private VirtualisationStatus GetNewVirtualisationFlags() + { + var flags = new VirtualisationStatus(); + if (IsNewVM) + { + 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 (flags.HasFlag(VirtualisationStatus.IO_DRIVERS_INSTALLED) && flags.HasFlag(VirtualisationStatus.MANAGEMENT_INSTALLED)) + flags |= VirtualisationStatus.OPTIMIZED; + + return flags; + } + + /// + /// 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 + /// + private bool IsNewVM + { + 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 +1530,20 @@ namespace XenAPI { get { - switch (virtualisation_status) - { - case VM.VirtualisationStatus.OPTIMIZED: - return string.Format(Messages.VIRTUALIZATION_OPTIMIZED, VirtualisationVersion); - case VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE: + if (virtualisation_status.HasFlag(VirtualisationStatus.OPTIMIZED)) + return string.Format(Messages.VIRTUALIZATION_OPTIMIZED, VirtualisationVersion); + + if (virtualisation_status.HasFlag(VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE)) return string.Format(Messages.VIRTUALIZATION_OUT_OF_DATE, VirtualisationVersion); - case VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED: + + if (virtualisation_status.HasFlag(VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED)) return Messages.PV_DRIVERS_NOT_INSTALLED; - default: - return Messages.VIRTUALIZATION_UNKNOWN; - } + + 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..7d66b7669 100644 --- a/XenModel/XenSearch/Common.cs +++ b/XenModel/XenSearch/Common.cs @@ -112,7 +112,7 @@ namespace XenAdmin.XenSearch [HelpString("The VM power state, e.g. Halted, Running")] power_state, [HelpString("The state of the pure virtualization drivers installed on a VM")] - virtualisation_status, + virtualisation_status_for_search, [HelpString("Date and time that the VM was started")] start_time, [HelpString("The HA restart priority of the VM")] @@ -234,7 +234,7 @@ namespace XenAdmin.XenSearch VirtualisationStatus_i18n[Messages.PV_DRIVERS_NOT_INSTALLED] = VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED; VirtualisationStatus_i18n[Messages.OUT_OF_DATE] = VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE; VirtualisationStatus_i18n[Messages.UNKNOWN] = VM.VirtualisationStatus.UNKNOWN; - + ObjectTypes_i18n[Messages.VMS] = ObjectTypes.VM; ObjectTypes_i18n[Messages.XENSERVER_TEMPLATES] = ObjectTypes.DefaultTemplate; ObjectTypes_i18n[Messages.CUSTOM_TEMPLATES] = ObjectTypes.UserTemplate; @@ -273,7 +273,7 @@ namespace XenAdmin.XenSearch PropertyNames_i18n[PropertyNames.storage] = Messages.SR; PropertyNames_i18n[PropertyNames.disks] = Messages.VIRTUAL_DISK; PropertyNames_i18n[PropertyNames.type] = Messages.TYPE; - PropertyNames_i18n[PropertyNames.virtualisation_status] = Messages.TOOLS_STATUS; + PropertyNames_i18n[PropertyNames.virtualisation_status_for_search] = Messages.TOOLS_STATUS; PropertyNames_i18n[PropertyNames.ha_restart_priority] = Messages.HA_RESTART_PRIORITY; PropertyNames_i18n[PropertyNames.appliance] = Messages.VM_APPLIANCE; PropertyNames_i18n[PropertyNames.tags] = Messages.TAGS; @@ -327,7 +327,7 @@ namespace XenAdmin.XenSearch property_types.Add(PropertyNames.host, typeof(Host)); property_types.Add(PropertyNames.os_name, typeof(string)); property_types.Add(PropertyNames.power_state, typeof(vm_power_state)); - property_types.Add(PropertyNames.virtualisation_status, typeof(VM.VirtualisationStatus)); + property_types.Add(PropertyNames.virtualisation_status_for_search, typeof(VM.VirtualisationStatus)); property_types.Add(PropertyNames.type, typeof(ObjectTypes)); property_types.Add(PropertyNames.networks, typeof(XenAPI.Network)); property_types.Add(PropertyNames.storage, typeof(SR)); @@ -416,11 +416,11 @@ namespace XenAdmin.XenSearch return vm.power_state; }); }; - properties[PropertyNames.virtualisation_status] = delegate(IXenObject o) + properties[PropertyNames.virtualisation_status_for_search] = delegate(IXenObject o) { return GetForRealVM(o, delegate(VM vm, IXenConnection conn) { - return vm.GetVirtualisationStatus; + return vm.virtualisation_status_for_search; }); }; properties[PropertyNames.start_time] = delegate(IXenObject o) @@ -646,7 +646,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.OPTIMIZED)) return null; return PropertyAccessorHelper.vmMemoryUsageString(vm); @@ -680,7 +680,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.OPTIMIZED)) return null; return PropertyAccessorHelper.vmMemoryUsageRank(vm); @@ -714,7 +714,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.OPTIMIZED)) return null; return PropertyAccessorHelper.vmMemoryUsageValue(vm); @@ -748,7 +748,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.OPTIMIZED)) return null; return PropertyAccessorHelper.vmNetworkUsageString(vm); @@ -775,7 +775,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.OPTIMIZED)) return null; return PropertyAccessorHelper.vmDiskUsageString(vm); @@ -1295,7 +1295,7 @@ namespace XenAdmin.XenSearch case PropertyNames.type: return ObjectTypes_i18n; - case PropertyNames.virtualisation_status: + case PropertyNames.virtualisation_status_for_search: return VirtualisationStatus_i18n; case PropertyNames.power_state: @@ -1367,23 +1367,19 @@ namespace XenAdmin.XenSearch return Icons.XenCenter; }; - case PropertyNames.virtualisation_status: + case PropertyNames.virtualisation_status_for_search: return (ImageDelegate)delegate(VM.VirtualisationStatus status) { - switch (status) - { - case VM.VirtualisationStatus.OPTIMIZED: - return Icons.ToolInstalled; + if (status == VM.VirtualisationStatus.OPTIMIZED) + return Icons.ToolInstalled; - case VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED: - return Icons.ToolsNotInstalled; + if (status == VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED || status != VM.VirtualisationStatus.MANAGEMENT_INSTALLED) + return Icons.ToolsNotInstalled; - case VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE: - return Icons.ToolsOutOfDate; - - default: - return Icons.ToolsNotInstalled; - } + if (status == VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE) + return Icons.ToolsOutOfDate; + + return Icons.ToolsNotInstalled; }; case PropertyNames.sr_type: diff --git a/XenModel/XenSearch/Search.cs b/XenModel/XenSearch/Search.cs index 7f28313cb..aed80040f 100644 --- a/XenModel/XenSearch/Search.cs +++ b/XenModel/XenSearch/Search.cs @@ -815,9 +815,9 @@ 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_for_search, VM.VirtualisationStatus.OPTIMIZED, false) }, GroupQuery.GroupQueryType.And)), - new PropertyGrouping(PropertyNames.virtualisation_status, null), + new PropertyGrouping(PropertyNames.virtualisation_status_for_search, null), false, Messages.DEFAULT_SEARCH_VMS_WO_XS_TOOLS, "dead-beef-1234-vmswotools", true ); From 6ec748c9b2760d9482d1be29379f2a07673c1259 Mon Sep 17 00:00:00 2001 From: Gabor Apati-Nagy Date: Wed, 9 Sep 2015 18:30:45 +0100 Subject: [PATCH 02/11] CP-13786: Fixed Install Tools link does not appear bug Signed-off-by: Gabor Apati-Nagy --- XenAdmin/Commands/InstallToolsCommand.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/XenAdmin/Commands/InstallToolsCommand.cs b/XenAdmin/Commands/InstallToolsCommand.cs index 804d6096c..fa7f73f82 100644 --- a/XenAdmin/Commands/InstallToolsCommand.cs +++ b/XenAdmin/Commands/InstallToolsCommand.cs @@ -289,7 +289,7 @@ namespace XenAdmin.Commands public static bool CanExecute(VM vm) { return vm != null && !vm.is_a_template && !vm.Locked && - vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.UNKNOWN) && + !vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.UNKNOWN) && (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.OPTIMIZED) || !vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) && vm.power_state == vm_power_state.Running && CanViewVMConsole(vm.Connection); From f98e22936f3873f6ad7b820a8391aeef3f9e5b4b Mon Sep 17 00:00:00 2001 From: Gabor Apati-Nagy Date: Thu, 10 Sep 2015 14:55:04 +0100 Subject: [PATCH 03/11] CP-13786: GetVirtualisationStatus: Some changes after rubber duck debugging Signed-off-by: Gabor Apati-Nagy --- XenModel/Messages.Designer.cs | 18 ++++++++++++++++++ XenModel/Messages.resx | 6 ++++++ XenModel/XenAPI-Extensions/VM.cs | 23 ++++++++++++++++------- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index 097759099..f2dcd8f7b 100644 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -34388,6 +34388,24 @@ 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 drivers and Management Agent not installed. + /// + public static string VIRTUALIZATION_STATE_VM_IO_DRIVERS_AND_MANAGEMENT_AGENT_NOT_INSTALLED { + get { + return ResourceManager.GetString("VIRTUALIZATION_STATE_VM_IO_DRIVERS_AND_MANAGEMENT_AGENT_NOT_INSTALLED", resourceCulture); + } + } + /// /// Looks up a localized string similar to I/O not optimized. /// diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index 0fc1bce3f..d995274e7 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -11903,6 +11903,12 @@ 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 drivers and Management Agent not installed + I/O not optimized diff --git a/XenModel/XenAPI-Extensions/VM.cs b/XenModel/XenAPI-Extensions/VM.cs index 9a6860a05..3ea8ab625 100644 --- a/XenModel/XenAPI-Extensions/VM.cs +++ b/XenModel/XenAPI-Extensions/VM.cs @@ -666,6 +666,7 @@ namespace XenAPI startuptime = value; // This has an impact on the virt state of the VM as we allow a set amount of time for tools to show up before assuming unvirt NotifyPropertyChanged("virtualisation_status"); + NotifyPropertyChanged("virtualisation_status_for_search"); if (VirtualizationTimer != null) VirtualizationTimer.Stop(); // 2 minutes before we give up plus some breathing space @@ -678,6 +679,7 @@ namespace XenAPI void VirtualizationTimer_Elapsed(object sender, ElapsedEventArgs e) { NotifyPropertyChanged("virtualisation_status"); + NotifyPropertyChanged("virtualisation_status_for_search"); } private Timer VirtualizationTimer = null; @@ -740,7 +742,8 @@ namespace XenAPI { VirtualisationStatus status = GetVirtualisationStatus; - if (virtualisation_status.HasFlag(VirtualisationStatus.OPTIMIZED) || virtualisation_status.HasFlag(VM.VirtualisationStatus.UNKNOWN)) + if (virtualisation_status.HasFlag(VirtualisationStatus.OPTIMIZED) + || 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 ""; @@ -759,10 +762,11 @@ namespace XenAPI return Messages.PV_DRIVERS_OUT_OF_DATE_UNKNOWN_VERSION; } - if (virtualisation_status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED) && !virtualisation_status.HasFlag(VirtualisationStatus.MANAGEMENT_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 IsNewVM ? Messages.VIRTUALIZATION_STATE_VM_MANAGEMENT_AGENT_NOT_INSTALLED : Messages.PV_DRIVERS_NOT_INSTALLED; + return IsNewVM ? Messages.VIRTUALIZATION_STATE_VM_IO_DRIVERS_AND_MANAGEMENT_AGENT_NOT_INSTALLED : Messages.PV_DRIVERS_NOT_INSTALLED; } public VirtualisationStatus GetVirtualisationStatus @@ -1531,19 +1535,24 @@ namespace XenAPI get { if (virtualisation_status.HasFlag(VirtualisationStatus.OPTIMIZED)) - return string.Format(Messages.VIRTUALIZATION_OPTIMIZED, VirtualisationVersion); - + { + if (!IsNewVM) + return string.Format(Messages.VIRTUALIZATION_OPTIMIZED, VirtualisationVersion); + 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.HasFlag(VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED)) return Messages.PV_DRIVERS_NOT_INSTALLED; - if (virtualisation_status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED) && !virtualisation_status.HasFlag(VirtualisationStatus.MANAGEMENT_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; - } } From 371f6bdb000d6a9cba56da82205d9b3b6a797845 Mon Sep 17 00:00:00 2001 From: Gabor Apati-Nagy Date: Mon, 14 Sep 2015 16:21:44 +0100 Subject: [PATCH 04/11] CP-13786: VM.VirtualisationStatus: Changes following the code review Removed Optimized state and using I/O & Management instead (even for old VMs) Changed messages to be different for old and new VMs instead of saying Tools or I/O drivers for instance Removed the extra enum property from the VM class that had been added for search Fixed code in GroupingTypes class (possible KeyNotFoundException) Signed-off-by: Gabor Apati-Nagy --- XenAdmin/Commands/ActivateVBDCommand.cs | 2 +- XenAdmin/Commands/DeactivateVBDCommand.cs | 2 +- XenAdmin/Commands/InstallToolsCommand.cs | 2 +- .../Ballooning/VMMemoryControlsBasic.cs | 46 ++++----- .../Controls/NetworkingTab/NetworkList.cs | 8 +- .../Controls/XenSearch/GroupingControl.cs | 2 +- XenAdmin/Controls/XenSearch/QueryElement.cs | 2 +- XenAdmin/Dialogs/VmSnapshotDialog.cs | 8 +- XenAdmin/SettingsPanels/EditNetworkPage.cs | 2 +- XenAdmin/XenSearch/Columns.cs | 2 +- .../CommandTests/VMLifecycleCommandTest.cs | 2 +- XenModel/Messages.Designer.cs | 95 +++++++++++++++---- XenModel/Messages.resx | 46 ++++++--- XenModel/XenAPI-Extensions/VM.cs | 52 +++------- XenModel/XenSearch/Common.cs | 36 +++---- XenModel/XenSearch/GroupingTypes.cs | 2 +- XenModel/XenSearch/Search.cs | 4 +- 17 files changed, 179 insertions(+), 134 deletions(-) diff --git a/XenAdmin/Commands/ActivateVBDCommand.cs b/XenAdmin/Commands/ActivateVBDCommand.cs index c82728602..a530c4bdd 100644 --- a/XenAdmin/Commands/ActivateVBDCommand.cs +++ b/XenAdmin/Commands/ActivateVBDCommand.cs @@ -123,7 +123,7 @@ namespace XenAdmin.Commands 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 8a4625ac9..3ba9de900 100644 --- a/XenAdmin/Commands/DeactivateVBDCommand.cs +++ b/XenAdmin/Commands/DeactivateVBDCommand.cs @@ -126,7 +126,7 @@ namespace XenAdmin.Commands 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 fa7f73f82..caa609a55 100644 --- a/XenAdmin/Commands/InstallToolsCommand.cs +++ b/XenAdmin/Commands/InstallToolsCommand.cs @@ -290,7 +290,7 @@ namespace XenAdmin.Commands { return vm != null && !vm.is_a_template && !vm.Locked && !vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.UNKNOWN) && - (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.OPTIMIZED) || !vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) && + (!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/Controls/Ballooning/VMMemoryControlsBasic.cs b/XenAdmin/Controls/Ballooning/VMMemoryControlsBasic.cs index a99b844b4..8cbc38de7 100644 --- a/XenAdmin/Controls/Ballooning/VMMemoryControlsBasic.cs +++ b/XenAdmin/Controls/Ballooning/VMMemoryControlsBasic.cs @@ -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 | VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) + labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_NOTSUPPORTED_PLURAL; + else if (status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED)) + labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_NOTOOLS_PLURAL; + else if (status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE)) + labelDMCUnavailable.Text = vm0.HasNewVirtualisationStates ? Messages.DMC_UNAVAILABLE_NO_IO_NO_MGMNT_PLURAL : 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 | VM.VirtualisationStatus.MANAGEMENT_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.PV_DRIVERS_NOT_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/NetworkingTab/NetworkList.cs b/XenAdmin/Controls/NetworkingTab/NetworkList.cs index 9aa1331f0..52d15fc95 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.HasFlag(VM.VirtualisationStatus.OPTIMIZED)) + if (vm.power_state == vm_power_state.Running && !vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_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/Controls/XenSearch/GroupingControl.cs b/XenAdmin/Controls/XenSearch/GroupingControl.cs index 2c690b853..a8fc20e74 100644 --- a/XenAdmin/Controls/XenSearch/GroupingControl.cs +++ b/XenAdmin/Controls/XenSearch/GroupingControl.cs @@ -70,7 +70,7 @@ namespace XenAdmin.Controls.XenSearch potentialGroups.Add(hostGroup); potentialGroups.Add(new PropertyGroupingType(ObjectTypes.VM, PropertyNames.os_name)); potentialGroups.Add(new PropertyGroupingType(ObjectTypes.VM, PropertyNames.power_state)); - potentialGroups.Add(new PropertyGroupingType(ObjectTypes.VM, PropertyNames.virtualisation_status_for_search)); + potentialGroups.Add(new PropertyGroupingType(ObjectTypes.VM, PropertyNames.virtualisation_status)); potentialGroups.Add(new PropertyGroupingType(ObjectTypes.AllExcFolders, PropertyNames.type)); potentialGroups.Add(new XenModelObjectPropertyGroupingType(ObjectTypes.VM, PropertyNames.networks, poolGroup)); XenModelObjectPropertyGroupingType srGroup = diff --git a/XenAdmin/Controls/XenSearch/QueryElement.cs b/XenAdmin/Controls/XenSearch/QueryElement.cs index deb4b878e..2074c3c49 100644 --- a/XenAdmin/Controls/XenSearch/QueryElement.cs +++ b/XenAdmin/Controls/XenSearch/QueryElement.cs @@ -74,7 +74,7 @@ namespace XenAdmin.Controls.XenSearch queryTypes.Add(new IPAddressQueryType(3, ObjectTypes.VM | ObjectTypes.Server | ObjectTypes.LocalSR | ObjectTypes.RemoteSR, PropertyNames.ip_address)); queryTypes.Add(new DatePropertyQueryType(3, ObjectTypes.VM, PropertyNames.start_time)); queryTypes.Add(new EnumPropertyQueryType(3, ObjectTypes.VM, PropertyNames.power_state)); - queryTypes.Add(new EnumPropertyQueryType(3, ObjectTypes.VM, PropertyNames.virtualisation_status_for_search)); + queryTypes.Add(new EnumPropertyQueryType(3, ObjectTypes.VM, PropertyNames.virtualisation_status)); queryTypes.Add(new ValuePropertyQueryType(3, ObjectTypes.VM, PropertyNames.os_name)); queryTypes.Add(new EnumPropertyQueryType(3, ObjectTypes.VM, PropertyNames.ha_restart_priority)); queryTypes.Add(new BooleanQueryType(3, ObjectTypes.VM, PropertyNames.read_caching_enabled)); diff --git a/XenAdmin/Dialogs/VmSnapshotDialog.cs b/XenAdmin/Dialogs/VmSnapshotDialog.cs index f4dfa8359..ea8daea80 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.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.OPTIMIZED)) - tt = Messages.INFO_QUIESCE_MODE_NO_TOOLS.Replace("\\n", "\n"); + else if (!_VM.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) + tt = (_VM.HasNewVirtualisationStates ? Messages.INFO_QUIESCE_MODE_NO_IO_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.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.OPTIMIZED)) - tt = Messages.INFO_DISKMEMORY_MODE_NO_TOOLS.Replace("\\n", "\n"); + else if (!_VM.virtualisation_status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_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 612996753..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.HasFlag(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/XenSearch/Columns.cs b/XenAdmin/XenSearch/Columns.cs index 194aa935f..59e8283dc 100644 --- a/XenAdmin/XenSearch/Columns.cs +++ b/XenAdmin/XenSearch/Columns.cs @@ -94,7 +94,7 @@ namespace XenAdmin.XenSearch { VM.VirtualisationStatus status = vm.virtualisation_status; if (vm.power_state != vm_power_state.Running || - vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.OPTIMIZED) || + status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_INSTALLED) || status.HasFlag(VM.VirtualisationStatus.UNKNOWN)) return false; diff --git a/XenAdminTests/CommandTests/VMLifecycleCommandTest.cs b/XenAdminTests/CommandTests/VMLifecycleCommandTest.cs index 20fb12f0a..cb562f02b 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.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.OPTIMIZED), "PV drivers installed on " + vm + " but it couldn't suspend."); + Assert.IsFalse(vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED) && vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED), "PV drivers installed on " + vm + " but it couldn't suspend."); } TestUtils.GetButton(dialog, "btnClose").PerformClick(); }); diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index f2dcd8f7b..e46bc2bde 100644 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -5968,7 +5968,16 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to You must install XenServer Tools or the I/O drivers on VM '{0}' before you can activate this virtual disk for the VM.. + /// Looks up a localized string similar to You must install the 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.. /// public static string CANNOT_ACTIVATE_VD_VM_NEEDS_TOOLS { get { @@ -6058,7 +6067,16 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to You must install XenServer Tools or the I/O drivers on VM '{0}' before you can deactivate this virtual disk for the VM.. + /// Looks up a localized string similar to You must install the 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.. /// public static string CANNOT_DEACTIVATE_VDI_NEEDS_TOOLS { get { @@ -10824,7 +10842,25 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to A memory range cannot be set because XenServer Tools or I/O drivers and Management Agent are not installed on this VM.. + /// Looks up a localized string similar to A memory range cannot be set because I/O drivers and Management Agent 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 and Management Agent 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.. /// public static string DMC_UNAVAILABLE_NOTOOLS { get { @@ -18147,7 +18183,16 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to Disk and memory snapshots need XenServer Tools or I/O drivers to be installed. + /// 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. /// public static string INFO_DISKMEMORY_MODE_NO_TOOLS { get { @@ -18174,7 +18219,16 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to Quiesced snapshots need XenServer Tools or I/O drivers and Management Agent to be installed. + /// Looks up a localized string similar to Quiesced snapshots need I/O drivers and Management Agent to be installed. + /// + public static string INFO_QUIESCE_MODE_NO_IO_MGMNT { + get { + return ResourceManager.GetString("INFO_QUIESCE_MODE_NO_IO_MGMNT", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Quiesced snapshots need XenServer Tools to be installed. /// public static string INFO_QUIESCE_MODE_NO_TOOLS { get { @@ -31995,7 +32049,16 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to XenServer Tools or the I/O drivers must be installed to edit a network on a running VM. + /// 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. /// public static string TOOLTIP_EDIT_NETWORK_TOOLS { get { @@ -32030,6 +32093,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. /// @@ -32040,7 +32112,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to XenServer Tools or the I/O drivers must be installed to remove a network on a running VM. + /// Looks up a localized string similar to XenServer Tools must be installed to remove a network on a running VM. /// public static string TOOLTIP_REMOVE_NETWORK_TOOLS { get { @@ -34397,15 +34469,6 @@ namespace XenAdmin { } } - /// - /// Looks up a localized string similar to I/O drivers and Management Agent not installed. - /// - public static string VIRTUALIZATION_STATE_VM_IO_DRIVERS_AND_MANAGEMENT_AGENT_NOT_INSTALLED { - get { - return ResourceManager.GetString("VIRTUALIZATION_STATE_VM_IO_DRIVERS_AND_MANAGEMENT_AGENT_NOT_INSTALLED", resourceCulture); - } - } - /// /// Looks up a localized string similar to I/O not optimized. /// diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index d995274e7..b82052cb6 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -2166,9 +2166,11 @@ 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 the I/O drivers on VM '{0}' before you can activate this virtual disk for the VM. + - You must install XenServer Tools or the I/O drivers on VM '{0}' before you can activate this virtual disk for the VM. - Tools or I/O + You must install XenServer Tools on VM '{0}' before you can activate this virtual disk for the VM. (The network's MTU cannot be changed as it is in use as the management interface '{0}') @@ -2197,9 +2199,11 @@ 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 the I/O drivers on VM '{0}' before you can deactivate this virtual disk for the VM. + - You must install XenServer Tools or the I/O drivers on VM '{0}' before you can deactivate this virtual disk for the VM. - Tools or I/O + You must install XenServer Tools on VM '{0}' before you can deactivate this virtual disk for the VM. It is not possible to deactivate this virtual disk on VM '{0}' as the VM is not running. @@ -3841,7 +3845,7 @@ This will also delete its subfolders. Only dismiss &visible - A memory range cannot be set because XenServer Tools or I/O drivers and Management Agent are not installed on this VM. + A memory range cannot be set because XenServer Tools are not installed on this VM. A memory range cannot be set because XenServer Tools are not installed on these VMs. @@ -3852,6 +3856,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 and Management Agent are not installed on this VM. + + + A memory range cannot be set because I/O drivers and Management Agent are not installed on these VMs. + A memory range cannot be set because XenServer Tools are out of date on this VM. @@ -6316,8 +6326,11 @@ 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 or I/O drivers to be installed + Disk and memory snapshots need XenServer Tools to be installed Disk and memory snapshots need the VM to be running @@ -6328,9 +6341,11 @@ Click Configure HA to alter the settings displayed below. Quiesced snapshots need the VSS service to be enabled on the VM + + Quiesced snapshots need I/O drivers and Management Agent to be installed + - Quiesced snapshots need XenServer Tools or I/O drivers and Management Agent to be installed - needs both I/O drivers and Management Agent + Quiesced snapshots need XenServer Tools to be installed Quiesced snapshots need the VM to be running @@ -11085,9 +11100,11 @@ 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 or the I/O drivers must be installed to edit a network on a running VM - Tools or I/O drivers + XenServer Tools must be installed to edit a network on a running VM Default templates support a maximum of {0} networks at VM creation @@ -11098,12 +11115,14 @@ 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 - XenServer Tools or the I/O drivers must be installed to remove a network on a running VM - Tools or I/O drivers + XenServer Tools must be installed to remove a network on a running VM This network cannot be removed because it is a physical device @@ -11906,9 +11925,6 @@ To learn more about the XenServer Dynamic Workload Balancing feature or to start I/O drivers and Management Agent installed - - I/O drivers and Management Agent not installed - I/O not optimized diff --git a/XenModel/XenAPI-Extensions/VM.cs b/XenModel/XenAPI-Extensions/VM.cs index 3ea8ab625..3de785329 100644 --- a/XenModel/XenAPI-Extensions/VM.cs +++ b/XenModel/XenAPI-Extensions/VM.cs @@ -666,7 +666,6 @@ namespace XenAPI startuptime = value; // This has an impact on the virt state of the VM as we allow a set amount of time for tools to show up before assuming unvirt NotifyPropertyChanged("virtualisation_status"); - NotifyPropertyChanged("virtualisation_status_for_search"); if (VirtualizationTimer != null) VirtualizationTimer.Stop(); // 2 minutes before we give up plus some breathing space @@ -679,7 +678,6 @@ namespace XenAPI void VirtualizationTimer_Elapsed(object sender, ElapsedEventArgs e) { NotifyPropertyChanged("virtualisation_status"); - NotifyPropertyChanged("virtualisation_status_for_search"); } private Timer VirtualizationTimer = null; @@ -688,7 +686,7 @@ namespace XenAPI public enum VirtualisationStatus { UNKNOWN = 1, - OPTIMIZED = 1 << 1, + //OPTIMIZED = 1 << 1, //removed OPTIMIZED, using (IO_DRIVERS_INSTALLED | MANAGEMENT_INSTALLED) instead PV_DRIVERS_NOT_INSTALLED = 1 << 2, PV_DRIVERS_OUT_OF_DATE = 1 << 3, IO_DRIVERS_INSTALLED = 1 << 4, @@ -703,28 +701,6 @@ namespace XenAPI } } - public VirtualisationStatus virtualisation_status_for_search - { - get - { - var status = virtualisation_status; - - if (status.HasFlag(VirtualisationStatus.UNKNOWN)) - return VirtualisationStatus.UNKNOWN; - - if (status.HasFlag(VirtualisationStatus.OPTIMIZED)) - return VirtualisationStatus.OPTIMIZED; - - if (status.HasFlag(VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED)) - return VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED; - - if (status.HasFlag(VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE)) - return VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE; - - return VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED; - } - } - public string VirtualisationVersion { get @@ -742,7 +718,7 @@ namespace XenAPI { VirtualisationStatus status = GetVirtualisationStatus; - if (virtualisation_status.HasFlag(VirtualisationStatus.OPTIMIZED) + if (virtualisation_status.HasFlag(VirtualisationStatus.IO_DRIVERS_INSTALLED | 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 ""; @@ -766,7 +742,7 @@ namespace XenAPI && !virtualisation_status.HasFlag(VirtualisationStatus.MANAGEMENT_INSTALLED)) return Messages.VIRTUALIZATION_STATE_VM_MANAGEMENT_AGENT_NOT_INSTALLED; - return IsNewVM ? Messages.VIRTUALIZATION_STATE_VM_IO_DRIVERS_AND_MANAGEMENT_AGENT_NOT_INSTALLED : Messages.PV_DRIVERS_NOT_INSTALLED; + return HasNewVirtualisationStates ? Messages.VIRTUALIZATION_STATE_VM_MANAGEMENT_AGENT_NOT_INSTALLED : Messages.PV_DRIVERS_NOT_INSTALLED; } public VirtualisationStatus GetVirtualisationStatus @@ -791,11 +767,11 @@ namespace XenAPI { if (vm_guest_metrics.PV_drivers_up_to_date) { - return VirtualisationStatus.OPTIMIZED | VirtualisationStatus.IO_DRIVERS_INSTALLED | VirtualisationStatus.MANAGEMENT_INSTALLED; + return HasNewVirtualisationStates ? GetNewVirtualisationFlags() : VirtualisationStatus.IO_DRIVERS_INSTALLED | VirtualisationStatus.MANAGEMENT_INSTALLED; } else { - return VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE | GetNewVirtualisationFlags(); + return HasNewVirtualisationStates ? GetNewVirtualisationFlags() : VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE; } } @@ -812,19 +788,18 @@ namespace XenAPI } else { - if (!IsNewVM) - return VirtualisationStatus.OPTIMIZED; + if (!HasNewVirtualisationStates) + return VirtualisationStatus.IO_DRIVERS_INSTALLED | VirtualisationStatus.MANAGEMENT_INSTALLED; else return GetNewVirtualisationFlags(); } - } } private VirtualisationStatus GetNewVirtualisationFlags() { - var flags = new VirtualisationStatus(); - if (IsNewVM) + var flags = new VirtualisationStatus(); + if (HasNewVirtualisationStates) { flags |= HasRDP ? VirtualisationStatus.MANAGEMENT_INSTALLED : 0; @@ -833,9 +808,6 @@ namespace XenAPI flags |= VirtualisationStatus.IO_DRIVERS_INSTALLED; } - if (flags.HasFlag(VirtualisationStatus.IO_DRIVERS_INSTALLED) && flags.HasFlag(VirtualisationStatus.MANAGEMENT_INSTALLED)) - flags |= VirtualisationStatus.OPTIMIZED; - return flags; } @@ -844,7 +816,7 @@ namespace XenAPI /// We need to know this, because for those VMs virtualization status is defined differently. /// This does not mean new(ly created) VM /// - private bool IsNewVM + public bool HasNewVirtualisationStates { get { @@ -1534,9 +1506,9 @@ namespace XenAPI { get { - if (virtualisation_status.HasFlag(VirtualisationStatus.OPTIMIZED)) + if (virtualisation_status.HasFlag(VirtualisationStatus.IO_DRIVERS_INSTALLED | VirtualisationStatus.MANAGEMENT_INSTALLED)) { - if (!IsNewVM) + if (!HasNewVirtualisationStates) return string.Format(Messages.VIRTUALIZATION_OPTIMIZED, VirtualisationVersion); else return Messages.VIRTUALIZATION_STATE_VM_IO_DRIVERS_AND_MANAGEMENT_AGENT_INSTALLED; diff --git a/XenModel/XenSearch/Common.cs b/XenModel/XenSearch/Common.cs index 7d66b7669..ce22f276f 100644 --- a/XenModel/XenSearch/Common.cs +++ b/XenModel/XenSearch/Common.cs @@ -112,7 +112,7 @@ namespace XenAdmin.XenSearch [HelpString("The VM power state, e.g. Halted, Running")] power_state, [HelpString("The state of the pure virtualization drivers installed on a VM")] - virtualisation_status_for_search, + virtualisation_status, [HelpString("Date and time that the VM was started")] start_time, [HelpString("The HA restart priority of the VM")] @@ -230,10 +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.OPTIMIZED] = VM.VirtualisationStatus.OPTIMIZED; VirtualisationStatus_i18n[Messages.PV_DRIVERS_NOT_INSTALLED] = VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED; 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; @@ -273,7 +277,7 @@ namespace XenAdmin.XenSearch PropertyNames_i18n[PropertyNames.storage] = Messages.SR; PropertyNames_i18n[PropertyNames.disks] = Messages.VIRTUAL_DISK; PropertyNames_i18n[PropertyNames.type] = Messages.TYPE; - PropertyNames_i18n[PropertyNames.virtualisation_status_for_search] = Messages.TOOLS_STATUS; + PropertyNames_i18n[PropertyNames.virtualisation_status] = Messages.TOOLS_STATUS; PropertyNames_i18n[PropertyNames.ha_restart_priority] = Messages.HA_RESTART_PRIORITY; PropertyNames_i18n[PropertyNames.appliance] = Messages.VM_APPLIANCE; PropertyNames_i18n[PropertyNames.tags] = Messages.TAGS; @@ -327,7 +331,7 @@ namespace XenAdmin.XenSearch property_types.Add(PropertyNames.host, typeof(Host)); property_types.Add(PropertyNames.os_name, typeof(string)); property_types.Add(PropertyNames.power_state, typeof(vm_power_state)); - property_types.Add(PropertyNames.virtualisation_status_for_search, typeof(VM.VirtualisationStatus)); + property_types.Add(PropertyNames.virtualisation_status, typeof(VM.VirtualisationStatus)); property_types.Add(PropertyNames.type, typeof(ObjectTypes)); property_types.Add(PropertyNames.networks, typeof(XenAPI.Network)); property_types.Add(PropertyNames.storage, typeof(SR)); @@ -416,11 +420,11 @@ namespace XenAdmin.XenSearch return vm.power_state; }); }; - properties[PropertyNames.virtualisation_status_for_search] = delegate(IXenObject o) + properties[PropertyNames.virtualisation_status] = delegate(IXenObject o) { return GetForRealVM(o, delegate(VM vm, IXenConnection conn) { - return vm.virtualisation_status_for_search; + return vm.GetVirtualisationStatus; }); }; properties[PropertyNames.start_time] = delegate(IXenObject o) @@ -646,7 +650,7 @@ namespace XenAdmin.XenSearch vm.power_state != vm_power_state.Running) return null; - if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.OPTIMIZED)) + if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) return null; return PropertyAccessorHelper.vmMemoryUsageString(vm); @@ -680,7 +684,7 @@ namespace XenAdmin.XenSearch vm.power_state != vm_power_state.Running) return null; - if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.OPTIMIZED)) + if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) return null; return PropertyAccessorHelper.vmMemoryUsageRank(vm); @@ -714,7 +718,7 @@ namespace XenAdmin.XenSearch vm.power_state != vm_power_state.Running) return null; - if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.OPTIMIZED)) + if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) return null; return PropertyAccessorHelper.vmMemoryUsageValue(vm); @@ -748,7 +752,7 @@ namespace XenAdmin.XenSearch vm.power_state != vm_power_state.Running) return null; - if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.OPTIMIZED)) + if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) return null; return PropertyAccessorHelper.vmNetworkUsageString(vm); @@ -775,7 +779,7 @@ namespace XenAdmin.XenSearch if (vm.power_state != vm_power_state.Running) return null; - if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.OPTIMIZED)) + if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) return null; return PropertyAccessorHelper.vmDiskUsageString(vm); @@ -1295,7 +1299,7 @@ namespace XenAdmin.XenSearch case PropertyNames.type: return ObjectTypes_i18n; - case PropertyNames.virtualisation_status_for_search: + case PropertyNames.virtualisation_status: return VirtualisationStatus_i18n; case PropertyNames.power_state: @@ -1367,16 +1371,16 @@ namespace XenAdmin.XenSearch return Icons.XenCenter; }; - case PropertyNames.virtualisation_status_for_search: + case PropertyNames.virtualisation_status: return (ImageDelegate)delegate(VM.VirtualisationStatus status) { - if (status == VM.VirtualisationStatus.OPTIMIZED) + if (status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) return Icons.ToolInstalled; - if (status == VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED || status != VM.VirtualisationStatus.MANAGEMENT_INSTALLED) + if (status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED) || !status.HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) return Icons.ToolsNotInstalled; - if (status == VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE) + if (status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE)) return Icons.ToolsOutOfDate; return Icons.ToolsNotInstalled; diff --git a/XenModel/XenSearch/GroupingTypes.cs b/XenModel/XenSearch/GroupingTypes.cs index 455f352e1..991303982 100644 --- a/XenModel/XenSearch/GroupingTypes.cs +++ b/XenModel/XenSearch/GroupingTypes.cs @@ -277,7 +277,7 @@ namespace XenAdmin.XenSearch public override String GetGroupName(Object group) { - if (!(group is T) || i18ns == null) + 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 aed80040f..95cd57103 100644 --- a/XenModel/XenSearch/Search.cs +++ b/XenModel/XenSearch/Search.cs @@ -815,9 +815,9 @@ namespace XenAdmin.XenSearch new GroupQuery( new QueryFilter[] { new EnumPropertyQuery(PropertyNames.power_state, vm_power_state.Running, true), - new EnumPropertyQuery(PropertyNames.virtualisation_status_for_search, 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_for_search, null), + new PropertyGrouping(PropertyNames.virtualisation_status, null), false, Messages.DEFAULT_SEARCH_VMS_WO_XS_TOOLS, "dead-beef-1234-vmswotools", true ); From 21a74d3d49e7e6e3e20f079d246f882d8fa4a4a6 Mon Sep 17 00:00:00 2001 From: Gabor Apati-Nagy Date: Wed, 16 Sep 2015 13:57:32 +0100 Subject: [PATCH 05/11] CP-13786: GetVirtualisationStatus: More fixes after code review Signed-off-by: Gabor Apati-Nagy --- XenAdmin/XenSearch/Columns.cs | 2 +- XenModel/XenSearch/Common.cs | 10 +++++----- XenModel/XenSearch/GroupingTypes.cs | 3 +++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/XenAdmin/XenSearch/Columns.cs b/XenAdmin/XenSearch/Columns.cs index 59e8283dc..a64722b1b 100644 --- a/XenAdmin/XenSearch/Columns.cs +++ b/XenAdmin/XenSearch/Columns.cs @@ -94,7 +94,7 @@ namespace XenAdmin.XenSearch { 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.IO_DRIVERS_INSTALLED ) || status.HasFlag(VM.VirtualisationStatus.UNKNOWN)) return false; diff --git a/XenModel/XenSearch/Common.cs b/XenModel/XenSearch/Common.cs index ce22f276f..be042c77f 100644 --- a/XenModel/XenSearch/Common.cs +++ b/XenModel/XenSearch/Common.cs @@ -650,7 +650,7 @@ namespace XenAdmin.XenSearch vm.power_state != vm_power_state.Running) return null; - if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) + if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) return null; return PropertyAccessorHelper.vmMemoryUsageString(vm); @@ -684,7 +684,7 @@ namespace XenAdmin.XenSearch vm.power_state != vm_power_state.Running) return null; - if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) + if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) return null; return PropertyAccessorHelper.vmMemoryUsageRank(vm); @@ -718,7 +718,7 @@ namespace XenAdmin.XenSearch vm.power_state != vm_power_state.Running) return null; - if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) + if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) return null; return PropertyAccessorHelper.vmMemoryUsageValue(vm); @@ -752,7 +752,7 @@ namespace XenAdmin.XenSearch vm.power_state != vm_power_state.Running) return null; - if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) + if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) return null; return PropertyAccessorHelper.vmNetworkUsageString(vm); @@ -779,7 +779,7 @@ namespace XenAdmin.XenSearch if (vm.power_state != vm_power_state.Running) return null; - if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) + if (!vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) return null; return PropertyAccessorHelper.vmDiskUsageString(vm); diff --git a/XenModel/XenSearch/GroupingTypes.cs b/XenModel/XenSearch/GroupingTypes.cs index 991303982..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,6 +278,8 @@ namespace XenAdmin.XenSearch public override String GetGroupName(Object group) { + 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); From cb861b0c2ad6d86debaa513ae47108a7b830a28d Mon Sep 17 00:00:00 2001 From: Gabor Apati-Nagy Date: Wed, 16 Sep 2015 18:22:16 +0100 Subject: [PATCH 06/11] CP-13786: GetVirtualisationStatus: Refactoring Signed-off-by: Gabor Apati-Nagy --- .../Controls/NetworkingTab/NetworkList.cs | 2 +- XenAdmin/Dialogs/VmSnapshotDialog.cs | 2 +- XenModel/XenAPI-Extensions/VM.cs | 93 +++++++++++++------ 3 files changed, 66 insertions(+), 31 deletions(-) diff --git a/XenAdmin/Controls/NetworkingTab/NetworkList.cs b/XenAdmin/Controls/NetworkingTab/NetworkList.cs index 52d15fc95..457ac32d0 100644 --- a/XenAdmin/Controls/NetworkingTab/NetworkList.cs +++ b/XenAdmin/Controls/NetworkingTab/NetworkList.cs @@ -439,7 +439,7 @@ namespace XenAdmin.Controls.NetworkingTab } else { - if (vm.power_state == vm_power_state.Running && !vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) + if (vm.power_state == vm_power_state.Running && !vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) { 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); diff --git a/XenAdmin/Dialogs/VmSnapshotDialog.cs b/XenAdmin/Dialogs/VmSnapshotDialog.cs index ea8daea80..2f9be8caf 100644 --- a/XenAdmin/Dialogs/VmSnapshotDialog.cs +++ b/XenAdmin/Dialogs/VmSnapshotDialog.cs @@ -184,7 +184,7 @@ 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.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) + 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"); diff --git a/XenModel/XenAPI-Extensions/VM.cs b/XenModel/XenAPI-Extensions/VM.cs index 3de785329..db12c6d55 100644 --- a/XenModel/XenAPI-Extensions/VM.cs +++ b/XenModel/XenAPI-Extensions/VM.cs @@ -685,12 +685,11 @@ namespace XenAPI [Flags] public enum VirtualisationStatus { + PV_DRIVERS_NOT_INSTALLED = 0, UNKNOWN = 1, - //OPTIMIZED = 1 << 1, //removed OPTIMIZED, using (IO_DRIVERS_INSTALLED | MANAGEMENT_INSTALLED) instead - PV_DRIVERS_NOT_INSTALLED = 1 << 2, - PV_DRIVERS_OUT_OF_DATE = 1 << 3, - IO_DRIVERS_INSTALLED = 1 << 4, - MANAGEMENT_INSTALLED = 1 << 5, + PV_DRIVERS_OUT_OF_DATE = 2, + IO_DRIVERS_INSTALLED = 4, + MANAGEMENT_INSTALLED = 8, }; public VirtualisationStatus virtualisation_status @@ -738,17 +737,15 @@ namespace XenAPI return Messages.PV_DRIVERS_OUT_OF_DATE_UNKNOWN_VERSION; } - 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 HasNewVirtualisationStates ? Messages.VIRTUALIZATION_STATE_VM_MANAGEMENT_AGENT_NOT_INSTALLED : Messages.PV_DRIVERS_NOT_INSTALLED; } - public VirtualisationStatus GetVirtualisationStatus + private VirtualisationStatus GetVirtualisationStatusOldVM { get { + Debug.Assert(!HasNewVirtualisationStates); + if (Connection == null) return VirtualisationStatus.UNKNOWN; @@ -766,13 +763,9 @@ namespace XenAPI if (vm_guest_metrics != null && vm_guest_metrics.PV_drivers_installed) { if (vm_guest_metrics.PV_drivers_up_to_date) - { - return HasNewVirtualisationStates ? GetNewVirtualisationFlags() : VirtualisationStatus.IO_DRIVERS_INSTALLED | VirtualisationStatus.MANAGEMENT_INSTALLED; - } + return VirtualisationStatus.IO_DRIVERS_INSTALLED | VirtualisationStatus.MANAGEMENT_INSTALLED; else - { - return HasNewVirtualisationStates ? GetNewVirtualisationFlags() : VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE; - } + return VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE; } return VirtualisationStatus.UNKNOWN; @@ -780,35 +773,77 @@ namespace XenAPI if (vm_guest_metrics == null || !vm_guest_metrics.PV_drivers_installed) { - return VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED | GetNewVirtualisationFlags(); + return VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED; } else if (!vm_guest_metrics.PV_drivers_up_to_date) { - return VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE | GetNewVirtualisationFlags(); + return VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE; } else { - if (!HasNewVirtualisationStates) - return VirtualisationStatus.IO_DRIVERS_INSTALLED | VirtualisationStatus.MANAGEMENT_INSTALLED; - else - return GetNewVirtualisationFlags(); + return VirtualisationStatus.IO_DRIVERS_INSTALLED | VirtualisationStatus.MANAGEMENT_INSTALLED; } } } - private VirtualisationStatus GetNewVirtualisationFlags() + private VirtualisationStatus GetVirtualisationStatusNewVM { - var flags = new VirtualisationStatus(); - if (HasNewVirtualisationStates) - { - flags |= HasRDP ? VirtualisationStatus.MANAGEMENT_INSTALLED : 0; + get + { + Debug.Assert(HasNewVirtualisationStates); + + if (Connection == null) + return VirtualisationStatus.UNKNOWN; + + VM_metrics vm_metrics = Connection.Resolve(metrics); + if (vm_metrics == null || power_state != vm_power_state.Running) + { + return VirtualisationStatus.UNKNOWN; + } + + 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; - } - return flags; + 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 + { + return HasNewVirtualisationStates ? GetVirtualisationStatusNewVM : GetVirtualisationStatusOldVM; + } } /// From a3ab8f6ad4dab54987b5e2d9da2d78b361aaf46c Mon Sep 17 00:00:00 2001 From: Gabor Apati-Nagy Date: Wed, 16 Sep 2015 18:33:12 +0100 Subject: [PATCH 07/11] CP-13786: GetVirtualisationStatus: Refactoring extracted common code Signed-off-by: Gabor Apati-Nagy --- XenModel/XenAPI-Extensions/VM.cs | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/XenModel/XenAPI-Extensions/VM.cs b/XenModel/XenAPI-Extensions/VM.cs index db12c6d55..37030cead 100644 --- a/XenModel/XenAPI-Extensions/VM.cs +++ b/XenModel/XenAPI-Extensions/VM.cs @@ -746,15 +746,6 @@ namespace XenAPI { Debug.Assert(!HasNewVirtualisationStates); - if (Connection == null) - return VirtualisationStatus.UNKNOWN; - - VM_metrics vm_metrics = Connection.Resolve(metrics); - if (vm_metrics == null || power_state != vm_power_state.Running) - { - return VirtualisationStatus.UNKNOWN; - } - VM_guest_metrics vm_guest_metrics = Connection.Resolve(guest_metrics); if ((DateTime.UtcNow - BodgeStartupTime).TotalMinutes < 2) @@ -792,15 +783,6 @@ namespace XenAPI { Debug.Assert(HasNewVirtualisationStates); - if (Connection == null) - return VirtualisationStatus.UNKNOWN; - - VM_metrics vm_metrics = Connection.Resolve(metrics); - if (vm_metrics == null || power_state != vm_power_state.Running) - { - return VirtualisationStatus.UNKNOWN; - } - var flags = HasRDP ? VirtualisationStatus.MANAGEMENT_INSTALLED : 0; var vm_guest_metrics = Connection.Resolve(guest_metrics); @@ -842,6 +824,15 @@ namespace XenAPI { get { + if (Connection == null) + return VirtualisationStatus.UNKNOWN; + + VM_metrics vm_metrics = Connection.Resolve(metrics); + if (vm_metrics == null || power_state != vm_power_state.Running) + { + return VirtualisationStatus.UNKNOWN; + } + return HasNewVirtualisationStates ? GetVirtualisationStatusNewVM : GetVirtualisationStatusOldVM; } } From f4cd9bd97c34fcc636bd424e580e364f69b931fe Mon Sep 17 00:00:00 2001 From: Gabor Apati-Nagy Date: Fri, 18 Sep 2015 15:48:59 +0100 Subject: [PATCH 08/11] CP-13786: GetVirtualisationStatus: Refactoring, bugfixes Removed PV_DRIVERS_NOT_INSTALLED=0 from the VirtualisationStatus [Flags]enum - 0 will mean the same (to avoid bugs with enum.HasFlag(0) is always true) Extracted common code to VMLifeCycleCommand.GetCantExecuteNoToolsOrDriversReasonCore() method (instead of defining overridden GetCantExecuteReasonCore() method at this level, because not all child classes need this...) Signed-off-by: Gabor Apati-Nagy --- XenAdmin/Commands/RebootVMCommand.cs | 15 +----------- XenAdmin/Commands/ResumeVMCommand.cs | 13 +--------- XenAdmin/Commands/ShutDownVMCommand.cs | 15 +----------- XenAdmin/Commands/SuspendVMCommand.cs | 13 +--------- XenAdmin/Commands/VMLifeCycleCommand.cs | 24 +++++++++++++++++++ .../Ballooning/VMMemoryControlsBasic.cs | 12 +++++----- XenAdmin/Dialogs/VmSnapshotDialog.cs | 2 +- XenAdmin/TabPages/GeneralTabPage.cs | 3 +-- XenAdminTests/TabsAndMenus/TabsAndMenus.cs | 2 +- XenModel/Messages.Designer.cs | 6 ++--- XenModel/Messages.resx | 6 ++--- XenModel/XenAPI-Extensions/VM.cs | 7 +++--- XenModel/XenSearch/Common.cs | 8 ++----- 13 files changed, 48 insertions(+), 78 deletions(-) diff --git a/XenAdmin/Commands/RebootVMCommand.cs b/XenAdmin/Commands/RebootVMCommand.cs index cca09b3cf..2cba7718d 100644 --- a/XenAdmin/Commands/RebootVMCommand.cs +++ b/XenAdmin/Commands/RebootVMCommand.cs @@ -199,20 +199,7 @@ namespace XenAdmin.Commands return base.GetCantExecuteReasonCore(item); } - if (vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED) || 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; - } - - if (!vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) - return Messages.VM_MISSING_IO_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 c516de608..a5b67a52d 100644 --- a/XenAdmin/Commands/ResumeVMCommand.cs +++ b/XenAdmin/Commands/ResumeVMCommand.cs @@ -179,19 +179,8 @@ namespace XenAdmin.Commands { return Messages.VM_NOT_SUSPENDED; } - else if (vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED) || vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.UNKNOWN)) - { - return FriendlyErrorNames.VM_MISSING_PV_DRIVERS; - } - else if (vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE)) - { - return FriendlyErrorNames.VM_OLD_PV_DRIVERS; - } - if (!vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) - return Messages.VM_MISSING_IO_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 48e83b529..ba0f79d00 100644 --- a/XenAdmin/Commands/ShutDownVMCommand.cs +++ b/XenAdmin/Commands/ShutDownVMCommand.cs @@ -169,20 +169,7 @@ namespace XenAdmin.Commands return base.GetCantExecuteReasonCore(item); } - if (vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED) || 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; - } - - if (!vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) - return Messages.VM_MISSING_IO_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 ffa380bdd..079a27b20 100644 --- a/XenAdmin/Commands/SuspendVMCommand.cs +++ b/XenAdmin/Commands/SuspendVMCommand.cs @@ -205,19 +205,8 @@ namespace XenAdmin.Commands { return Messages.VM_ALREADY_SUSPENDED; } - else if (vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED) || 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; - } - if (!vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED)) - return Messages.VM_MISSING_IO_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 8cbc38de7..fb9fafaf9 100644 --- a/XenAdmin/Controls/Ballooning/VMMemoryControlsBasic.cs +++ b/XenAdmin/Controls/Ballooning/VMMemoryControlsBasic.cs @@ -101,12 +101,12 @@ namespace XenAdmin.Controls.Ballooning if (identical) { var status = vm0.GetVirtualisationStatus; - if (status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) + if (status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED) && status.HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_NOTSUPPORTED_PLURAL; - else if (status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED)) - labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_NOTOOLS_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 = vm0.HasNewVirtualisationStates ? Messages.DMC_UNAVAILABLE_NO_IO_NO_MGMNT_PLURAL : Messages.DMC_UNAVAILABLE_OLDTOOLS_PLURAL; + labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_OLDTOOLS_PLURAL; else labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_VMS; } @@ -123,9 +123,9 @@ namespace XenAdmin.Controls.Ballooning { var status = vm0.GetVirtualisationStatus; - if (status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) + if (status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED) && status.HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) labelDMCUnavailable.Text = Messages.DMC_UNAVAILABLE_NOTSUPPORTED; - else if (status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED)) + 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; diff --git a/XenAdmin/Dialogs/VmSnapshotDialog.cs b/XenAdmin/Dialogs/VmSnapshotDialog.cs index 2f9be8caf..dd829b2a5 100644 --- a/XenAdmin/Dialogs/VmSnapshotDialog.cs +++ b/XenAdmin/Dialogs/VmSnapshotDialog.cs @@ -151,7 +151,7 @@ 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.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) + else if (!(_VM.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED) && _VM.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED))) tt = (_VM.HasNewVirtualisationStates ? Messages.INFO_QUIESCE_MODE_NO_IO_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. diff --git a/XenAdmin/TabPages/GeneralTabPage.cs b/XenAdmin/TabPages/GeneralTabPage.cs index 58b37f9db..ffdbda0e9 100644 --- a/XenAdmin/TabPages/GeneralTabPage.cs +++ b/XenAdmin/TabPages/GeneralTabPage.cs @@ -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.HasFlag(XenAPI.VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED) - || vm.virtualisation_status.HasFlag(XenAPI.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/XenAdminTests/TabsAndMenus/TabsAndMenus.cs b/XenAdminTests/TabsAndMenus/TabsAndMenus.cs index 314b6d803..7f51010af 100644 --- a/XenAdminTests/TabsAndMenus/TabsAndMenus.cs +++ b/XenAdminTests/TabsAndMenus/TabsAndMenus.cs @@ -302,7 +302,7 @@ namespace XenAdminTests.TabsAndMenus protected static bool HasTools(VM vm) { return !vm.is_a_template && vm.IsRunning&& - !vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED) && + vm.virtualisation_status != 0 && !vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE); } diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index e46bc2bde..4bfeec585 100644 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -10842,7 +10842,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to A memory range cannot be set because I/O drivers and Management Agent are not installed on this VM.. + /// 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 { @@ -10851,7 +10851,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to A memory range cannot be set because I/O drivers and Management Agent are not installed on these VMs.. + /// 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 { @@ -10905,7 +10905,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to A memory range cannot be set because XenServer Tools or I/O drivers and Management Agent are out of date on these VMs.. + /// Looks up a localized string similar to A memory range cannot be set because XenServer Tools are out of date on these VMs.. /// public static string DMC_UNAVAILABLE_OLDTOOLS_PLURAL { get { diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index b82052cb6..56c263253 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -3857,16 +3857,16 @@ 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 and Management Agent are not installed on this VM. + 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 and Management Agent are not installed on these VMs. + 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. - A memory range cannot be set because XenServer Tools or I/O drivers and Management Agent are out of date on these VMs. + A memory range cannot be set because XenServer Tools are out of date on these VMs. A memory range cannot be set for this template. diff --git a/XenModel/XenAPI-Extensions/VM.cs b/XenModel/XenAPI-Extensions/VM.cs index 37030cead..b28938df8 100644 --- a/XenModel/XenAPI-Extensions/VM.cs +++ b/XenModel/XenAPI-Extensions/VM.cs @@ -685,7 +685,6 @@ namespace XenAPI [Flags] public enum VirtualisationStatus { - PV_DRIVERS_NOT_INSTALLED = 0, UNKNOWN = 1, PV_DRIVERS_OUT_OF_DATE = 2, IO_DRIVERS_INSTALLED = 4, @@ -717,7 +716,7 @@ namespace XenAPI { VirtualisationStatus status = GetVirtualisationStatus; - if (virtualisation_status.HasFlag(VirtualisationStatus.IO_DRIVERS_INSTALLED | VirtualisationStatus.MANAGEMENT_INSTALLED) + 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 ""; @@ -764,7 +763,7 @@ namespace XenAPI if (vm_guest_metrics == null || !vm_guest_metrics.PV_drivers_installed) { - return VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED; + return 0; } else if (!vm_guest_metrics.PV_drivers_up_to_date) { @@ -1543,7 +1542,7 @@ namespace XenAPI if (virtualisation_status.HasFlag(VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE)) return string.Format(Messages.VIRTUALIZATION_OUT_OF_DATE, VirtualisationVersion); - if (virtualisation_status.HasFlag(VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED)) + if (virtualisation_status == 0) return Messages.PV_DRIVERS_NOT_INSTALLED; if (virtualisation_status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED) diff --git a/XenModel/XenSearch/Common.cs b/XenModel/XenSearch/Common.cs index be042c77f..ee5a9dd85 100644 --- a/XenModel/XenSearch/Common.cs +++ b/XenModel/XenSearch/Common.cs @@ -230,8 +230,7 @@ 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; @@ -1377,12 +1376,9 @@ namespace XenAdmin.XenSearch if (status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED | VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) return Icons.ToolInstalled; - if (status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_NOT_INSTALLED) || !status.HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) - return Icons.ToolsNotInstalled; - if (status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE)) return Icons.ToolsOutOfDate; - + return Icons.ToolsNotInstalled; }; From acbc21597ade9f1c03e5a7c09f1903b82132615f Mon Sep 17 00:00:00 2001 From: Gabor Apati-Nagy Date: Mon, 21 Sep 2015 16:09:12 +0100 Subject: [PATCH 09/11] CP-13786: GetVirtualisationStatus More small fixes Signed-off-by: Gabor Apati-Nagy --- .../Ballooning/VMMemoryControlsBasic.cs | 6 ++-- XenAdmin/Dialogs/EvacuateHostDialog.cs | 30 +++++++++++++++++- XenAdmin/Dialogs/VmSnapshotDialog.cs | 4 +-- XenAdmin/XenSearch/Columns.cs | 31 +++++++++++++++++-- .../CommandTests/VMLifecycleCommandTest.cs | 2 +- XenModel/Messages.Designer.cs | 10 +++--- XenModel/Messages.resx | 8 ++--- XenModel/XenAPI-Extensions/VM.cs | 27 ---------------- 8 files changed, 73 insertions(+), 45 deletions(-) diff --git a/XenAdmin/Controls/Ballooning/VMMemoryControlsBasic.cs b/XenAdmin/Controls/Ballooning/VMMemoryControlsBasic.cs index fb9fafaf9..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) @@ -101,7 +101,7 @@ namespace XenAdmin.Controls.Ballooning if (identical) { var status = vm0.GetVirtualisationStatus; - if (status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED) && status.HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) + 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; @@ -123,7 +123,7 @@ namespace XenAdmin.Controls.Ballooning { var status = vm0.GetVirtualisationStatus; - if (status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED) && status.HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED)) + 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; diff --git a/XenAdmin/Dialogs/EvacuateHostDialog.cs b/XenAdmin/Dialogs/EvacuateHostDialog.cs index 64ee50af9..c326aaf92 100644 --- a/XenAdmin/Dialogs/EvacuateHostDialog.cs +++ b/XenAdmin/Dialogs/EvacuateHostDialog.cs @@ -546,7 +546,7 @@ namespace XenAdmin.Dialogs // 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.HasFlag(XenAPI.VM.VirtualisationStatus.UNKNOWN) - ? vm.GetVirtualisationWarningMessages() + ? GetVirtualisationWarningMessages(vm) : Messages.PV_DRIVERS_NOT_INSTALLED; break; } @@ -554,6 +554,34 @@ namespace XenAdmin.Dialogs Update(); } + public string GetVirtualisationWarningMessages(VM vm) + { + VM.VirtualisationStatus status = vm.GetVirtualisationStatus; + + if (vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED) + || vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.UNKNOWN)) + return ""; + + if (vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE)) + { + VM_guest_metrics guestMetrics = vm.Connection.Resolve(vm.guest_metrics); + if (guestMetrics != null + && guestMetrics.PV_drivers_version.ContainsKey("major") + && guestMetrics.PV_drivers_version.ContainsKey("minor")) + { + return String.Format(Messages.PV_DRIVERS_OUT_OF_DATE, String.Format("{0}.{1}", + guestMetrics.PV_drivers_version["major"], + guestMetrics.PV_drivers_version["minor"])); + } + else + return Messages.PV_DRIVERS_OUT_OF_DATE_UNKNOWN_VERSION; + } + + return vm.HasNewVirtualisationStates + ? Messages.VIRTUALIZATION_STATE_VM_INSTALL_MANAGEMENT_AGENT //We display "Install Management Agent" even though I/O drivers are missing in this case + : Messages.PV_DRIVERS_NOT_INSTALLED; + } + public AsyncAction Solve() { AsyncAction a = null; diff --git a/XenAdmin/Dialogs/VmSnapshotDialog.cs b/XenAdmin/Dialogs/VmSnapshotDialog.cs index dd829b2a5..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.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED) && _VM.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED))) - tt = (_VM.HasNewVirtualisationStates ? Messages.INFO_QUIESCE_MODE_NO_IO_MGMNT : 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); diff --git a/XenAdmin/XenSearch/Columns.cs b/XenAdmin/XenSearch/Columns.cs index a64722b1b..2aa91678d 100644 --- a/XenAdmin/XenSearch/Columns.cs +++ b/XenAdmin/XenSearch/Columns.cs @@ -102,7 +102,7 @@ namespace XenAdmin.XenSearch { if (InstallToolsCommand.CanExecute(vm)) { - item = new GridStringItem(vm.GetVirtualisationWarningMessages(), + item = new GridStringItem(GetVMToolsInstallMessage(vm), HorizontalAlignment.Center, VerticalAlignment.Middle, false, @@ -116,7 +116,7 @@ namespace XenAdmin.XenSearch } else { - item = new GridStringItem(vm.GetVirtualisationWarningMessages(), + item = new GridStringItem(GetVMToolsInstallMessage(vm), HorizontalAlignment.Center, VerticalAlignment.Middle, false, @@ -161,6 +161,33 @@ namespace XenAdmin.XenSearch return false; } + + public string GetVMToolsInstallMessage(VM vm) + { + VM.VirtualisationStatus status = vm.GetVirtualisationStatus; + + if (vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED) && vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED) + || vm.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 ""; + + if (vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE)) + { + VM_guest_metrics guestMetrics = vm.Connection.Resolve(vm.guest_metrics); + if (guestMetrics != null + && guestMetrics.PV_drivers_version.ContainsKey("major") + && guestMetrics.PV_drivers_version.ContainsKey("minor")) + { + return String.Format(Messages.PV_DRIVERS_OUT_OF_DATE, String.Format("{0}.{1}", + guestMetrics.PV_drivers_version["major"], + guestMetrics.PV_drivers_version["minor"])); + } + else + return Messages.PV_DRIVERS_OUT_OF_DATE_UNKNOWN_VERSION; + } + + return vm.HasNewVirtualisationStates ? Messages.VIRTUALIZATION_STATE_VM_MANAGEMENT_AGENT_NOT_INSTALLED : Messages.PV_DRIVERS_NOT_INSTALLED; + } } public class NameColumn : Column diff --git a/XenAdminTests/CommandTests/VMLifecycleCommandTest.cs b/XenAdminTests/CommandTests/VMLifecycleCommandTest.cs index cb562f02b..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.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED) && vm.GetVirtualisationStatus.HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED), "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/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index 4bfeec585..07f6afb79 100644 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -5968,7 +5968,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to You must install the I/O drivers on VM '{0}' before you can activate this virtual disk for the VM.. + /// 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 { @@ -6067,7 +6067,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to You must install the I/O drivers on VM '{0}' before you can deactivate this virtual disk for the VM.. + /// 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 { @@ -18219,11 +18219,11 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to Quiesced snapshots need I/O drivers and Management Agent to be installed. + /// Looks up a localized string similar to Quiesced snapshots need Management Agent to be installed. /// - public static string INFO_QUIESCE_MODE_NO_IO_MGMNT { + public static string INFO_QUIESCE_MODE_NO_MGMNT { get { - return ResourceManager.GetString("INFO_QUIESCE_MODE_NO_IO_MGMNT", resourceCulture); + return ResourceManager.GetString("INFO_QUIESCE_MODE_NO_MGMNT", resourceCulture); } } diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index 56c263253..403a8a835 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -2167,7 +2167,7 @@ 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 the I/O drivers on VM '{0}' before you can activate this virtual disk for the VM. + 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. @@ -2200,7 +2200,7 @@ 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 the I/O drivers on VM '{0}' before you can deactivate this virtual disk for the VM. + 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. @@ -6341,8 +6341,8 @@ Click Configure HA to alter the settings displayed below. Quiesced snapshots need the VSS service to be enabled on the VM - - Quiesced snapshots need I/O drivers and Management Agent to be installed + + Quiesced snapshots need Management Agent to be installed Quiesced snapshots need XenServer Tools to be installed diff --git a/XenModel/XenAPI-Extensions/VM.cs b/XenModel/XenAPI-Extensions/VM.cs index b28938df8..168f231ce 100644 --- a/XenModel/XenAPI-Extensions/VM.cs +++ b/XenModel/XenAPI-Extensions/VM.cs @@ -712,33 +712,6 @@ namespace XenAPI } } - public string GetVirtualisationWarningMessages() - { - VirtualisationStatus status = GetVirtualisationStatus; - - 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 ""; - - 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") - && guestMetrics.PV_drivers_version.ContainsKey("minor")) - { - return String.Format(Messages.PV_DRIVERS_OUT_OF_DATE, String.Format("{0}.{1}", - guestMetrics.PV_drivers_version["major"], - guestMetrics.PV_drivers_version["minor"])); - } - else - return Messages.PV_DRIVERS_OUT_OF_DATE_UNKNOWN_VERSION; - } - - return HasNewVirtualisationStates ? Messages.VIRTUALIZATION_STATE_VM_MANAGEMENT_AGENT_NOT_INSTALLED : Messages.PV_DRIVERS_NOT_INSTALLED; - } - private VirtualisationStatus GetVirtualisationStatusOldVM { get From 3eb796d13e4f6e3a5f7487f3995adc9c759b397c Mon Sep 17 00:00:00 2001 From: Gabor Apati-Nagy Date: Mon, 21 Sep 2015 16:59:43 +0100 Subject: [PATCH 10/11] CP-13786: GetVirtualisationStatus Moving GetVirtualisationWarningMessages back to VM Also added EVACUATE_HOST_INSTALL_MGMNT_PROMPT what is shown on the EvacuateHostDialog when a 'new' VM is given and Management Agent can be installed Signed-off-by: Gabor Apati-Nagy --- .../Dialogs/EvacuateHostDialog.Designer.cs | 12 +++---- XenAdmin/Dialogs/EvacuateHostDialog.cs | 32 ++----------------- XenAdmin/XenSearch/Columns.cs | 4 +-- XenModel/Messages.Designer.cs | 9 ++++++ XenModel/Messages.resx | 3 ++ XenModel/XenAPI-Extensions/VM.cs | 27 ++++++++++++++++ 6 files changed, 49 insertions(+), 38 deletions(-) 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 c326aaf92..d40743760 100644 --- a/XenAdmin/Dialogs/EvacuateHostDialog.cs +++ b/XenAdmin/Dialogs/EvacuateHostDialog.cs @@ -539,14 +539,14 @@ 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.HasFlag(XenAPI.VM.VirtualisationStatus.UNKNOWN) - ? GetVirtualisationWarningMessages(vm) + ? vm.GetVirtualisationWarningMessages() : Messages.PV_DRIVERS_NOT_INSTALLED; break; } @@ -554,34 +554,6 @@ namespace XenAdmin.Dialogs Update(); } - public string GetVirtualisationWarningMessages(VM vm) - { - VM.VirtualisationStatus status = vm.GetVirtualisationStatus; - - if (vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED) - || vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.UNKNOWN)) - return ""; - - if (vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE)) - { - VM_guest_metrics guestMetrics = vm.Connection.Resolve(vm.guest_metrics); - if (guestMetrics != null - && guestMetrics.PV_drivers_version.ContainsKey("major") - && guestMetrics.PV_drivers_version.ContainsKey("minor")) - { - return String.Format(Messages.PV_DRIVERS_OUT_OF_DATE, String.Format("{0}.{1}", - guestMetrics.PV_drivers_version["major"], - guestMetrics.PV_drivers_version["minor"])); - } - else - return Messages.PV_DRIVERS_OUT_OF_DATE_UNKNOWN_VERSION; - } - - return vm.HasNewVirtualisationStates - ? Messages.VIRTUALIZATION_STATE_VM_INSTALL_MANAGEMENT_AGENT //We display "Install Management Agent" even though I/O drivers are missing in this case - : Messages.PV_DRIVERS_NOT_INSTALLED; - } - public AsyncAction Solve() { AsyncAction a = null; diff --git a/XenAdmin/XenSearch/Columns.cs b/XenAdmin/XenSearch/Columns.cs index 2aa91678d..6e4c79979 100644 --- a/XenAdmin/XenSearch/Columns.cs +++ b/XenAdmin/XenSearch/Columns.cs @@ -102,7 +102,7 @@ namespace XenAdmin.XenSearch { if (InstallToolsCommand.CanExecute(vm)) { - item = new GridStringItem(GetVMToolsInstallMessage(vm), + item = new GridStringItem(vm.GetVirtualisationWarningMessages(), HorizontalAlignment.Center, VerticalAlignment.Middle, false, @@ -116,7 +116,7 @@ namespace XenAdmin.XenSearch } else { - item = new GridStringItem(GetVMToolsInstallMessage(vm), + item = new GridStringItem(vm.GetVirtualisationWarningMessages(), HorizontalAlignment.Center, VerticalAlignment.Middle, false, diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index 07f6afb79..73ffda99c 100644 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -13581,6 +13581,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. /// diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index 403a8a835..6f2081dd2 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -4766,6 +4766,9 @@ Would you like to eject these ISOs before continuing? {0} Eject the CD + + {0} Install Management Agent + {0} Install XenServer Tools diff --git a/XenModel/XenAPI-Extensions/VM.cs b/XenModel/XenAPI-Extensions/VM.cs index 168f231ce..b28938df8 100644 --- a/XenModel/XenAPI-Extensions/VM.cs +++ b/XenModel/XenAPI-Extensions/VM.cs @@ -712,6 +712,33 @@ namespace XenAPI } } + public string GetVirtualisationWarningMessages() + { + VirtualisationStatus status = GetVirtualisationStatus; + + 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 ""; + + 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") + && guestMetrics.PV_drivers_version.ContainsKey("minor")) + { + return String.Format(Messages.PV_DRIVERS_OUT_OF_DATE, String.Format("{0}.{1}", + guestMetrics.PV_drivers_version["major"], + guestMetrics.PV_drivers_version["minor"])); + } + else + return Messages.PV_DRIVERS_OUT_OF_DATE_UNKNOWN_VERSION; + } + + return HasNewVirtualisationStates ? Messages.VIRTUALIZATION_STATE_VM_MANAGEMENT_AGENT_NOT_INSTALLED : Messages.PV_DRIVERS_NOT_INSTALLED; + } + private VirtualisationStatus GetVirtualisationStatusOldVM { get From 438b8446c3c8c13cedc774edbb97c2352f878984 Mon Sep 17 00:00:00 2001 From: Gabor Apati-Nagy Date: Tue, 22 Sep 2015 21:43:06 +0100 Subject: [PATCH 11/11] CP-13786: GetVirtualisationStatus: Removed unused method from Column class Signed-off-by: Gabor Apati-Nagy --- XenAdmin/XenSearch/Columns.cs | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/XenAdmin/XenSearch/Columns.cs b/XenAdmin/XenSearch/Columns.cs index 6e4c79979..a64722b1b 100644 --- a/XenAdmin/XenSearch/Columns.cs +++ b/XenAdmin/XenSearch/Columns.cs @@ -161,33 +161,6 @@ namespace XenAdmin.XenSearch return false; } - - public string GetVMToolsInstallMessage(VM vm) - { - VM.VirtualisationStatus status = vm.GetVirtualisationStatus; - - if (vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.IO_DRIVERS_INSTALLED) && vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.MANAGEMENT_INSTALLED) - || vm.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 ""; - - if (vm.virtualisation_status.HasFlag(VM.VirtualisationStatus.PV_DRIVERS_OUT_OF_DATE)) - { - VM_guest_metrics guestMetrics = vm.Connection.Resolve(vm.guest_metrics); - if (guestMetrics != null - && guestMetrics.PV_drivers_version.ContainsKey("major") - && guestMetrics.PV_drivers_version.ContainsKey("minor")) - { - return String.Format(Messages.PV_DRIVERS_OUT_OF_DATE, String.Format("{0}.{1}", - guestMetrics.PV_drivers_version["major"], - guestMetrics.PV_drivers_version["minor"])); - } - else - return Messages.PV_DRIVERS_OUT_OF_DATE_UNKNOWN_VERSION; - } - - return vm.HasNewVirtualisationStates ? Messages.VIRTUALIZATION_STATE_VM_MANAGEMENT_AGENT_NOT_INSTALLED : Messages.PV_DRIVERS_NOT_INSTALLED; - } } public class NameColumn : Column