CA-227067: General tab: XenCenter does not show Reboot required when Toolstack restart required

On the General tab XenCenter shows a list of updates that requires the host to be restarted. This is shown for applied updates for which the required guidance hasn't been done (eg. restartHost or restartAgent after-apply-guidances)

This commit fixes a regression that caused restartToolstack warnings to be not shown in the list of warnings.

The displayed messages are also improved, XenCenter will show Toolstack restart or host restart appropriately and not just restart only as it used to.

Signed-off-by: Gabor Apati-Nagy <gabor.apati-nagy@citrix.com>
This commit is contained in:
Gabor Apati-Nagy 2016-10-27 14:27:20 +01:00
parent e36eea4a8e
commit fa7dbc14ed
3 changed files with 49 additions and 13 deletions

View File

@ -1825,17 +1825,11 @@ namespace XenAdmin.TabPages
{
double applyTime = Util.ToUnixTime(patch.AppliedOn(host));
if (patch.after_apply_guidance.Contains(after_apply_guidance.restartHost)
&& applyTime > bootTime)
if (patch.after_apply_guidance.Contains(after_apply_guidance.restartHost) && applyTime > bootTime
|| patch.after_apply_guidance.Contains(after_apply_guidance.restartXAPI) && applyTime > agentStart)
{
warnings.Add(CreateWarningRow(host, patch));
}
else if (patch.after_apply_guidance.Contains(after_apply_guidance.restartXAPI)
&& applyTime > agentStart)
{
// Actually, it only needs xapi restart, but we have no UI to do that.
warnings.Add(CreateWarningRow(host, patch));
}
}
return warnings;
}
@ -1848,6 +1842,8 @@ namespace XenAdmin.TabPages
private List<KeyValuePair<String, String>> CheckHostUpdatesRequiringReboot(Host host)
{
var warnings = new List<KeyValuePair<String, String>>();
// Updates that require host restart
var updateRefs = host.updates_requiring_reboot;
foreach (var updateRef in updateRefs)
{
@ -1855,21 +1851,49 @@ namespace XenAdmin.TabPages
warnings.Add(CreateWarningRow(host, update));
}
// For Toolstack restart, legacy code has to be used to determine this - pool_patches are still populated for backward compatibility
List<Pool_patch> patches = host.AppliedPatches();
double bootTime = host.BootTime;
double agentStart = host.AgentStartTime;
if (bootTime == 0.0 || agentStart == 0.0)
return warnings;
foreach (Pool_patch patch in patches)
{
double applyTime = Util.ToUnixTime(patch.AppliedOn(host));
if (patch.after_apply_guidance.Contains(after_apply_guidance.restartXAPI)
&& applyTime > agentStart)
{
warnings.Add(CreateWarningRow(host, patch));
}
}
return warnings;
}
private KeyValuePair<string, string> CreateWarningRow(Host host, Pool_patch patch)
{
var key = String.Format(Messages.GENERAL_PANEL_UPDATE_KEY, patch.Name, host.Name);
var value = string.Format(Messages.GENERAL_PANEL_UPDATE_WARNING, host.Name, patch.Name);
string value = string.Empty;
if (patch.after_apply_guidance.Contains(after_apply_guidance.restartHost))
{
value = string.Format(Messages.GENERAL_PANEL_UPDATE_REBOOT_WARNING, host.Name, patch.Name);
}
else if (patch.after_apply_guidance.Contains(after_apply_guidance.restartXAPI))
{
value = string.Format(Messages.GENERAL_PANEL_UPDATE_RESTART_TOOLSTACK_WARNING, host.Name, patch.Name);
}
return new KeyValuePair<string, string>(key, value);
}
private KeyValuePair<string, string> CreateWarningRow(Host host, Pool_update update)
{
var key = String.Format(Messages.GENERAL_PANEL_UPDATE_KEY, update.Name, host.Name);
var value = string.Format(Messages.GENERAL_PANEL_UPDATE_WARNING, host.Name, update.Name);
var value = string.Format(Messages.GENERAL_PANEL_UPDATE_REBOOT_WARNING, host.Name, update.Name);
return new KeyValuePair<string, string>(key, value);
}

View File

@ -15785,9 +15785,18 @@ namespace XenAdmin {
/// <summary>
/// Looks up a localized string similar to The server &apos;{0}&apos; needs to be rebooted for update &apos;{1}&apos; to take effect.
/// </summary>
public static string GENERAL_PANEL_UPDATE_WARNING {
public static string GENERAL_PANEL_UPDATE_REBOOT_WARNING {
get {
return ResourceManager.GetString("GENERAL_PANEL_UPDATE_WARNING", resourceCulture);
return ResourceManager.GetString("GENERAL_PANEL_UPDATE_REBOOT_WARNING", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Toolstack on server &apos;{0}&apos; needs to be restarted for update &apos;{1}&apos; to take effect.
/// </summary>
public static string GENERAL_PANEL_UPDATE_RESTART_TOOLSTACK_WARNING {
get {
return ResourceManager.GetString("GENERAL_PANEL_UPDATE_RESTART_TOOLSTACK_WARNING", resourceCulture);
}
}

View File

@ -5533,9 +5533,12 @@ Would you like to eject these ISOs before continuing?</value>
<data name="GENERAL_PANEL_UPDATE_KEY" xml:space="preserve">
<value>{0} on {1}</value>
</data>
<data name="GENERAL_PANEL_UPDATE_WARNING" xml:space="preserve">
<data name="GENERAL_PANEL_UPDATE_REBOOT_WARNING" xml:space="preserve">
<value>The server '{0}' needs to be rebooted for update '{1}' to take effect</value>
</data>
<data name="GENERAL_PANEL_UPDATE_RESTART_TOOLSTACK_WARNING" xml:space="preserve">
<value>Toolstack on server '{0}' needs to be restarted for update '{1}' to take effect</value>
</data>
<data name="GENERAL_SR_CONTEXT_REPAIR" xml:space="preserve">
<value>Repair</value>
</data>