mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-23 20:36:33 +01:00
CP-19264: Live Patching in XC: Use Pool_update version of Host.patches_requiring_reboot in XenCenter
Signed-off-by: Gabor Apati-Nagy <gabor.apati-nagy@citrix.com>
This commit is contained in:
parent
192cacc5fc
commit
5df1593989
@ -675,8 +675,8 @@ namespace XenAdmin.TabPages
|
||||
|
||||
if (elyOrGreater)
|
||||
{
|
||||
// As of Ely we use host.patches_requiring_reboot to generate the list of reboot required messages
|
||||
messages = CheckHostPatchesRequiringReboot(host);
|
||||
// As of Ely we use host.updates_requiring_reboot to generate the list of reboot required messages
|
||||
messages = CheckHostUpdatesRequiringReboot(host);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1777,7 +1777,7 @@ namespace XenAdmin.TabPages
|
||||
// As of Ely we use CheckHostPatchesRequiringReboot to get reboot messages for a host
|
||||
foreach (Host host in xenObject.Connection.Cache.Hosts)
|
||||
{
|
||||
warnings.AddRange(CheckHostPatchesRequiringReboot(host));
|
||||
warnings.AddRange(CheckHostUpdatesRequiringReboot(host));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1830,21 +1830,19 @@ namespace XenAdmin.TabPages
|
||||
/// </summary>
|
||||
/// <param name="host"></param>
|
||||
/// <returns></returns>
|
||||
private List<KeyValuePair<String, String>> CheckHostPatchesRequiringReboot(Host host)
|
||||
private List<KeyValuePair<String, String>> CheckHostUpdatesRequiringReboot(Host host)
|
||||
{
|
||||
var warnings = new List<KeyValuePair<String, String>>();
|
||||
var patchRefs = host.patches_requiring_reboot;
|
||||
foreach (var patchRef in patchRefs)
|
||||
var updateRefs = host.updates_requiring_reboot;
|
||||
foreach (var updateRef in updateRefs)
|
||||
{
|
||||
var patch = host.Connection.Resolve(patchRef);
|
||||
warnings.Add(CreateWarningRow(host, patch));
|
||||
var update = host.Connection.Resolve(updateRef);
|
||||
warnings.Add(CreateWarningRow(host, update));
|
||||
}
|
||||
|
||||
return warnings;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private KeyValuePair<string, string> CreateWarningRow(Host host, Pool_patch patch)
|
||||
{
|
||||
//TODO: Could we come up with a better key string than foopatch on blahhost?
|
||||
@ -1853,6 +1851,15 @@ namespace XenAdmin.TabPages
|
||||
|
||||
return new KeyValuePair<string, string>(key, value);
|
||||
}
|
||||
|
||||
private KeyValuePair<string, string> CreateWarningRow(Host host, Pool_update update)
|
||||
{
|
||||
//TODO: Could we come up with a better key string than foopatch on blahhost?
|
||||
var key = String.Format(Messages.GENERAL_PANEL_UPDATE_KEY, update.Name, host.Name);
|
||||
var value = string.Format(Messages.GENERAL_PANEL_UPDATE_WARNING, host.Name, update.Name);
|
||||
|
||||
return new KeyValuePair<string, string>(key, value);
|
||||
}
|
||||
|
||||
private static string GetUUID(IXenObject o)
|
||||
{
|
||||
|
@ -554,28 +554,13 @@ namespace XenAdmin.Wizards.PatchingWizard
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Live patching has failed for a host if that host requires a reboot for this patch, and we expected to live patch
|
||||
/// Returns true if <paramref name="host"/> has to be rebooted for this update
|
||||
/// </summary>
|
||||
/// <param name="host"></param>
|
||||
/// <returns></returns>
|
||||
private bool LivePatchingFailedForHost(Host host)
|
||||
private bool HostRequiresReboot(Host host)
|
||||
{
|
||||
if (!host.patches_requiring_reboot.Any())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var patchRef in host.patches_requiring_reboot)
|
||||
{
|
||||
var poolPatch = host.Connection.Resolve(patchRef);
|
||||
if (poolPatch.uuid.Equals(Patch.uuid))
|
||||
{
|
||||
// This patch failed
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return
|
||||
host.updates_requiring_reboot !=null && PoolUpdate != null
|
||||
&& host.updates_requiring_reboot.Select(uRef => host.Connection.Resolve(uRef)).Any(u => u != null && u.uuid.Equals(PoolUpdate.uuid));
|
||||
}
|
||||
|
||||
private void FinishedSuccessfully()
|
||||
@ -589,7 +574,7 @@ namespace XenAdmin.Wizards.PatchingWizard
|
||||
|
||||
foreach (var host in SelectedMasters)
|
||||
{
|
||||
if (LivePatchingAttemptedForHost(host) && LivePatchingFailedForHost(host))
|
||||
if (LivePatchingAttemptedForHost(host) && HostRequiresReboot(host))
|
||||
{
|
||||
livePatchingFailedHosts.Add(host);
|
||||
}
|
||||
|
@ -66,11 +66,11 @@ namespace XenAdmin.Wizards.PatchingWizard.PlanActions
|
||||
{
|
||||
log.DebugFormat("Checking host.patches_requiring_reboot now on '{0}'...", hostObject);
|
||||
|
||||
if (hostObject.patches_requiring_reboot.Count > 0)
|
||||
if (hostObject.updates_requiring_reboot.Count > 0)
|
||||
{
|
||||
AvoidRestartHosts.Remove(hostObject.uuid);
|
||||
|
||||
log.DebugFormat("Restart is needed now (hostObject.patches_requiring_reboot has {0} items in it). Evacuating now. Will restart after.", hostObject.patches_requiring_reboot.Count);
|
||||
log.DebugFormat("Restart is needed now (hostObject.updates_requiring_reboot has {0} items in it). Evacuating now. Will restart after.", hostObject.updates_requiring_reboot.Count);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user