Merge pull request #1014 from GaborApatiNagy/master_batch_new2

CP-15790, CP-17444
This commit is contained in:
Mihaela Stoica 2016-06-08 14:19:42 +01:00
commit 247a44d7ab
9 changed files with 104 additions and 12 deletions

View File

@ -379,6 +379,11 @@ namespace XenAdmin.Core
get { return ReadInstalledKey(ADDITIONAL_FEATURES); }
}
public static string CustomUpdatesXmlLocation
{
get { return ReadKey(CUSTOM_UPDATES_XML_LOCATION); }
}
private const string SSL_CERTIFICATES_CHANGED_ONLY = "CHANGED";
private const string SSL_CERTIFICATES_ALL = "ALL";
private const string SSL_CERTIFICATES_KEY = "ForceSSLCertificates";
@ -402,6 +407,7 @@ namespace XenAdmin.Core
private const string HEALTH_CHECK_PRODUCT_KEY = "HealthCheckProductKey";
private const string HIDDEN_FEATURES = "HiddenFeatures";
private const string ADDITIONAL_FEATURES = "AdditionalFeatures";
private const string CUSTOM_UPDATES_XML_LOCATION = "CheckForUpdatesXmlLocationOverride";
}
public enum SSLCertificateTypes { None, Changed, All }

View File

@ -197,7 +197,7 @@ namespace XenAdmin.Core
Properties.Settings.Default.AllowXenCenterUpdates || force,
Properties.Settings.Default.AllowXenServerUpdates || force,
Properties.Settings.Default.AllowPatchesUpdates || force,
Branding.CheckForUpdatesUrl);
Updates.CheckForUpdatesUrl);
{
action.Completed += actionCompleted;
}
@ -209,6 +209,14 @@ namespace XenAdmin.Core
}
}
public static string CheckForUpdatesUrl
{
get
{
return Registry.CustomUpdatesXmlLocation ?? Branding.CheckForUpdatesUrl;
}
}
private static void actionCompleted(ActionBase sender)
{
Program.AssertOffEventThread();
@ -406,15 +414,52 @@ namespace XenAdmin.Core
return alerts;
}
/// <summary>
/// This method returns the minimal set of patches for a host if this class already has information about them. Otherwise it returns empty list.
/// Calling this function will not initiate a download or update.
/// </summary>
/// <param name="host"></param>
/// <returns></returns>
public static List<XenServerPatch> RecommendedPatchesForHost(Host host)
{
var recommendedPatches = new List<XenServerPatch>();
if (XenServerVersions == null)
return recommendedPatches;
var serverVersions = XenServerVersions.FindAll(version =>
{
if (version.BuildNumber != string.Empty)
return (host.BuildNumberRaw == version.BuildNumber);
return Helpers.HostProductVersionWithOEM(host) == version.VersionAndOEM
|| (version.Oem != null && Helpers.OEMName(host).StartsWith(version.Oem)
&& Helpers.HostProductVersion(host) == version.Version.ToString());
});
if (serverVersions.Count != 0)
{
var minimumPatches = new List<XenServerPatch>();
minimumPatches = serverVersions[0].MinimalPatches;
var appliedPatches = host.AppliedPatches();
recommendedPatches = minimumPatches.FindAll(p => !appliedPatches.Any(ap => string.Equals(ap.uuid, p.Uuid, StringComparison.OrdinalIgnoreCase)));
}
return recommendedPatches;
}
public static UpgradeSequence GetUpgradeSequence(IXenConnection conn)
{
var uSeq = new UpgradeSequence();
Host master = Helpers.GetMaster(conn);
List<Host> hosts = conn.Cache.Hosts.ToList();
if (master == null)
return null;
List<Host> hosts = conn.Cache.Hosts.ToList();
var serverVersions = XenServerVersions.FindAll(version =>
{
if (version.BuildNumber != string.Empty)

View File

@ -676,6 +676,12 @@ namespace XenAdmin.TabPages
s.AddEntry(FriendlyName("Pool_patch.applied"), hostAppliedPatches(host));
}
var recommendedPatches = RecommendedPatchesForHost(host);
if (!string.IsNullOrEmpty(recommendedPatches))
{
s.AddEntry(FriendlyName("Pool_patch.recommended"), recommendedPatches);
}
// add supplemental packs
var suppPacks = hostInstalledSuppPacks(host);
if (!string.IsNullOrEmpty(suppPacks))
@ -1613,6 +1619,17 @@ namespace XenAdmin.TabPages
return true;
}
private string RecommendedPatchesForHost(Host host)
{
var result = new List<string>();
var recommendedPatches = Updates.RecommendedPatchesForHost(host);
foreach (var patch in recommendedPatches)
result.Add(patch.Name);
return string.Join(Environment.NewLine, result.ToArray());
}
private string hostAppliedPatches(Host host)
{
List<string> result = new List<string>();

View File

@ -184,7 +184,7 @@ namespace XenAdmin.Wizards.PatchingWizard
}
else //In Automatic Mode
{
var downloadUpdatesAction = new DownloadUpdatesXmlAction(false, true, true);
var downloadUpdatesAction = new DownloadUpdatesXmlAction(false, true, true, Updates.CheckForUpdatesUrl);
var dialog = new ActionProgressDialog(downloadUpdatesAction, ProgressBarStyle.Marquee);
dialog.ShowDialog(this.Parent); //Will block until dialog closes, action completed

View File

@ -36,6 +36,7 @@ using XenAPI;
using System.IO;
using System.Xml;
using XenAdmin.Core;
using System.Diagnostics;
namespace XenAdmin.Actions
@ -76,6 +77,8 @@ namespace XenAdmin.Actions
public DownloadUpdatesXmlAction(bool checkForXenCenter, bool checkForServerVersion, bool checkForPatches, string checkForUpdatesUrl)
: base(null, "_get_updates", "_get_updates", true)
{
Debug.Assert(checkForUpdatesUrl != null, "Parameter checkForUpdatesUrl should not be null. This class does not default its value anymore.");
XenServerPatches = new List<XenServerPatch>();
XenServerVersions = new List<XenServerVersion>();
XenCenterVersions = new List<XenCenterVersion>();
@ -83,10 +86,10 @@ namespace XenAdmin.Actions
_checkForXenCenter = checkForXenCenter;
_checkForServerVersion = checkForServerVersion;
_checkForPatches = checkForPatches;
_checkForUpdatesUrl = string.IsNullOrEmpty(checkForUpdatesUrl) ? InvisibleMessages.XENSERVER_UPDATE_URL : checkForUpdatesUrl;
_checkForUpdatesUrl = checkForUpdatesUrl;
}
public DownloadUpdatesXmlAction(bool checkForXenCenter, bool checkForServerVersion, bool checkForPatches)
protected DownloadUpdatesXmlAction(bool checkForXenCenter, bool checkForServerVersion, bool checkForPatches)
: this(checkForXenCenter, checkForServerVersion, checkForPatches, null)
{ }
@ -288,11 +291,20 @@ namespace XenAdmin.Actions
protected virtual XmlDocument FetchCheckForUpdatesXml(string location)
{
XmlDocument xdoc;
var xdoc = new XmlDocument();
var uri = new Uri(location);
if (uri.IsFile)
{
xdoc.Load(location);
}
else
{
using (Stream xmlstream = HTTPHelper.GET(new Uri(location), Connection, false, true))
{
xdoc = Helpers.LoadXmlDocument(xmlstream);
}
}
return xdoc;
}
}

View File

@ -2652,6 +2652,15 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to Recommended Patches.
/// </summary>
public static string Label_Pool_patch_recommended {
get {
return ResourceManager.GetString("Label-Pool_patch.recommended", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Disk space allocations.
/// </summary>
@ -4041,7 +4050,7 @@ namespace XenAdmin {
}
/// <summary>
/// Looks up a localized string similar to Pool &apos;{0}&apos; failed to retrieve placement recommendations from WLB for VM &apos;{1}&apos;..
/// Looks up a localized string similar to Pool &apos;{0}&apos; failed to retrieve placement recommendations from WLB for &apos;{1}&apos;..
/// </summary>
public static string Message_body_wlb_consultation_failed {
get {

View File

@ -1859,4 +1859,7 @@
<data name="Label-host.edition-standard" xml:space="preserve">
<value>[Citrix] [XenServer product] Standard Edition</value>
</data>
<data name="Label-Pool_patch.recommended" xml:space="preserve">
<value>Recommended Patches</value>
</data>
</root>

View File

@ -25604,7 +25604,7 @@ namespace XenAdmin {
}
/// <summary>
/// Looks up a localized string similar to Update process was not completed successfully. Check .
/// Looks up a localized string similar to Update process was not completed successfully..
/// </summary>
public static string PATCHINGWIZARD_AUTOUPDATINGPAGE_ERROR {
get {

View File

@ -8857,7 +8857,7 @@ However, there is not enough space to perform the repartitioning, so the current
<value>Paste</value>
</data>
<data name="PATCHINGWIZARD_AUTOUPDATINGPAGE_ERROR" xml:space="preserve">
<value>Update process was not completed successfully. Check </value>
<value>Update process was not completed successfully.</value>
</data>
<data name="PATCHINGWIZARD_AUTOUPDATINGPAGE_ERRORS_OCCURED" xml:space="preserve">
<value>Following errors occured while automatic upgrade was in progress:</value>