CA-337287: Skip vSwitch controller and PV guest checks with a warning if the RPU hotfix is missing.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2020-03-26 16:54:56 +00:00 committed by Mihaela Stoica
parent 608f56fe7d
commit 888a0555ab
8 changed files with 86 additions and 57 deletions

View File

@ -39,7 +39,6 @@ namespace XenAdmin.Diagnostics.Checks
{
class HostHasHotfixCheck : HostPostLivenessCheck
{
private readonly HotfixFactory hotfixFactory = new HotfixFactory();
public HostHasHotfixCheck(Host host)
: base(host)
{
@ -47,16 +46,13 @@ namespace XenAdmin.Diagnostics.Checks
protected override Problem RunHostCheck()
{
var hotfix = hotfixFactory.Hotfix(Host);
var hotfix = HotfixFactory.Hotfix(Host);
if (hotfix != null && hotfix.ShouldBeAppliedTo(Host))
return new HostDoesNotHaveHotfix(this, Host);
return null;
}
public override string Description
{
get { return Messages.HOTFIX_CHECK; }
}
public override string Description => Messages.HOTFIX_CHECK;
}
}

View File

@ -36,7 +36,8 @@ using XenAPI;
using XenAdmin.Diagnostics.Problems;
using XenAdmin.Diagnostics.Problems.PoolProblem;
using System.Collections.Generic;
using System.Web.Script.Serialization;
using XenAdmin.Diagnostics.Hotfixing;
using XenAdmin.Diagnostics.Problems.HostProblem;
namespace XenAdmin.Diagnostics.Checks
{
@ -44,40 +45,49 @@ namespace XenAdmin.Diagnostics.Checks
{
private readonly Pool _pool;
private readonly bool _upgrade;
private readonly Dictionary<string, string> _installMethodConfig;
private readonly bool _manualUpgrade;
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private readonly Dictionary<string, string> _installMethodConfig;
public PVGuestsCheck(Pool pool, bool upgrade, Dictionary<string, string> installMethodConfig = null, bool manualUpgrade = false)
public PVGuestsCheck(Pool pool, bool upgrade, bool manualUpgrade = false, Dictionary<string, string> installMethodConfig = null)
: base(Helpers.GetMaster(pool.Connection))
{
_pool = pool;
_upgrade = upgrade;
_installMethodConfig = installMethodConfig;
_manualUpgrade = manualUpgrade;
_installMethodConfig = installMethodConfig;
}
protected override Problem RunHostCheck()
{
string upgradePlatformVersion;
if (!_pool.Connection.Cache.VMs.Any(vm => vm.IsPvVm()))
return null;
if (!_upgrade || _manualUpgrade)
//update case
if (!_upgrade)
return new PoolHasPVGuestWarningUrl(this, _pool);
try
//upgrade case
if (!_manualUpgrade)
{
var result = Host.call_plugin(Host.Connection.Session, Host.opaque_ref, "prepare_host_upgrade.py", "getVersion", _installMethodConfig);
var serializer = new JavaScriptSerializer();
var version = (Dictionary<string, object>)serializer.DeserializeObject(result);
upgradePlatformVersion = version.ContainsKey("platform-version") ? (string)version["platform-version"] : null;
var hotfix = HotfixFactory.Hotfix(Host);
if (hotfix != null && hotfix.ShouldBeAppliedTo(Host))
return new HostDoesNotHaveHotfixWarning(this, Host);
}
catch (Exception exception)
{
log.Warn($"Plugin call prepare_host_upgrade.getVersion on {Host.Name()} threw an exception.", exception);
string upgradePlatformVersion = null;
if (_installMethodConfig != null)
Host.TryGetUpgradeVersion(Host, _installMethodConfig, out upgradePlatformVersion, out _);
// 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);
}
if (Helpers.QuebecOrGreater(upgradePlatformVersion))
return new PoolHasPVGuestWarningUrl(this, _pool);
return null;
}

View File

@ -32,7 +32,9 @@
using System;
using System.Collections.Generic;
using XenAdmin.Core;
using XenAdmin.Diagnostics.Hotfixing;
using XenAdmin.Diagnostics.Problems;
using XenAdmin.Diagnostics.Problems.HostProblem;
using XenAdmin.Diagnostics.Problems.PoolProblem;
using XenAPI;
@ -42,7 +44,8 @@ namespace XenAdmin.Diagnostics.Checks
{
private readonly Dictionary<string, string> _installMethodConfig;
private readonly Pool _pool;
private XenServerVersion _newVersion;
private readonly XenServerVersion _newVersion;
private readonly bool _manualUpgrade;
public VSwitchControllerCheck(Host host, XenServerVersion newVersion)
: base(host)
@ -51,10 +54,11 @@ namespace XenAdmin.Diagnostics.Checks
_pool = Helpers.GetPoolOfOne(Host?.Connection);
}
public VSwitchControllerCheck(Host host, Dictionary<string, string> installMethodConfig)
public VSwitchControllerCheck(Host host, Dictionary<string, string> installMethodConfig, bool manualUpgrade)
: base(host)
{
_installMethodConfig = installMethodConfig;
_manualUpgrade = manualUpgrade;
_pool = Helpers.GetPoolOfOne(Host?.Connection);
}
@ -74,6 +78,14 @@ namespace XenAdmin.Diagnostics.Checks
}
//upgrade case
if (!_manualUpgrade)
{
var hotfix = HotfixFactory.Hotfix(Host);
if (hotfix != null && hotfix.ShouldBeAppliedTo(Host))
return new HostDoesNotHaveHotfixWarning(this, Host);
}
string upgradePlatformVersion = null;
if (_installMethodConfig != null)

View File

@ -35,7 +35,7 @@ using XenAPI;
namespace XenAdmin.Diagnostics.Hotfixing
{
internal sealed class HotfixFactory
internal static class HotfixFactory
{
public enum HotfixableServerVersion
{
@ -44,25 +44,25 @@ namespace XenAdmin.Diagnostics.Hotfixing
Naples
}
private readonly Hotfix dundeeHotfix = new SingleHotfix
private static readonly Hotfix dundeeHotfix = new SingleHotfix
{
Filename = "RPU003",
UUID = "b651dd22-df7d-45a4-8c0a-6be037bc1714"
};
private readonly Hotfix elyLimaHotfix = new SingleHotfix
private static readonly Hotfix elyLimaHotfix = new SingleHotfix
{
Filename = "RPU004",
UUID = "1821854d-0171-4696-a9c4-01daf75a45a0"
};
private readonly Hotfix naplesHotfix = new SingleHotfix
private static readonly Hotfix naplesHotfix = new SingleHotfix
{
Filename = "RPU005",
UUID = "b43ea62d-2804-4589-9164-f6cc5867d011"
};
public Hotfix Hotfix(Host host)
public static Hotfix Hotfix(Host host)
{
if (Helpers.NaplesOrGreater(host) && !Helpers.QuebecOrGreater(host))
return Hotfix(HotfixableServerVersion.Naples);
@ -73,7 +73,7 @@ namespace XenAdmin.Diagnostics.Hotfixing
return null;
}
public Hotfix Hotfix(HotfixableServerVersion version)
public static Hotfix Hotfix(HotfixableServerVersion version)
{
if (version == HotfixableServerVersion.Naples)
return naplesHotfix;
@ -85,7 +85,7 @@ namespace XenAdmin.Diagnostics.Hotfixing
throw new ArgumentException("A version was provided for which there is no hotfix filename");
}
public bool IsHotfixRequired(Host host)
public static bool IsHotfixRequired(Host host)
{
return Hotfix(host) != null;
}

View File

@ -29,39 +29,23 @@
* SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using XenAdmin.Core;
using XenAdmin.Diagnostics.Checks;
using XenAdmin.Diagnostics.Hotfixing;
using XenAdmin.Properties;
using XenAPI;
namespace XenAdmin.Diagnostics.Problems.HostProblem
{
class HostDoesNotHaveHotfix : HostProblem
{
private readonly HotfixFactory hotfixFactory = new HotfixFactory();
public HostDoesNotHaveHotfix(HostHasHotfixCheck check, Host server)
: base(check, server)
{
}
public override string Description
{
get { return string.Format(Messages.REQUIRED_HOTFIX_ISNOT_INSTALLED, ServerName); }
}
public override string Description => string.Format(Messages.REQUIRED_HOTFIX_NOT_INSTALLED, ServerName);
public override string HelpMessage
{
get { return Messages.APPLY_HOTFIX; }
}
public override string HelpMessage => Messages.APPLY_HOTFIX;
protected override Actions.AsyncAction CreateAction(out bool cancelled)
{
@ -69,10 +53,25 @@ namespace XenAdmin.Diagnostics.Problems.HostProblem
return new Actions.DelegatedAsyncAction(Server.Connection, string.Format(Messages.APPLYING_HOTFIX_TO_HOST, Server), "", "",
(ss) =>
{
Hotfix hotfix = hotfixFactory.Hotfix(Server);
Hotfix hotfix = HotfixFactory.Hotfix(Server);
if (hotfix != null)
hotfix.Apply(Server, ss);
}, true);
}
}
class HostDoesNotHaveHotfixWarning : Warning
{
private readonly Host host;
public HostDoesNotHaveHotfixWarning(Check check, Host host)
: base(check)
{
this.host = host;
}
public override string Title => Check.Description;
public override string Description => string.Format(Messages.REQUIRED_HOTFIX_NOT_INSTALLED_WARNING, host);
}
}

View File

@ -179,7 +179,7 @@ namespace XenAdmin.Wizards.RollingUpgradeWizard
var hotfixChecks = new List<Check>();
foreach (var host in hostsToUpgrade)
{
if (new HotfixFactory().IsHotfixRequired(host) && !ManualUpgrade)
if (HotfixFactory.IsHotfixRequired(host) && !ManualUpgrade)
hotfixChecks.Add(new HostHasHotfixCheck(host));
}
if (hotfixChecks.Count > 0)
@ -201,7 +201,7 @@ namespace XenAdmin.Wizards.RollingUpgradeWizard
//vSwitch controller check - for each pool
var vswitchChecks = (from Host server in SelectedMasters.Where(m => !Helpers.StockholmOrGreater(m))
select new VSwitchControllerCheck(server, InstallMethodConfig) as Check).ToList();
select new VSwitchControllerCheck(server, InstallMethodConfig, ManualUpgrade) as Check).ToList();
if (vswitchChecks.Count > 0)
groups.Add(new CheckGroup(Messages.CHECKING_VSWITCH_CONTROLLER_GROUP, vswitchChecks));
@ -250,7 +250,7 @@ namespace XenAdmin.Wizards.RollingUpgradeWizard
foreach (Pool pool in SelectedPools.Where(p => !Helpers.QuebecOrGreater(p.Connection)))
{
if (pool.Connection.Resolve(pool.master) != null)
pvChecks.Add(new PVGuestsCheck(pool, true, InstallMethodConfig, ManualUpgrade));
pvChecks.Add(new PVGuestsCheck(pool, true, ManualUpgrade, InstallMethodConfig));
}
if (pvChecks.Count > 0)
groups.Add(new CheckGroup(Messages.CHECKING_PV_GUESTS, pvChecks));

View File

@ -31861,9 +31861,18 @@ namespace XenAdmin {
/// <summary>
/// Looks up a localized string similar to {0}: The required hotfix is not installed.
/// </summary>
public static string REQUIRED_HOTFIX_ISNOT_INSTALLED {
public static string REQUIRED_HOTFIX_NOT_INSTALLED {
get {
return ResourceManager.GetString("REQUIRED_HOTFIX_ISNOT_INSTALLED", resourceCulture);
return ResourceManager.GetString("REQUIRED_HOTFIX_NOT_INSTALLED", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {0}: Check skipped because the required hotfix is not installed.
/// </summary>
public static string REQUIRED_HOTFIX_NOT_INSTALLED_WARNING {
get {
return ResourceManager.GetString("REQUIRED_HOTFIX_NOT_INSTALLED_WARNING", resourceCulture);
}
}

View File

@ -11061,9 +11061,12 @@ Click Server Status Report to open the Compile Server Status Report Wizard or cl
<data name="REPEATED_KEY" xml:space="preserve">
<value>Repeated key</value>
</data>
<data name="REQUIRED_HOTFIX_ISNOT_INSTALLED" xml:space="preserve">
<data name="REQUIRED_HOTFIX_NOT_INSTALLED" xml:space="preserve">
<value>{0}: The required hotfix is not installed</value>
</data>
<data name="REQUIRED_HOTFIX_NOT_INSTALLED_WARNING" xml:space="preserve">
<value>{0}: Check skipped because the required hotfix is not installed</value>
</data>
<data name="REQUIRED_UPDATES" xml:space="preserve">
<value>Required Updates</value>
</data>