CP-6215: Do not allow HA for vGPU VMs.

# HG changeset patch
# User Konstantina Chremmou <Konstantina.Chremmou@citrix.com>
# Date 1384333341 0
#      Wed Nov 13 09:02:21 2013 +0000
# Node ID 8f10c3e041ebb2295f0692fcc6d733e7654906d0
# Parent  2f55fef6f39ab916f2ab8604926621aeb6dfc41c

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2013-11-14 12:38:00 +00:00
parent 0354bd7a85
commit 0d7c6eb5f4
4 changed files with 107 additions and 126 deletions

View File

@ -466,10 +466,22 @@ namespace XenAdmin.Dialogs
return;
}
var vmHAEditPage = verticalTabs.SelectedItem as VMHAEditPage;
if (vmHAEditPage != null)
if (verticalTabs.SelectedItem == VMHAEditPage)
{
vmHAEditPage.StartNtolUpdate();
VMHAEditPage.StartNtolUpdate();
if (GpuEditPage != null)
{
VMHAEditPage.GpuGroup = GpuEditPage.GpuGroup;
VMHAEditPage.VgpuType = GpuEditPage.VgpuType;
VMHAEditPage.RefillPrioritiesComboBox();
}
return;
}
if (verticalTabs.SelectedItem == GpuEditPage && VMHAEditPage != null)
{
GpuEditPage.SelectedPriority = VMHAEditPage.SelectedPriority;
GpuEditPage.ShowHideWarnings();
return;
}
}

View File

@ -82,6 +82,8 @@ namespace XenAdmin.SettingsPanels
}
}
public VM.HA_Restart_Priority SelectedPriority { private get; set; }
#region IEditPage Members
public AsyncAction SaveSettings()
@ -96,6 +98,7 @@ namespace XenAdmin.SettingsPanels
Trace.Assert(!Helpers.FeatureForbidden(clone, Host.RestrictGpu)); // If license insufficient, we show upsell page instead
vm = (VM)clone;
SelectedPriority = vm.HARestartPriority;
if (Connection == null) // on the PropertiesDialog
Connection = vm.Connection;
@ -210,87 +213,85 @@ namespace XenAdmin.SettingsPanels
gpu_groups = Connection.Cache.GPU_groups.Where(g => g.PGPUs.Count > 0 && g.supported_VGPU_types.Count != 0).ToArray();//not showing empty groups
gpusAvailable = gpu_groups.Length > 0;
if (!gpusAvailable)
if (gpusAvailable)
{
labelGpuType.Visible = comboBoxGpus.Visible = false;
labelRubric.Text = Helpers.GetPool(Connection) == null
? Messages.GPU_RUBRIC_NO_GPUS_SERVER
: Messages.GPU_RUBRIC_NO_GPUS_POOL;
PopulateComboBox();
ShowHideWarnings();
}
else
{
var noneItem = new GpuTuple(null, null, null);
comboBoxGpus.Items.Add(noneItem);
labelRubric.Text = Helpers.GetPool(Connection) == null
? Messages.GPU_RUBRIC_NO_GPUS_SERVER
: Messages.GPU_RUBRIC_NO_GPUS_POOL;
Array.Sort(gpu_groups);
foreach (GPU_group gpu_group in gpu_groups)
{
if (Helpers.FeatureForbidden(Connection, Host.RestrictVgpu))
{
comboBoxGpus.Items.Add(new GpuTuple(gpu_group, null, null));
}
else
{
var enabledRefs = GPU_group.get_enabled_VGPU_types(Connection.Session, gpu_group.opaque_ref);
var enabledTypes = Connection.ResolveAll(enabledRefs);
var allTypes = Connection.ResolveAll(gpu_group.supported_VGPU_types);
var disabledTypes = allTypes.FindAll(t => !enabledTypes.Exists(e => e.opaque_ref == t.opaque_ref));
if (allTypes.Count > 1)
{
allTypes.Sort((t1, t2) =>
{
int result = t1.Capacity.CompareTo(t2.Capacity);
if (result != 0)
return result;
return t1.Name.CompareTo(t2.Name);
});
comboBoxGpus.Items.Add(new GpuTuple(gpu_group, allTypes.ToArray(), disabledTypes.ToArray()));
foreach (var vgpuType in allTypes)
comboBoxGpus.Items.Add(new GpuTuple(gpu_group, new[] { vgpuType }, disabledTypes.ToArray()));
}
else
comboBoxGpus.Items.Add(new GpuTuple(gpu_group, null, disabledTypes.ToArray()));
}
}
foreach (var item in comboBoxGpus.Items)
{
var tuple = item as GpuTuple;
if (tuple == null)
continue;
if (tuple.Equals(currentGpuTuple))
{
comboBoxGpus.SelectedItem = item;
break;
}
}
if (comboBoxGpus.SelectedItem == null)
comboBoxGpus.SelectedItem = noneItem;
tableLayoutPanel1.Visible = false;
warningsTable.Visible = false;
}
ShowHideWarnings();
}
#endregion
private void ShowHideWarnings()
private void PopulateComboBox()
{
var noneItem = new GpuTuple(null, null, null);
comboBoxGpus.Items.Add(noneItem);
Array.Sort(gpu_groups);
foreach (GPU_group gpu_group in gpu_groups)
{
if (Helpers.FeatureForbidden(Connection, Host.RestrictVgpu))
{
comboBoxGpus.Items.Add(new GpuTuple(gpu_group, null, null));
}
else
{
var enabledRefs = GPU_group.get_enabled_VGPU_types(Connection.Session, gpu_group.opaque_ref);
var enabledTypes = Connection.ResolveAll(enabledRefs);
var allTypes = Connection.ResolveAll(gpu_group.supported_VGPU_types);
var disabledTypes = allTypes.FindAll(t => !enabledTypes.Exists(e => e.opaque_ref == t.opaque_ref));
if (allTypes.Count > 1)
{
allTypes.Sort((t1, t2) =>
{
int result = t1.Capacity.CompareTo(t2.Capacity);
if (result != 0)
return result;
return t1.Name.CompareTo(t2.Name);
});
comboBoxGpus.Items.Add(new GpuTuple(gpu_group, allTypes.ToArray(), disabledTypes.ToArray()));
foreach (var vgpuType in allTypes)
comboBoxGpus.Items.Add(new GpuTuple(gpu_group, new[] { vgpuType }, disabledTypes.ToArray()));
}
else
comboBoxGpus.Items.Add(new GpuTuple(gpu_group, null, disabledTypes.ToArray()));
}
}
foreach (var item in comboBoxGpus.Items)
{
var tuple = item as GpuTuple;
if (tuple == null)
continue;
if (tuple.Equals(currentGpuTuple))
{
comboBoxGpus.SelectedItem = item;
break;
}
}
if (comboBoxGpus.SelectedItem == null)
comboBoxGpus.SelectedItem = noneItem;
}
public void ShowHideWarnings()
{
if (!gpusAvailable)
{
imgRDP.Visible = labelRDP.Visible =
imgNeedDriver.Visible = labelNeedDriver.Visible =
imgNeedGpu.Visible = labelNeedGpu.Visible =
imgStopVM.Visible = labelStopVM.Visible =
imgHA.Visible = labelHA.Visible =
false;
return;
}
if (vm.power_state != vm_power_state.Halted)
{
@ -306,7 +307,7 @@ namespace XenAdmin.SettingsPanels
return;
}
if (vm.IsHAProtectedRestart)
if (VM.HaPriorityIsRestart(Connection, SelectedPriority))
{
imgRDP.Visible = labelRDP.Visible =
imgNeedDriver.Visible = labelNeedDriver.Visible =
@ -320,6 +321,7 @@ namespace XenAdmin.SettingsPanels
return;
}
labelGpuType.Enabled = comboBoxGpus.Enabled = true;
GpuTuple tuple = comboBoxGpus.SelectedItem as GpuTuple;
imgStopVM.Visible = labelStopVM.Visible =

View File

@ -32,16 +32,15 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
using XenAdmin;
using XenAdmin.Actions;
using XenAdmin.Core;
using XenAdmin.Network;
using XenAdmin.TabPages;
using XenAPI;
using System.Drawing;
using XenAdmin.Controls;
@ -124,10 +123,7 @@ namespace XenAdmin.SettingsPanels
return String.Format(Messages.HA_NOT_CONFIGURED, Helpers.GetName(pool).Ellipsise(30));
}
if (m_comboBoxProtectionLevel.SelectedItem != null)
return m_comboBoxProtectionLevel.SelectedItem.ToString();
return Messages.NONE_DEFINED;
return Helpers.RestartPriorityI18n(SelectedPriority);
}
}
@ -248,10 +244,7 @@ namespace XenAdmin.SettingsPanels
// VM wasn't agile
vmIsAgile = false;
}
Program.Invoke(Program.MainWindow, delegate()
{
RefillPrioritiesComboBox();
});
Program.Invoke(Program.MainWindow, RefillPrioritiesComboBox);
}
catch (Exception e)
{
@ -287,7 +280,7 @@ namespace XenAdmin.SettingsPanels
/// <summary>
/// Called after we determine if the selected VM is agile or not. Fills the combo box with the correct PriorityWrappers.
/// </summary>
private void RefillPrioritiesComboBox()
public void RefillPrioritiesComboBox()
{
Program.AssertOnEventThread();
@ -298,7 +291,8 @@ namespace XenAdmin.SettingsPanels
foreach (var restartPriority in restartPriorities)
{
// add "restart" priorities only is vm is agile
if (VM.HaPriorityIsRestart(vm.Connection, restartPriority) && !vmIsAgile)
if (VM.HaPriorityIsRestart(vm.Connection, restartPriority) &&
(!vmIsAgile || GpuGroup != null || VgpuType != null))
continue;
m_comboBoxProtectionLevel.Items.Add(new PriorityWrapper(restartPriority));
}
@ -306,10 +300,9 @@ namespace XenAdmin.SettingsPanels
// Select appropriate entry in combo box
bool found = false;
VM.HA_Restart_Priority pri = vm.HARestartPriority;
foreach (PriorityWrapper w in m_comboBoxProtectionLevel.Items)
{
if (w.Priority == pri)
if (w.Priority == SelectedPriority)
{
found = true;
m_comboBoxProtectionLevel.SelectedItem = w;
@ -322,7 +315,7 @@ namespace XenAdmin.SettingsPanels
// Someone might have set a High/Medium/Low restart priority for a non-agile VM through the CLI,
// even though this is not possible through the GUI. Hence we need to add that priority to the
// combo box just to prevent things screwing up.
m_comboBoxProtectionLevel.Items.Insert(0, new PriorityWrapper(pri));
m_comboBoxProtectionLevel.Items.Insert(0, new PriorityWrapper(SelectedPriority));
m_comboBoxProtectionLevel.SelectedIndex = 0;
}
}
@ -430,21 +423,11 @@ namespace XenAdmin.SettingsPanels
return showStartOrderAndDelay && (nudOrder.Value != origOrder || nudStartDelay.Value != origStartDelay);
}
private VM.HA_Restart_Priority SelectedPriority
{
get
{
PriorityWrapper w = m_comboBoxProtectionLevel.SelectedItem as PriorityWrapper;
if (w == null)
{
return origRestartPriority;
}
else
{
return w.Priority;
}
}
}
public VM.HA_Restart_Priority SelectedPriority { get; private set; }
public GPU_group GpuGroup { private get; set; }
public VGPU_type VgpuType { private get; set; }
private bool IsHaEditable()
{
@ -462,7 +445,8 @@ namespace XenAdmin.SettingsPanels
System.Diagnostics.Trace.Assert(vm == null);
vm = (VM)clone;
origRestartPriority = vm.HARestartPriority;
origRestartPriority = vm.HARestartPriority;
SelectedPriority = origRestartPriority;
origOrder = vm.order;
origStartDelay = vm.start_delay;
@ -604,13 +588,15 @@ namespace XenAdmin.SettingsPanels
if (vm == null)
return;
VM.HA_Restart_Priority priority = SelectedPriority;
var pw = m_comboBoxProtectionLevel.SelectedItem as PriorityWrapper;
if (pw != null)
SelectedPriority = pw.Priority;
comboLabel.Text = Helpers.RestartPriorityDescription(priority);
comboLabel.Text = Helpers.RestartPriorityDescription(SelectedPriority);
Dictionary<VM, VM.HA_Restart_Priority> settings = Helpers.GetVmHaRestartPriorities(vm.Connection, Properties.Settings.Default.ShowHiddenVMs);
var settings = Helpers.GetVmHaRestartPriorities(vm.Connection, Properties.Settings.Default.ShowHiddenVMs);
// Supplement with the changed setting
settings[vm] = priority;
settings[vm] = SelectedPriority;
// This will trigger an update in the ntol indicator.
haNtolIndicator.Settings = settings;

View File

@ -1156,25 +1156,6 @@ namespace XenAPI
}
}
/// <summary>
/// True if this VM's ha_restart_priority is not "Do not restart" and its pool has ha_enabled true.
/// For pre-Boston VMs: True if this VM has ha_always_run set and its pool has ha_enabled true.
/// </summary>
public bool IsHAProtectedRestart
{
get
{
if (Connection == null)
return false;
Pool myPool = Helpers.GetPoolOfOne(Connection);
if (myPool == null)
return false;
if (Helpers.BostonOrGreater(Connection))
return myPool.ha_enabled && this.HARestartPriority == HA_Restart_Priority.Restart;
return myPool.ha_enabled && this.ha_always_run;
}
}
/// <summary>
/// Calls set_ha_restart_priority and set_ha_always_run as appropriate.
/// </summary>