From 5df1593989c18c82b69d76b37235452d5f67097b Mon Sep 17 00:00:00 2001 From: Gabor Apati-Nagy Date: Wed, 12 Oct 2016 14:48:17 +0100 Subject: [PATCH] CP-19264: Live Patching in XC: Use Pool_update version of Host.patches_requiring_reboot in XenCenter Signed-off-by: Gabor Apati-Nagy --- XenAdmin/TabPages/GeneralTabPage.cs | 27 ++++++++++++------- .../PatchingWizard_PatchingPage.cs | 27 +++++-------------- .../PlanActions/EvacuateHostPlanAction.cs | 4 +-- 3 files changed, 25 insertions(+), 33 deletions(-) diff --git a/XenAdmin/TabPages/GeneralTabPage.cs b/XenAdmin/TabPages/GeneralTabPage.cs index 929128dfd..679605149 100644 --- a/XenAdmin/TabPages/GeneralTabPage.cs +++ b/XenAdmin/TabPages/GeneralTabPage.cs @@ -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 /// /// /// - private List> CheckHostPatchesRequiringReboot(Host host) + private List> CheckHostUpdatesRequiringReboot(Host host) { var warnings = new List>(); - 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 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(key, value); } + + private KeyValuePair 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(key, value); + } private static string GetUUID(IXenObject o) { diff --git a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PatchingPage.cs b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PatchingPage.cs index e79ad22cb..63ef77e82 100644 --- a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PatchingPage.cs +++ b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_PatchingPage.cs @@ -554,28 +554,13 @@ namespace XenAdmin.Wizards.PatchingWizard } /// - /// 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 has to be rebooted for this update /// - /// - /// - 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); } diff --git a/XenAdmin/Wizards/PatchingWizard/PlanActions/EvacuateHostPlanAction.cs b/XenAdmin/Wizards/PatchingWizard/PlanActions/EvacuateHostPlanAction.cs index 1b31e0eb5..2edb17cba 100644 --- a/XenAdmin/Wizards/PatchingWizard/PlanActions/EvacuateHostPlanAction.cs +++ b/XenAdmin/Wizards/PatchingWizard/PlanActions/EvacuateHostPlanAction.cs @@ -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 {