Merge pull request #1513 from GaborApatiNagy/REQ-411_2

CP-21504: Updates wizard: Automated mode for new versions that are av…
This commit is contained in:
Mihaela Stoica 2017-03-24 14:20:26 +00:00 committed by GitHub
commit ab89a26171

View File

@ -568,8 +568,18 @@ namespace XenAdmin.Core
}
}
public static UpgradeSequence GetUpgradeSequence(IXenConnection conn, XenServerPatchAlert alert)
/// <summary>
/// Gets an upgrade sequence that contains a version upgrade, optionally followed by the minimal patches for the new version
/// </summary>
/// <param name="conn">Connection for the pool</param>
/// <param name="alert">The alert that refers the version-update</param>
/// <param name="updateTheNewVersion">Also add the minimum patches for the new version (true) or not (false).</param>
/// <returns></returns>
public static UpgradeSequence GetUpgradeSequence(IXenConnection conn, XenServerPatchAlert alert, bool updateTheNewVersion)
{
Debug.Assert(conn != null);
Debug.Assert(alert != null);
var uSeq = new UpgradeSequence();
if (XenServerVersions == null)
@ -581,28 +591,24 @@ namespace XenAdmin.Core
var version = GetCommonServerVersionOfHostsInAConnection(conn, XenServerVersions);
// the pool has to be homogeneous
if (version != null)
{
//if it's a version updgrade the min sequence will be this patch (the upgrade) and the min patches for the new version
if (alert.NewServerVersion != null)
{
if (alert.NewServerVersion.MinimalPatches == null)
return null;
uSeq.MinimalPatches = new List<XenServerPatch>();
uSeq.MinimalPatches.Add(alert.Patch);
uSeq.MinimalPatches.AddRange(alert.NewServerVersion.MinimalPatches);
List<Host> hosts = conn.Cache.Hosts.ToList();
foreach (Host h in hosts)
// if it's a version updgrade the min sequence will be this patch (the upgrade) and the min patches for the new version
if (updateTheNewVersion && alert.NewServerVersion != null && alert.NewServerVersion.MinimalPatches != null)
{
uSeq[h] = GetUpgradeSequenceForHost(h, uSeq.MinimalPatches);
uSeq.MinimalPatches.AddRange(alert.NewServerVersion.MinimalPatches);
}
conn.Cache.Hosts.ToList().ForEach(h =>
uSeq[h] = GetUpgradeSequenceForHost(h, uSeq.MinimalPatches)
);
return uSeq;
}
}
return null;
}