CP-18013: [XenCenter] Update host/pool updates pane

Generalising to also support pools. New CheckHostPatchesRequiringReboot method with the same behaviour as old method (return list of KeyValue warning messages). Pool updates on Ely use the union of messages from this method instead of the old one. Also localised the "{hotfix} on {server}" string per todo (hence resx changes).

Signed-off-by: Callum McIntyre <callumiandavid.mcintyre@citrix.com>
This commit is contained in:
Callum McIntyre 2016-08-17 10:45:11 +01:00
parent dffd7507cc
commit 2d089fa9e9
5 changed files with 73 additions and 27 deletions

View File

@ -662,33 +662,24 @@ namespace XenAdmin.TabPages
return;
PDSection s = pdSectionUpdates;
List<KeyValuePair<String, String>> messages;
if (Helpers.ElyOrGreater(host))
{
// As of Ely we use host.patches_requiring_reboot to generate the list of reboot required messages
var patchRefs = host.patches_requiring_reboot;
foreach (var patchRef in patchRefs)
{
var patch = host.Connection.Resolve(patchRef);
var key = patch.NameWithLocation;
var value = string.Format(
Messages.GENERAL_PANEL_UPDATE_WARNING,
patch.Connection.FriendlyName,
patch.Name);
s.AddEntry(key, value);
}
messages = CheckHostPatchesRequiringReboot(host);
}
else
{
// For older versions no change to how messages are generated
List<KeyValuePair<String, String>> messages = CheckServerUpdates(host);
if (messages.Count > 0)
messages = CheckServerUpdates(host);
}
if (messages.Count > 0)
{
foreach (KeyValuePair<String, String> kvp in messages)
{
foreach (KeyValuePair<String, String> kvp in messages)
{
s.AddEntry(kvp.Key, kvp.Value);
}
s.AddEntry(kvp.Key, kvp.Value);
}
}
@ -1720,9 +1711,22 @@ namespace XenAdmin.TabPages
private List<KeyValuePair<String, String>> CheckPoolUpdate(Pool pool)
{
List<KeyValuePair<String, String>> warnings = new List<KeyValuePair<string, string>>();
foreach (Host host in xenObject.Connection.Cache.Hosts)
if (Helpers.ElyOrGreater(pool.Connection))
{
warnings.AddRange(CheckServerUpdates(host));
// As of Ely we use CheckHostPatchesRequiringReboot to get reboot messages for a host
foreach (Host host in xenObject.Connection.Cache.Hosts)
{
warnings.AddRange(CheckHostPatchesRequiringReboot(host));
}
}
else
{
// Earlier versions use the old server updates method
foreach (Host host in xenObject.Connection.Cache.Hosts)
{
warnings.AddRange(CheckServerUpdates(host));
}
}
return warnings;
}
@ -1749,23 +1753,47 @@ namespace XenAdmin.TabPages
if (patch.after_apply_guidance.Contains(after_apply_guidance.restartHost)
&& applyTime > bootTime)
{
//TODO: Could we come up with a better key string than foopatch on blahhost? Also needs i18
warnings.Add(new KeyValuePair<String, String>(
String.Format("{0} on {1}", patch.Name, host.Name),
String.Format(Messages.GENERAL_PANEL_UPDATE_WARNING, host.Name, patch.Name)));
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(new KeyValuePair<String, String>(
String.Format("{0} on {1}", patch.Name, host.Name),
String.Format(Messages.GENERAL_PANEL_UPDATE_WARNING, host.Name, patch.Name)));
warnings.Add(CreateWarningRow(host, patch));
}
}
return warnings;
}
/// <summary>
/// Creates a list of warnings for patches that require the host to be rebooted
/// </summary>
/// <param name="host"></param>
/// <returns></returns>
private List<KeyValuePair<String, String>> CheckHostPatchesRequiringReboot(Host host)
{
var warnings = new List<KeyValuePair<String, String>>();
var patchRefs = host.patches_requiring_reboot;
foreach (var patchRef in patchRefs)
{
var patch = host.Connection.Resolve(patchRef);
warnings.Add(CreateWarningRow(host, patch));
}
return warnings;
}
private KeyValuePair<string, string> CreateWarningRow(Host host, Pool_patch patch)
{
//TODO: Could we come up with a better key string than foopatch on blahhost?
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);
return new KeyValuePair<string, string>(key, value);
}
private static string GetUUID(IXenObject o)
{
return o.Get("uuid") as String;

View File

@ -15429,6 +15429,15 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to {0} on {1}.
/// </summary>
public static string GENERAL_PANEL_UPDATE_KEY {
get {
return ResourceManager.GetString("GENERAL_PANEL_UPDATE_KEY", resourceCulture);
}
}
/// <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>

View File

@ -12963,4 +12963,7 @@ To learn more about the [XenServer] Active Directory feature or to start a [XenS
<data name="LIVE_PATCHING" xml:space="preserve">
<value>Live Patching</value>
</data>
<data name="GENERAL_PANEL_UPDATE_KEY" xml:space="preserve">
<value>{0} on {1}</value>
</data>
</root>

View File

@ -5414,6 +5414,9 @@ Would you like to eject these ISOs before continuing?</value>
<data name="GENERAL_PAGE_VM_APPLIANCE_SETTINGS" xml:space="preserve">
<value>Enter the vApp name and an optional description.</value>
</data>
<data name="GENERAL_PANEL_UPDATE_KEY" xml:space="preserve">
<value>{0} on {1}</value>
</data>
<data name="GENERAL_PANEL_UPDATE_WARNING" xml:space="preserve">
<value>The server '{0}' needs to be rebooted for update '{1}' to take effect</value>
</data>

View File

@ -12962,4 +12962,7 @@ VM 克隆使用文件管理器的快照和克隆功能来实现高性能,并
<data name="LIVE_PATCHING" xml:space="preserve">
<value>Live Patching</value>
</data>
<data name="GENERAL_PANEL_UPDATE_KEY" xml:space="preserve">
<value>{0} on {1}</value>
</data>
</root>