From 5bf8559b609cf061553fc22d7dcbe6b48a7e86c8 Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Tue, 28 Feb 2023 13:43:47 +0000 Subject: [PATCH] Show more analytical warning. Signed-off-by: Konstantina Chremmou --- .../Checks/PoolHasDeprecatedSrsCheck.cs | 30 +++++++----- .../PoolProblem/PoolHasFCoESrWarning.cs | 47 +++++-------------- XenAdmin/Diagnostics/Problems/Problem.cs | 2 +- XenAdmin/Diagnostics/Problems/Warning.cs | 10 ++++ XenModel/Messages.Designer.cs | 11 ++++- XenModel/Messages.resx | 7 ++- 6 files changed, 57 insertions(+), 50 deletions(-) diff --git a/XenAdmin/Diagnostics/Checks/PoolHasDeprecatedSrsCheck.cs b/XenAdmin/Diagnostics/Checks/PoolHasDeprecatedSrsCheck.cs index 462b9be1c..ceca7f2ea 100644 --- a/XenAdmin/Diagnostics/Checks/PoolHasDeprecatedSrsCheck.cs +++ b/XenAdmin/Diagnostics/Checks/PoolHasDeprecatedSrsCheck.cs @@ -31,9 +31,11 @@ using System.Collections.Generic; using System.Linq; using XenAdmin.Core; -using XenAPI; +using XenAdmin.Diagnostics.Hotfixing; using XenAdmin.Diagnostics.Problems; +using XenAdmin.Diagnostics.Problems.HostProblem; using XenAdmin.Diagnostics.Problems.PoolProblem; +using XenAPI; namespace XenAdmin.Diagnostics.Checks { @@ -55,19 +57,25 @@ namespace XenAdmin.Diagnostics.Checks protected override Problem RunHostCheck() { - string upgradePlatformVersion = null; - var upgradingToVersionWithDeprecation = false; - if (_installMethodConfig != null) + if (!_manualUpgrade) { - Host.TryGetUpgradeVersion(Host, _installMethodConfig, out upgradePlatformVersion, out _); + var hotfix = HotfixFactory.Hotfix(Host); + if (hotfix != null && hotfix.ShouldBeAppliedTo(Host)) + return new HostDoesNotHaveHotfixWarning(this, Host); } - if (!_manualUpgrade && !string.IsNullOrEmpty(upgradePlatformVersion)) - { - upgradingToVersionWithDeprecation = Helpers.Post82X(upgradePlatformVersion); - } - - return new PoolHasFCoESrWarning(this, Helpers.GetPoolOfOne(Host.Connection), upgradingToVersionWithDeprecation); + string upgradePlatformVersion = null; + + if (_installMethodConfig != null) + Host.TryGetUpgradeVersion(Host, _installMethodConfig, out upgradePlatformVersion, out _); + + if (string.IsNullOrEmpty(upgradePlatformVersion)) + return new PoolHasFCoESrWarning(this, Helpers.GetPoolOfOne(Host.Connection), false); + + if (Helpers.Post82X(upgradePlatformVersion)) + return new PoolHasFCoESrWarning(this, Helpers.GetPoolOfOne(Host.Connection), true); + + return null; } } } diff --git a/XenAdmin/Diagnostics/Problems/PoolProblem/PoolHasFCoESrWarning.cs b/XenAdmin/Diagnostics/Problems/PoolProblem/PoolHasFCoESrWarning.cs index 7288e2cea..a1b650463 100644 --- a/XenAdmin/Diagnostics/Problems/PoolProblem/PoolHasFCoESrWarning.cs +++ b/XenAdmin/Diagnostics/Problems/PoolProblem/PoolHasFCoESrWarning.cs @@ -28,13 +28,8 @@ * SUCH DAMAGE. */ -using System; -using System.Diagnostics; -using System.Reflection; -using XenAdmin.Actions; using XenAdmin.Core; using XenAdmin.Diagnostics.Checks; -using XenAdmin.Dialogs; using XenAPI; @@ -42,44 +37,26 @@ namespace XenAdmin.Diagnostics.Problems.PoolProblem { internal class PoolHasFCoESrWarning : WarningWithMoreInfo { - private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod()?.DeclaringType); private readonly Pool _pool; private readonly bool _upgradingToVersionWithDeprecation; - public override string Title => Check.Description; - public override string HelpMessage => Messages.MORE_INFO; + public override string Title => Description; public override string LinkText => Messages.LEARN_MORE; - public override string LinkData => InvisibleMessages.PV_GUESTS_CHECK_URL; - public override string Message => string.Empty; + public override string LinkData => InvisibleMessages.FCOE_SR_DEPRECATION_URL; - public override string Description => string.Format(_upgradingToVersionWithDeprecation ? Messages.POOL_HAS_DEPRECATED_FCOE_WARNING : Messages.POOL_MAY_HAVE_DEPRECATED_FCOE_WARNING, - _pool, - BrandManager.ProductVersionPost82 - ); - - public PoolHasFCoESrWarning(Check check, Pool pool, bool upgradingToVersionWithDeprecation) : base(check) + public override string Message => string.Format(_upgradingToVersionWithDeprecation + ? Messages.POOL_HAS_DEPRECATED_FCOE_WARNING + : Messages.POOL_MAY_HAVE_DEPRECATED_FCOE_WARNING, + BrandManager.ProductVersionPost82); + + public override string Description => string.Format(Messages.POOL_HAS_DEPRECATED_FCOE_SHORT, + _pool, BrandManager.ProductVersionPost82); + + public PoolHasFCoESrWarning(Check check, Pool pool, bool upgradingToVersionWithDeprecation) + : base(check) { _pool = pool; _upgradingToVersionWithDeprecation = upgradingToVersionWithDeprecation; } - - protected override AsyncAction CreateAction(out bool cancelled) - { - try - { - Process.Start(InvisibleMessages.FCOE_SR_DEPRECATION_URL); - } - catch(Exception e) - { - Log.Error($"Error while attempting to open {InvisibleMessages.FCOE_SR_DEPRECATION_URL}.", e); - using (var dlg = new WarningDialog(string.Format(Messages.COULD_NOT_OPEN_URL, InvisibleMessages.FCOE_SR_DEPRECATION_URL))) - { - dlg.Show(); - } - } - - cancelled = true; - return null; - } } } \ No newline at end of file diff --git a/XenAdmin/Diagnostics/Problems/Problem.cs b/XenAdmin/Diagnostics/Problems/Problem.cs index 0a82d82f0..0f2fc906d 100644 --- a/XenAdmin/Diagnostics/Problems/Problem.cs +++ b/XenAdmin/Diagnostics/Problems/Problem.cs @@ -93,7 +93,7 @@ namespace XenAdmin.Diagnostics.Problems return null; } - public int CompareTo(Problem other) + public virtual int CompareTo(Problem other) { if (other == null) return 1; diff --git a/XenAdmin/Diagnostics/Problems/Warning.cs b/XenAdmin/Diagnostics/Problems/Warning.cs index 38161979d..3142e6b22 100644 --- a/XenAdmin/Diagnostics/Problems/Warning.cs +++ b/XenAdmin/Diagnostics/Problems/Warning.cs @@ -83,6 +83,16 @@ namespace XenAdmin.Diagnostics.Problems public override string Title => Check.Description; public virtual string LinkData => null; public virtual string LinkText => LinkData; + + public override int CompareTo(Problem other) + { + if (!(other is WarningWithMoreInfo warning)) + return 1; + + var result = string.Compare(Message, warning.Message); + + return result == 0 ? base.CompareTo(other) : result; + } } diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index 9ac952f38..3629e2046 100755 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -30807,6 +30807,15 @@ namespace XenAdmin { /// /// Looks up a localized string similar to {0}: Support for Software FCoE SRs has been deprecated in {1}. /// + public static string POOL_HAS_DEPRECATED_FCOE_SHORT { + get { + return ResourceManager.GetString("POOL_HAS_DEPRECATED_FCOE_SHORT", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Support for Software FCoE SRs has been deprecated in {0} and will be removed in a future release. It is recommended that you move your VMs to a different type of storage and remove Software FCoE SRs from your systems as soon as possible.. + /// public static string POOL_HAS_DEPRECATED_FCOE_WARNING { get { return ResourceManager.GetString("POOL_HAS_DEPRECATED_FCOE_WARNING", resourceCulture); @@ -30944,7 +30953,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to {0}: If you are upgrading to {1}, support for Software FCoE SRs has been deprecated. + /// Looks up a localized string similar to Support for Software FCoE SRs has been deprecated in {0} and will be removed in a future release. If you are upgrading to this version, it is recommended that you move your VMs to a different type of storage and remove Software FCoE SRs from your system as soon as possible.. /// public static string POOL_MAY_HAVE_DEPRECATED_FCOE_WARNING { get { diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index 43f24148a..29f6eeb67 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -10695,9 +10695,12 @@ Please reconnect the host and try again Could not find the pool in {0}'s cache. - + {0}: Support for Software FCoE SRs has been deprecated in {1} + + Support for Software FCoE SRs has been deprecated in {0} and will be removed in a future release. It is recommended that you move your VMs to a different type of storage and remove Software FCoE SRs from your systems as soon as possible. + This pool has hosts with different types of license. @@ -10745,7 +10748,7 @@ Support for PV guests has been removed in {1}. Click Learn more to see the list Pool License - {0}: If you are upgrading to {1}, support for Software FCoE SRs has been deprecated + Support for Software FCoE SRs has been deprecated in {0} and will be removed in a future release. If you are upgrading to this version, it is recommended that you move your VMs to a different type of storage and remove Software FCoE SRs from your system as soon as possible. Pool name cannot be empty