From 8646a1ca3ab094060b3a55ab64c691e37b00076a Mon Sep 17 00:00:00 2001 From: Stephen Turner Date: Mon, 13 Jul 2015 16:27:18 +0100 Subject: [PATCH] CP-12966 GPU drop-down to behave correctly when there is one vGPU type and no passthrough --- XenAdmin/Controls/ComboBoxes/VgpuComboBox.cs | 2 +- XenAdmin/SettingsPanels/GpuEditPage.cs | 2 +- XenModel/XenAPI-Extensions/GPU_group.cs | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/XenAdmin/Controls/ComboBoxes/VgpuComboBox.cs b/XenAdmin/Controls/ComboBoxes/VgpuComboBox.cs index a585e448e..d5bce66e6 100644 --- a/XenAdmin/Controls/ComboBoxes/VgpuComboBox.cs +++ b/XenAdmin/Controls/ComboBoxes/VgpuComboBox.cs @@ -125,7 +125,7 @@ namespace XenAdmin.Controls VgpuTypes = vgpuType == null ? null : new[] {vgpuType}; if (vgpuType != null) { - IsVgpuSubitem = gpuGroup.supported_VGPU_types.Count > 1; + IsVgpuSubitem = gpuGroup.HasVGpu; IsFractionalVgpu = !vgpuType.IsPassthrough; if (disabledVGpuTypes != null && disabledVGpuTypes.Select(t => t.opaque_ref).Contains(vgpuType.opaque_ref)) IsNotEnabledVgpu = true; diff --git a/XenAdmin/SettingsPanels/GpuEditPage.cs b/XenAdmin/SettingsPanels/GpuEditPage.cs index a8454b31d..4230187f2 100644 --- a/XenAdmin/SettingsPanels/GpuEditPage.cs +++ b/XenAdmin/SettingsPanels/GpuEditPage.cs @@ -255,7 +255,7 @@ namespace XenAdmin.SettingsPanels var disabledTypes = allTypes.FindAll(t => !enabledTypes.Exists(e => e.opaque_ref == t.opaque_ref)); - if (allTypes.Count > 1) + if (gpu_group.HasVGpu) { allTypes.Sort((t1, t2) => { diff --git a/XenModel/XenAPI-Extensions/GPU_group.cs b/XenModel/XenAPI-Extensions/GPU_group.cs index 6c5793288..79fe0c0c8 100644 --- a/XenModel/XenAPI-Extensions/GPU_group.cs +++ b/XenModel/XenAPI-Extensions/GPU_group.cs @@ -30,6 +30,7 @@ */ using System; +using System.Linq; using XenAdmin; namespace XenAPI @@ -54,6 +55,15 @@ namespace XenAPI : String.Format(Messages.GPU_GROUP_NAME_AND_NO_OF_GPUS, Name, PGPUs.Count); } + public bool HasVGpu + { + get + { + return Connection.ResolveAll(PGPUs).Any(pgpu => pgpu.HasVGpu); + } + } + + #region IEquatable Members ///