CA-317752: Take live-patching qualification into consideration in the Install Update pre-checks

Signed-off-by: Mihaela Stoica <mihaela.stoica@citrix.com>
This commit is contained in:
Mihaela Stoica 2019-07-22 17:49:18 +01:00 committed by Konstantina Chremmou
parent 0e57e871b9
commit c137b4a6ea
5 changed files with 45 additions and 11 deletions

View File

@ -77,6 +77,12 @@ namespace XenAdmin.Diagnostics.Checks
livePatchCodesByHost[Host.uuid] == livepatch_status.ok_livepatch_complete livePatchCodesByHost[Host.uuid] == livepatch_status.ok_livepatch_complete
|| updateSequenceIsLivePatchable) || updateSequenceIsLivePatchable)
{ {
var livePatchingRestricted = Helpers.FeatureForbidden(Host.Connection, Host.RestrictLivePatching);
var livePatchingRDisabled = Helpers.GetPoolOfOne(Host.Connection)?.live_patching_disabled == true;
if (livePatchingRestricted || livePatchingRDisabled)
return new HostNeedsReboot(this, Host, livePatchingRestricted, livePatchingRDisabled);
successfulCheckDescription = string.Format(Messages.UPDATES_WIZARD_NO_REBOOT_NEEDED_LIVE_PATCH, Host); successfulCheckDescription = string.Format(Messages.UPDATES_WIZARD_NO_REBOOT_NEEDED_LIVE_PATCH, Host);
return null; return null;
} }

View File

@ -29,7 +29,6 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
using System;
using XenAdmin.Diagnostics.Checks; using XenAdmin.Diagnostics.Checks;
using XenAPI; using XenAPI;
@ -38,21 +37,23 @@ namespace XenAdmin.Diagnostics.Problems.HostProblem
public class HostNeedsReboot : Information public class HostNeedsReboot : Information
{ {
private readonly Host host; private readonly Host host;
private readonly bool livePatchingRestricted;
private readonly bool livePatchingDisabled;
public HostNeedsReboot(Check check, Host host) public HostNeedsReboot(Check check, Host host, bool livePatchingRestricted = false, bool livePatchingDisabled = false)
: base(check) : base(check)
{ {
this.host = host; this.host = host;
this.livePatchingRestricted = livePatchingRestricted;
this.livePatchingDisabled = livePatchingDisabled;
} }
public override string Title public override string Title => Description;
{
get { return Description; }
}
public override string Description public override string Description => livePatchingRestricted
{ ? string.Format(Messages.UPDATES_WIZARD_REBOOT_NEEDED_LIVEPATCH_RESTRICTED, host.name_label)
get { return String.Format(Messages.UPDATES_WIZARD_REBOOT_NEEDED, host.name_label); } : livePatchingDisabled
} ? string.Format(Messages.UPDATES_WIZARD_REBOOT_NEEDED_LIVEPATCH_DISABLED, host.name_label)
: string.Format(Messages.UPDATES_WIZARD_REBOOT_NEEDED, host.name_label);
} }
} }

View File

@ -438,7 +438,10 @@ namespace XenAdmin.Wizards.PatchingWizard
: new List<XenServerPatch>(); : new List<XenServerPatch>();
rebootChecks.Add(new HostNeedsRebootCheck(host, restartHostPatches)); rebootChecks.Add(new HostNeedsRebootCheck(host, restartHostPatches));
if (restartHostPatches.Any(p => !p.ContainsLivepatch))
if (restartHostPatches.Count > 0 && (restartHostPatches.Any(p => !p.ContainsLivepatch) ||
Helpers.FeatureForbidden(host.Connection, Host.RestrictLivePatching) ||
Helpers.GetPoolOfOne(host.Connection)?.live_patching_disabled == true))
evacuateChecks.Add(new AssertCanEvacuateCheck(host)); evacuateChecks.Add(new AssertCanEvacuateCheck(host));
foreach (var p in us[host]) foreach (var p in us[host])

View File

@ -35692,6 +35692,24 @@ namespace XenAdmin {
} }
} }
/// <summary>
/// Looks up a localized string similar to {0}: This server needs to be rebooted after the update is applied, because live patching is disabled..
/// </summary>
public static string UPDATES_WIZARD_REBOOT_NEEDED_LIVEPATCH_DISABLED {
get {
return ResourceManager.GetString("UPDATES_WIZARD_REBOOT_NEEDED_LIVEPATCH_DISABLED", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {0}: This server needs to be rebooted after the update is applied, because it is not licensed for live patching..
/// </summary>
public static string UPDATES_WIZARD_REBOOT_NEEDED_LIVEPATCH_RESTRICTED {
get {
return ResourceManager.GetString("UPDATES_WIZARD_REBOOT_NEEDED_LIVEPATCH_RESTRICTED", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Rebooted. /// Looks up a localized string similar to Rebooted.
/// </summary> /// </summary>

View File

@ -12322,6 +12322,12 @@ Please check your settings and try again.</value>
<data name="UPDATES_WIZARD_REBOOT_NEEDED" xml:space="preserve"> <data name="UPDATES_WIZARD_REBOOT_NEEDED" xml:space="preserve">
<value>{0}: This server needs to be rebooted after the update is applied.</value> <value>{0}: This server needs to be rebooted after the update is applied.</value>
</data> </data>
<data name="UPDATES_WIZARD_REBOOT_NEEDED_LIVEPATCH_DISABLED" xml:space="preserve">
<value>{0}: This server needs to be rebooted after the update is applied, because live patching is disabled.</value>
</data>
<data name="UPDATES_WIZARD_REBOOT_NEEDED_LIVEPATCH_RESTRICTED" xml:space="preserve">
<value>{0}: This server needs to be rebooted after the update is applied, because it is not licensed for live patching.</value>
</data>
<data name="UPDATES_WIZARD_REMOVING_UPDATE" xml:space="preserve"> <data name="UPDATES_WIZARD_REMOVING_UPDATE" xml:space="preserve">
<value>Deleting update installation file {0} from {1}... </value> <value>Deleting update installation file {0} from {1}... </value>
</data> </data>