From f9d8b4dea97f26549a591dd6b9ccd4c35876d305 Mon Sep 17 00:00:00 2001 From: Gabor Apati-Nagy Date: Wed, 10 Aug 2016 10:48:22 +0100 Subject: [PATCH] CA-217862: Batch updates: Install dundee released hotfixes in Batch fails when pool slave is not reachable and pool partially upgraded Partially upgraded pools are not supported. If the versions of servers mismatch in a pool, Automatic updating will be disabled with the appropriate info message. Signed-off-by: Gabor Apati-Nagy --- XenAdmin/Core/Updates.cs | 80 +++++++++++++------ .../PatchingWizard_SelectServers.cs | 9 +++ XenModel/Messages.Designer.cs | 9 +++ XenModel/Messages.resx | 3 + 4 files changed, 78 insertions(+), 23 deletions(-) diff --git a/XenAdmin/Core/Updates.cs b/XenAdmin/Core/Updates.cs index 8a61d6afb..42ff4e9bd 100644 --- a/XenAdmin/Core/Updates.cs +++ b/XenAdmin/Core/Updates.cs @@ -439,8 +439,7 @@ namespace XenAdmin.Core if (serverVersions.Count != 0) { - var minimumPatches = new List(); - minimumPatches = serverVersions[0].MinimalPatches; + var minimumPatches = serverVersions[0].MinimalPatches; if (minimumPatches == null) //unknown return recommendedPatches; @@ -461,33 +460,19 @@ namespace XenAdmin.Core if (master == null) return null; - List hosts = conn.Cache.Hosts.ToList(); + var version = GetCommonServerVersionOfHostsInAConnection(conn); - var serverVersions = XenServerVersions.FindAll(version => + if (version != null) { - if (version.BuildNumber != string.Empty) - return (master.BuildNumberRaw == version.BuildNumber); - - return Helpers.HostProductVersionWithOEM(master) == version.VersionAndOEM - || (version.Oem != null && Helpers.OEMName(master).StartsWith(version.Oem) - && Helpers.HostProductVersion(master) == version.Version.ToString()); - }); - - List allPatches = new List(); - - if (serverVersions.Count > 0) - { - // Take all the hotfixes for this version - allPatches.AddRange(serverVersions[0].Patches); - - if (serverVersions[0].MinimalPatches == null) + if (version.MinimalPatches == null) return null; - uSeq.MinimalPatches = serverVersions[0].MinimalPatches; + uSeq.MinimalPatches = version.MinimalPatches; + List hosts = conn.Cache.Hosts.ToList(); foreach (Host h in hosts) { - uSeq[h] = GetUpgradeSequenceForHost(h, allPatches, uSeq.MinimalPatches); + uSeq[h] = GetUpgradeSequenceForHost(h, uSeq.MinimalPatches); } } else @@ -498,7 +483,56 @@ namespace XenAdmin.Core return uSeq; } - private static List GetUpgradeSequenceForHost(Host h, List allPatches, List latestPatches) + /// + /// Returns a XenServerVersion if all hosts of the pool has the same version + /// Returns null if it is unknown or they don't match + /// + /// + private static XenServerVersion GetCommonServerVersionOfHostsInAConnection(IXenConnection connection) + { + XenServerVersion xenServerVersion = null; + + if (connection == null) + return null; + + List hosts = connection.Cache.Hosts.ToList(); + + foreach (Host host in hosts) + { + var hostVersions = 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()); + }); + + var foundVersion = hostVersions.FirstOrDefault(); + + if (foundVersion == null) + { + return null; + } + else + { + if (xenServerVersion == null) + { + xenServerVersion = foundVersion; + } + else + { + if (xenServerVersion != foundVersion) + return null; + } + } + } + + return xenServerVersion; + } + + private static List GetUpgradeSequenceForHost(Host h, List latestPatches) { var sequence = new List(); var appliedPatches = h.AppliedPatches(); diff --git a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_SelectServers.cs b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_SelectServers.cs index 6f48cb9ce..5d70bc37a 100644 --- a/XenAdmin/Wizards/PatchingWizard/PatchingWizard_SelectServers.cs +++ b/XenAdmin/Wizards/PatchingWizard/PatchingWizard_SelectServers.cs @@ -193,6 +193,15 @@ namespace XenAdmin.Wizards.PatchingWizard return; } + var pool = Helpers.GetPool(host.Connection); + if (pool != null && !pool.IsPoolFullyUpgraded) //partially upgraded pool is not supported + { + row.Enabled = false; + row.Cells[3].ToolTipText = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_AUTO_UPDATE_NOT_SUPPORTED_PARTIALLY_UPGRADED; + + return; + } + //if there is a host missing from the upgrade sequence if (host.Connection.Cache.Hosts.Any(h => !us.Keys.Contains(h))) { diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index ec23a1f28..9e63de6f3 100755 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -26080,6 +26080,15 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to Automatic update is not supported on partially upgraded [XenServer] pools.. + /// + public static string PATCHINGWIZARD_SELECTSERVERPAGE_AUTO_UPDATE_NOT_SUPPORTED_PARTIALLY_UPGRADED { + get { + return ResourceManager.GetString("PATCHINGWIZARD_SELECTSERVERPAGE_AUTO_UPDATE_NOT_SUPPORTED_PARTIALLY_UPGRADED", resourceCulture); + } + } + /// /// Looks up a localized string similar to Cannot install supplemental packs on this [XenServer] version. /// diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index 24cfba100..d7533c8d3 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -9015,6 +9015,9 @@ However, there is not enough space to perform the repartitioning, so the current Automatic update is not supported on this [XenServer] version + + Automatic update is not supported on partially upgraded [XenServer] pools. + Cannot install supplemental packs on this [XenServer] version