CA-381502: Improved the disabled reason for new servers.

Signed-off-by: Konstantina Chremmou <Konstantina.Chremmou@cloud.com>
This commit is contained in:
Konstantina Chremmou 2023-08-15 21:07:29 +01:00
parent 143974e93d
commit 0d103e9af6
3 changed files with 67 additions and 10 deletions

View File

@ -190,69 +190,90 @@ namespace XenAdmin.Wizards.PatchingWizard
: CanEnableRowNonAutomated(host, out tooltipText);
}
private bool CanEnableRowAutomatedUpdates(Host host, out string tooltipText)
private bool CanEnableRowAutomatedUpdates(Host host, out string cannotEnableReason)
{
var poolOfOne = Helpers.GetPoolOfOne(host.Connection);
// This check is first because it generally can't be fixed, it's a property of the host
if (poolOfOne != null && poolOfOne.IsAutoUpdateRestartsForbidden()) // Forbids update auto restarts
{
tooltipText = Messages.POOL_FORBIDS_AUTOMATED_UPDATES;
cannotEnableReason = Messages.POOL_FORBIDS_AUTOMATED_UPDATES;
return false;
}
var pool = Helpers.GetPool(host.Connection);
if (WizardMode != WizardMode.NewVersion && pool != null && !pool.IsPoolFullyUpgraded()) //partially upgraded pool is not supported
{
tooltipText = string.Format(Messages.PATCHINGWIZARD_SELECTSERVERPAGE_AUTOMATED_UPDATES_NOT_SUPPORTED_PARTIALLY_UPGRADED, BrandManager.ProductBrand);
cannotEnableReason = string.Format(Messages.PATCHINGWIZARD_SELECTSERVERPAGE_AUTOMATED_UPDATES_NOT_SUPPORTED_PARTIALLY_UPGRADED, BrandManager.ProductBrand);
return false;
}
if (Helpers.CloudOrGreater(host))
{
if (poolOfOne?.repositories.Count == 0)
{
cannotEnableReason = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_CDN_REPOS_NOT_CONFIGURED;
return false;
}
if (Helpers.XapiEqualOrGreater_23_18_0(host.Connection))
{
if (poolOfOne?.last_update_sync == Util.GetUnixMinDateTime())
{
cannotEnableReason = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_CDN_NOT_SYNCHRONIZED;
return false;
}
if (host.latest_synced_updates_applied == latest_synced_updates_applied_state.yes)
{
cannotEnableReason = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_CDN_UPDATES_APPLIED;
return false;
}
}
if (!Updates.CdnUpdateInfoPerConnection.TryGetValue(host.Connection, out var updateInfo) ||
updateInfo.HostsWithUpdates.FirstOrDefault(u => u.HostOpaqueRef == host.opaque_ref) == null)
{
tooltipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_SERVER_UP_TO_DATE;
cannotEnableReason = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_CDN_UPDATES_APPLIED;
return false;
}
}
else
{
//check updgrade sequences
//check upgrade sequences
var minimalPatches = WizardMode == WizardMode.NewVersion
? Updates.GetMinimalPatches(host)
: Updates.GetMinimalPatches(host.Connection);
if (minimalPatches == null) //version not supported or too new to have automated updates available
{
tooltipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_SERVER_UP_TO_DATE;
cannotEnableReason = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_SERVER_UP_TO_DATE;
return false;
}
//check all hosts are licensed for automated updates (there may be restrictions on individual hosts)
if (host.Connection.Cache.Hosts.Any(Host.RestrictBatchHotfixApply))
{
tooltipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_HOST_UNLICENSED_FOR_AUTOMATED_UPDATES;
cannotEnableReason = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_HOST_UNLICENSED_FOR_AUTOMATED_UPDATES;
return false;
}
var us = Updates.GetPatchSequenceForHost(host, minimalPatches);
if (us == null)
{
tooltipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_SERVER_NOT_AUTO_UPGRADABLE;
cannotEnableReason = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_SERVER_NOT_AUTO_UPGRADABLE;
return false;
}
//if host is up to date
if (us.Count == 0)
{
tooltipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_SERVER_UP_TO_DATE;
cannotEnableReason = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_SERVER_UP_TO_DATE;
return false;
}
}
tooltipText = null;
cannotEnableReason = null;
return true;
}

View File

@ -30247,6 +30247,33 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to You have never synchronized with the update channel..
/// </summary>
public static string PATCHINGWIZARD_SELECTSERVERPAGE_CDN_NOT_SYNCHRONIZED {
get {
return ResourceManager.GetString("PATCHINGWIZARD_SELECTSERVERPAGE_CDN_NOT_SYNCHRONIZED", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to You have not configured an update channel..
/// </summary>
public static string PATCHINGWIZARD_SELECTSERVERPAGE_CDN_REPOS_NOT_CONFIGURED {
get {
return ResourceManager.GetString("PATCHINGWIZARD_SELECTSERVERPAGE_CDN_REPOS_NOT_CONFIGURED", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to All updates available at the last synchronization have been applied..
/// </summary>
public static string PATCHINGWIZARD_SELECTSERVERPAGE_CDN_UPDATES_APPLIED {
get {
return ResourceManager.GetString("PATCHINGWIZARD_SELECTSERVERPAGE_CDN_UPDATES_APPLIED", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Subscription Advantage required.
/// </summary>

View File

@ -10486,6 +10486,15 @@ This will cancel the update process and may leave your system in an unstable sta
<data name="PATCHINGWIZARD_SELECTSERVERPAGE_CANNOT_INSTALL_UPDATE_COORDINATOR_POST_7_0" xml:space="preserve">
<value>Cannot install updates on this host because the coordinator is running a version higher than {0}</value>
</data>
<data name="PATCHINGWIZARD_SELECTSERVERPAGE_CDN_NOT_SYNCHRONIZED" xml:space="preserve">
<value>You have never synchronized with the update channel.</value>
</data>
<data name="PATCHINGWIZARD_SELECTSERVERPAGE_CDN_REPOS_NOT_CONFIGURED" xml:space="preserve">
<value>You have not configured an update channel.</value>
</data>
<data name="PATCHINGWIZARD_SELECTSERVERPAGE_CDN_UPDATES_APPLIED" xml:space="preserve">
<value>All updates available at the last synchronization have been applied.</value>
</data>
<data name="PATCHINGWIZARD_SELECTSERVERPAGE_HOST_UNLICENSED" xml:space="preserve">
<value>Subscription Advantage required</value>
</data>