diff --git a/XenAdmin/Core/Updates.cs b/XenAdmin/Core/Updates.cs index 0ee1dd45f..68c0e23ae 100644 --- a/XenAdmin/Core/Updates.cs +++ b/XenAdmin/Core/Updates.cs @@ -980,5 +980,31 @@ namespace XenAdmin.Core else Alert.RefreshAlertAt(alertIndex); } + + public static void CheckHotfixEligibility() + { + var alerts = new List(); + + foreach (var connection in ConnectionsManager.XenConnectionsCopy) + { + if (!connection.IsConnected) + continue; + + var master = Helpers.GetMaster(connection); + if (master == null) + continue; + + var hotfixEligibility = HotfixEligibility(master, out var xenServerVersion); + + if (xenServerVersion == null || hotfixEligibility == hotfix_eligibility.all || + hotfixEligibility == hotfix_eligibility.premium && !master.IsFreeLicenseOrExpired()) + continue; + + alerts.Add(new HotfixEligibilityAlert(connection, xenServerVersion)); + } + + Alert.RemoveAlert(a => a is HotfixEligibilityAlert); + Alert.AddAlertRange(alerts); + } } } diff --git a/XenAdmin/TabPages/AlertSummaryPage.Designer.cs b/XenAdmin/TabPages/AlertSummaryPage.Designer.cs index 151517965..c7bb223b2 100644 --- a/XenAdmin/TabPages/AlertSummaryPage.Designer.cs +++ b/XenAdmin/TabPages/AlertSummaryPage.Designer.cs @@ -16,6 +16,7 @@ namespace XenAdmin.TabPages if (disposing) { DeregisterEventHandlers(); + DeregisterCheckForUpdatesEvents(); if (components != null) components.Dispose(); diff --git a/XenAdmin/TabPages/AlertSummaryPage.cs b/XenAdmin/TabPages/AlertSummaryPage.cs index bac23c8f5..b06f43a99 100644 --- a/XenAdmin/TabPages/AlertSummaryPage.cs +++ b/XenAdmin/TabPages/AlertSummaryPage.cs @@ -69,6 +69,7 @@ namespace XenAdmin.TabPages UpdateActionEnablement(); m_alertCollectionChangedWithInvoke = Program.ProgramInvokeHandler(AlertsCollectionChanged); + RegisterCheckForUpdatesEvents(); toolStripSplitButtonDismiss.DefaultItem = tsmiDismissAll; toolStripSplitButtonDismiss.Text = tsmiDismissAll.Text; @@ -834,5 +835,22 @@ namespace XenAdmin.TabPages Clip.SetClipboardText(alert.GetUpdateDetailsCSVQuotes()); } + + #region CheckForUpdates events + private void RegisterCheckForUpdatesEvents() + { + Updates.CheckForUpdatesCompleted += CheckForUpdatesCompleted; + } + + private void DeregisterCheckForUpdatesEvents() + { + Updates.CheckForUpdatesCompleted -= CheckForUpdatesCompleted; + } + + private void CheckForUpdatesCompleted(bool succeeded, string errorMessage) + { + Updates.CheckHotfixEligibility(); + } + #endregion } } diff --git a/XenModel/Alerts/Types/Alert.cs b/XenModel/Alerts/Types/Alert.cs index 62099d269..cdd7bd5a3 100644 --- a/XenModel/Alerts/Types/Alert.cs +++ b/XenModel/Alerts/Types/Alert.cs @@ -61,6 +61,18 @@ namespace XenAdmin.Alerts log.Error("Failed to add incoming alert", e); } } + public static void AddAlertRange(IEnumerable collection) + { + try + { + lock (XenCenterAlertsLock) + XenCenterAlerts.AddRange(collection); + } + catch (Exception e) + { + log.Error("Failed to add incoming alerts", e); + } + } public static void RemoveAlert(Alert a) {