Show more analytical warning.

Signed-off-by: Konstantina Chremmou <Konstantina.Chremmou@cloud.com>
This commit is contained in:
Konstantina Chremmou 2023-02-28 13:43:47 +00:00 committed by Danilo Del Busso
parent 43e2cecf32
commit 5bf8559b60
6 changed files with 57 additions and 50 deletions

View File

@ -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;
}
}
}

View File

@ -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;
}
}
}

View File

@ -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;

View File

@ -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;
}
}

View File

@ -30807,6 +30807,15 @@ namespace XenAdmin {
/// <summary>
/// Looks up a localized string similar to {0}: Support for Software FCoE SRs has been deprecated in {1}.
/// </summary>
public static string POOL_HAS_DEPRECATED_FCOE_SHORT {
get {
return ResourceManager.GetString("POOL_HAS_DEPRECATED_FCOE_SHORT", resourceCulture);
}
}
/// <summary>
/// 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..
/// </summary>
public static string POOL_HAS_DEPRECATED_FCOE_WARNING {
get {
return ResourceManager.GetString("POOL_HAS_DEPRECATED_FCOE_WARNING", resourceCulture);
@ -30944,7 +30953,7 @@ namespace XenAdmin {
}
/// <summary>
/// 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..
/// </summary>
public static string POOL_MAY_HAVE_DEPRECATED_FCOE_WARNING {
get {

View File

@ -10695,9 +10695,12 @@ Please reconnect the host and try again</value>
<data name="POOL_GONE" xml:space="preserve">
<value>Could not find the pool in {0}'s cache.</value>
</data>
<data name="POOL_HAS_DEPRECATED_FCOE_WARNING" xml:space="preserve">
<data name="POOL_HAS_DEPRECATED_FCOE_SHORT" xml:space="preserve">
<value>{0}: Support for Software FCoE SRs has been deprecated in {1}</value>
</data>
<data name="POOL_HAS_DEPRECATED_FCOE_WARNING" xml:space="preserve">
<value>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.</value>
</data>
<data name="POOL_HAS_MIXED_LICENSES" xml:space="preserve">
<value>This pool has hosts with different types of license.</value>
</data>
@ -10745,7 +10748,7 @@ Support for PV guests has been removed in {1}. Click Learn more to see the list
<value>Pool License</value>
</data>
<data name="POOL_MAY_HAVE_DEPRECATED_FCOE_WARNING" xml:space="preserve">
<value>{0}: If you are upgrading to {1}, support for Software FCoE SRs has been deprecated</value>
<value>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.</value>
</data>
<data name="POOL_NAME_EMPTY" xml:space="preserve">
<value>Pool name cannot be empty</value>