From fd627e687fb0497f7c73517f8ccc1d0332e71585 Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Wed, 25 May 2022 13:31:36 +0100 Subject: [PATCH] CP-39933: Show the names of the PV guests preventing upgrade if any are detected. Signed-off-by: Konstantina Chremmou --- XenAdmin/Diagnostics/Checks/PVGuestsCheck.cs | 20 ++++++--- .../PoolProblem/PoolHasPVGuestWarningUrl.cs | 43 +++++++++++++------ XenModel/Messages.Designer.cs | 15 ++++++- XenModel/Messages.resx | 9 +++- 4 files changed, 64 insertions(+), 23 deletions(-) diff --git a/XenAdmin/Diagnostics/Checks/PVGuestsCheck.cs b/XenAdmin/Diagnostics/Checks/PVGuestsCheck.cs index 3422b0555..8b322b368 100644 --- a/XenAdmin/Diagnostics/Checks/PVGuestsCheck.cs +++ b/XenAdmin/Diagnostics/Checks/PVGuestsCheck.cs @@ -30,13 +30,14 @@ */ using System.Linq; +using System.Collections.Generic; using XenAdmin.Core; -using XenAPI; +using XenAdmin.Diagnostics.Hotfixing; using XenAdmin.Diagnostics.Problems; using XenAdmin.Diagnostics.Problems.PoolProblem; -using System.Collections.Generic; -using XenAdmin.Diagnostics.Hotfixing; using XenAdmin.Diagnostics.Problems.HostProblem; +using XenAPI; + namespace XenAdmin.Diagnostics.Checks { @@ -45,6 +46,7 @@ namespace XenAdmin.Diagnostics.Checks private readonly Pool _pool; private readonly bool _manualUpgrade; private readonly Dictionary _installMethodConfig; + private List _pvGuests = new List(); public PVGuestsCheck(Host coordinator, bool manualUpgrade = false, Dictionary installMethodConfig = null) : base(coordinator) @@ -59,7 +61,11 @@ namespace XenAdmin.Diagnostics.Checks if (Helpers.YangtzeOrGreater(Host)) return false; - if (_pool == null || !_pool.Connection.Cache.VMs.Any(vm => vm.IsPvVm())) + if (_pool == null) + return false; + + _pvGuests = _pool.Connection.Cache.VMs.Where(vm => vm.IsPvVm()).ToList(); + if (_pvGuests.Count <= 0) return false; return true; @@ -82,13 +88,13 @@ namespace XenAdmin.Diagnostics.Checks // we don't know the upgrade version, so add warning // (this is the case of the manual upgrade or when the rpu plugin doesn't have the function) if (string.IsNullOrEmpty(upgradePlatformVersion)) - return new PoolHasPVGuestWarningUrl(this, _pool); + return new PoolHasPVGuestWarningUrl(this, _pool, _pvGuests); if (Helpers.YangtzeOrGreater(upgradePlatformVersion)) - return new PoolHasPVGuestProblem(this, _pool); + return new PoolHasPVGuestProblem(this, _pool, _pvGuests); if (Helpers.QuebecOrGreater(upgradePlatformVersion)) - return new PoolHasPVGuestWarningUrl(this, _pool); + return new PoolHasPVGuestWarningUrl(this, _pool, _pvGuests); return null; } diff --git a/XenAdmin/Diagnostics/Problems/PoolProblem/PoolHasPVGuestWarningUrl.cs b/XenAdmin/Diagnostics/Problems/PoolProblem/PoolHasPVGuestWarningUrl.cs index b75a3e8d2..4619808cd 100644 --- a/XenAdmin/Diagnostics/Problems/PoolProblem/PoolHasPVGuestWarningUrl.cs +++ b/XenAdmin/Diagnostics/Problems/PoolProblem/PoolHasPVGuestWarningUrl.cs @@ -29,55 +29,70 @@ * SUCH DAMAGE. */ -using XenAdmin.Diagnostics.Checks; -using System; +using System.Collections.Generic; +using System.Linq; using XenAdmin.Core; +using XenAdmin.Diagnostics.Checks; using XenAPI; namespace XenAdmin.Diagnostics.Problems.PoolProblem { - class PoolHasPVGuestWarningUrl : WarningWithInformationUrl + class PoolHasPVGuestWarningUrl : WarningWithMoreInfo { private readonly Pool _pool; + private readonly List _pvGuests; - public PoolHasPVGuestWarningUrl(Check check, Pool pool) + public PoolHasPVGuestWarningUrl(Check check, Pool pool, List pvGuests) : base(check) { _pool = pool; + _pvGuests = pvGuests; } - private string PVGuestCheckUrl => string.Format(InvisibleMessages.PV_GUESTS_CHECK_URL); - public override Uri UriToLaunch => new Uri(PVGuestCheckUrl); - public override string Title => Description; + public override string Title => Check.Description; public override string Description => string.Format(Messages.POOL_HAS_PV_GUEST_WARNING, _pool.Name(), string.Format(Messages.STRING_SPACE_STRING, BrandManager.ProductBrand, BrandManager.ProductVersion81)); - public override string HelpMessage => LinkText; + public override string HelpMessage => Messages.MORE_INFO; + + public override string Message => + string.Format(Messages.POOL_HAS_PV_GUEST_WARNING_DETAIL, + string.Join(", ", _pvGuests.Select(g => g.Name())), + string.Format(Messages.STRING_SPACE_STRING, BrandManager.ProductBrand, BrandManager.ProductVersion81)); + public override string LinkText => Messages.LEARN_MORE; + public override string LinkData => InvisibleMessages.PV_GUESTS_CHECK_URL; } - class PoolHasPVGuestProblem : ProblemWithInformationUrl + class PoolHasPVGuestProblem : ProblemWithMoreInfo { private readonly Pool _pool; + private readonly List _pvGuests; - public PoolHasPVGuestProblem(Check check, Pool pool) + public PoolHasPVGuestProblem(Check check, Pool pool, List pvGuests) : base(check) { _pool = pool; + _pvGuests = pvGuests; } - private string PVGuestCheckUrl => string.Format(InvisibleMessages.PV_GUESTS_CHECK_URL); - public override Uri UriToLaunch => new Uri(PVGuestCheckUrl); - public override string Title => Description; + public override string Title => Check.Description; public override string Description => string.Format(Messages.POOL_HAS_PV_GUEST_WARNING, _pool.Name(), string.Format(Messages.STRING_SPACE_STRING, BrandManager.ProductBrand, BrandManager.ProductVersion81)); - public override string HelpMessage => LinkText; + public override string HelpMessage => Messages.MORE_INFO; + + public override string Message => + string.Format(Messages.POOL_HAS_PV_GUEST_WARNING_DETAIL, + string.Join(", ", _pvGuests.Select(g => g.Name())), + string.Format(Messages.STRING_SPACE_STRING, BrandManager.ProductBrand, BrandManager.ProductVersion81)); + public override string LinkText => Messages.LEARN_MORE; + public override string LinkData => InvisibleMessages.PV_GUESTS_CHECK_URL; } } diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index 37bb46180..d02039238 100755 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -31082,7 +31082,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to {0}: Support for paravirtualized (PV) guests has been removed in {1}. Click Learn more to see the list of supported guest operating systems.. + /// Looks up a localized string similar to {0}: Support for paravirtualized (PV) guests has been removed in {1}.. /// public static string POOL_HAS_PV_GUEST_WARNING { get { @@ -31090,6 +31090,19 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to The following VMs are paravirtualized (PV): + /// + ///{0} + /// + ///Support for PV guests has been removed in {1}. Click Learn more to see the list of supported guest operating systems.. + /// + public static string POOL_HAS_PV_GUEST_WARNING_DETAIL { + get { + return ResourceManager.GetString("POOL_HAS_PV_GUEST_WARNING_DETAIL", resourceCulture); + } + } + /// /// Looks up a localized string similar to The pool is partially licensed. /// diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index b9907a79e..dd21c5555 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -10787,7 +10787,14 @@ Please reconnect the host and try again This pool has no shared storage - {0}: Support for paravirtualized (PV) guests has been removed in {1}. Click Learn more to see the list of supported guest operating systems. + {0}: Support for paravirtualized (PV) guests has been removed in {1}. + + + The following VMs are paravirtualized (PV): + +{0} + +Support for PV guests has been removed in {1}. Click Learn more to see the list of supported guest operating systems. The pool is partially licensed