From b32168d8d8bda0315e2269725b14f6fa1a5953c9 Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Fri, 11 Aug 2023 01:24:07 +0100 Subject: [PATCH] Further work on CA-380738: After updates are applied retrieve the new metadata from the host in order to refresh the server status. Signed-off-by: Konstantina Chremmou --- XenAdmin/Core/Updates.cs | 29 ++++++++++++------- .../PatchingWizard_AutomatedUpdatesPage.cs | 1 + .../PlanActions/ApplyCdnUpdatesPlanAction.cs | 16 ++++++++++ XenModel/Messages.Designer.cs | 9 ++++++ XenModel/Messages.resx | 3 ++ 5 files changed, 47 insertions(+), 11 deletions(-) diff --git a/XenAdmin/Core/Updates.cs b/XenAdmin/Core/Updates.cs index 87204f002..c3e6cdfb4 100644 --- a/XenAdmin/Core/Updates.cs +++ b/XenAdmin/Core/Updates.cs @@ -120,22 +120,25 @@ namespace XenAdmin.Core CdnUpdateInfoChanged?.Invoke(connection); } - public static void CheckForCdnUpdates(IXenConnection connection) + public static void CheckForCdnUpdates(IXenConnection connection, bool isPlanAction = false) { var pool = Helpers.GetPoolOfOne(connection); if (pool == null) return; - if (Helpers.XapiEqualOrGreater_23_18_0(connection)) + if (!isPlanAction) { - if (pool.last_update_sync == Util.GetUnixMinDateTime() || - connection.Cache.Hosts.All(h => h.latest_synced_updates_applied == latest_synced_updates_applied_state.yes)) - return; - } - else - { - if (pool.repositories.Count == 0) - return; + if (Helpers.XapiEqualOrGreater_23_18_0(connection)) + { + if (pool.last_update_sync == Util.GetUnixMinDateTime() || + connection.Cache.Hosts.All(h => h.latest_synced_updates_applied == latest_synced_updates_applied_state.yes)) + return; + } + else + { + if (pool.repositories.Count == 0) + return; + } } if (!pool.allowed_operations.Contains(pool_allowed_operations.get_updates)) @@ -143,7 +146,11 @@ namespace XenAdmin.Core var action = new CheckForCdnUpdatesAction(connection); action.Completed += CheckForCdnUpdatesAction_Completed; - action.RunAsync(); + + if (isPlanAction) + action.RunSync(action.Session); + else + action.RunAsync(); } private static void CheckForCdnUpdatesAction_Completed(ActionBase sender) diff --git a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_AutomatedUpdatesPage.cs b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_AutomatedUpdatesPage.cs index a7218ca2a..e342d37dd 100644 --- a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_AutomatedUpdatesPage.cs +++ b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_AutomatedUpdatesPage.cs @@ -197,6 +197,7 @@ namespace XenAdmin.Wizards.PatchingWizard } planActionsPerHost.Add(new ApplyCdnUpdatesPlanAction(host, poolUpdateInfo)); + delayedActionsPerHost.Add(new CheckForCdnUpdatesPlanAction(host.Connection)); return new HostPlan(host, null, planActionsPerHost, delayedActionsPerHost); } diff --git a/XenAdmin/Wizards/PatchingWizard/PlanActions/ApplyCdnUpdatesPlanAction.cs b/XenAdmin/Wizards/PatchingWizard/PlanActions/ApplyCdnUpdatesPlanAction.cs index 6e96b9888..15a9d68de 100644 --- a/XenAdmin/Wizards/PatchingWizard/PlanActions/ApplyCdnUpdatesPlanAction.cs +++ b/XenAdmin/Wizards/PatchingWizard/PlanActions/ApplyCdnUpdatesPlanAction.cs @@ -30,6 +30,7 @@ using XenAdmin.Actions; using XenAdmin.Core; +using XenAdmin.Network; using XenAPI; @@ -62,4 +63,19 @@ namespace XenAdmin.Wizards.PatchingWizard.PlanActions new ApplyUpdatesFromCdnAction(host, _updateInfo).RunSync(session); } } + + + class CheckForCdnUpdatesPlanAction : PlanActionWithSession + { + public CheckForCdnUpdatesPlanAction(IXenConnection connection) + : base(connection) + { + } + + protected override void RunWithSession(ref Session session) + { + AddProgressStep(string.Format(Messages.UPDATES_WIZARD_REFRESHING_CDN_UPDATES_LIST, Connection.Name)); + Updates.CheckForCdnUpdates(Connection, true); + } + } } diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index 59373b5ac..e30d7bed5 100755 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -38389,6 +38389,15 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to Refreshing the updates list for {0}... . + /// + public static string UPDATES_WIZARD_REFRESHING_CDN_UPDATES_LIST { + get { + return ResourceManager.GetString("UPDATES_WIZARD_REFRESHING_CDN_UPDATES_LIST", resourceCulture); + } + } + /// /// Looks up a localized string similar to Deleting update installation file {0} from {1}... . /// diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index e5502c78d..1a9ed17fd 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -13255,6 +13255,9 @@ Please check your settings and try again. Rebooting {0}... + + Refreshing the updates list for {0}... + Deleting update installation file {0} from {1}...