diff --git a/CFUValidator/CFUValidator.cs b/CFUValidator/CFUValidator.cs index ea29bfceb..08b057c9f 100644 --- a/CFUValidator/CFUValidator.cs +++ b/CFUValidator/CFUValidator.cs @@ -118,7 +118,7 @@ namespace CFUValidator var xcupdateAlerts = XenAdmin.Core.Updates.NewXenCenterUpdateAlerts(xenCenterVersions, new Version(ServerVersion)); Status = "Determining XenServer update required..."; - var updateAlert = XenAdmin.Core.Updates.NewXenServerVersionAlert(xenServerVersions); + var updateAlerts = XenAdmin.Core.Updates.NewXenServerVersionAlerts(xenServerVersions); Status = "Determining patches required..."; var patchAlerts = XenAdmin.Core.Updates.NewXenServerPatchAlerts(xenServerVersions, xenServerPatches).Where(alert => !alert.CanIgnore).ToList(); @@ -135,7 +135,7 @@ namespace CFUValidator RunValidators(validators); Status = "Generating summary..."; - GeneratePatchSummary(patchAlerts, validators, updateAlert, xcupdateAlerts); + GeneratePatchSummary(patchAlerts, validators, updateAlerts, xcupdateAlerts); } private void CheckProvidedVersionNumber(List xenServerVersions) @@ -196,11 +196,11 @@ namespace CFUValidator } private void GeneratePatchSummary(List alerts, List validators, - XenServerVersionAlert updateAlert, List xcupdateAlerts) + List updateAlerts, List xcupdateAlerts) { OuputComponent oc = new OutputTextOuputComponent(XmlLocation, ServerVersion); XenCenterUpdateDecorator xcud = new XenCenterUpdateDecorator(oc, xcupdateAlerts); - XenServerUpdateDecorator xsud = new XenServerUpdateDecorator(xcud, updateAlert); + XenServerUpdateDecorator xsud = new XenServerUpdateDecorator(xcud, updateAlerts); PatchAlertDecorator pad = new PatchAlertDecorator(xsud, alerts); AlertFeatureValidatorDecorator afdCoreFields = new AlertFeatureValidatorDecorator(pad, validators.First(v => v is CorePatchDetailsValidator), diff --git a/CFUValidator/OutputDecorators/XenServerUpdateDecorator.cs b/CFUValidator/OutputDecorators/XenServerUpdateDecorator.cs index 2384d8929..c7513e388 100644 --- a/CFUValidator/OutputDecorators/XenServerUpdateDecorator.cs +++ b/CFUValidator/OutputDecorators/XenServerUpdateDecorator.cs @@ -39,21 +39,21 @@ namespace CFUValidator.OutputDecorators { class XenServerUpdateDecorator : Decorator { - private readonly XenServerVersionAlert alert; + private readonly List alerts; private const string header = "XenServer updates required:"; private const string updateNotFound = "XenServer update could not be found"; - public XenServerUpdateDecorator(OuputComponent ouputComponent, XenServerVersionAlert alert) + public XenServerUpdateDecorator(OuputComponent ouputComponent, List alerts) { SetComponent(ouputComponent); - this.alert = alert; + this.alerts = alerts; } public override StringBuilder Generate() { StringBuilder sb = base.Generate(); sb.AppendLine(header); - sb.AppendLine(alert == null ? updateNotFound : alert.Version.Name); + sb.AppendLine(alerts == null || alerts.Count == 0 ? updateNotFound : string.Join(",", alerts.SelectMany(a => a.Version.Name))); return sb.AppendLine(String.Empty); } } diff --git a/XenAdmin/Core/Updates.cs b/XenAdmin/Core/Updates.cs index 60fd7d01c..bb7ed635e 100644 --- a/XenAdmin/Core/Updates.cs +++ b/XenAdmin/Core/Updates.cs @@ -272,9 +272,9 @@ namespace XenAdmin.Core if (xenCenterAlerts != null) updateAlerts.AddRange(xenCenterAlerts.Where(a=>!a.IsDismissed())); - var xenServerUpdateAlert = NewXenServerVersionAlert(XenServerVersionsForAutoCheck); - if (xenServerUpdateAlert != null && !xenServerUpdateAlert.CanIgnore) - updateAlerts.Add(xenServerUpdateAlert); + var xenServerUpdateAlerts = NewXenServerVersionAlerts(XenServerVersionsForAutoCheck); + if (xenServerUpdateAlerts != null) + updateAlerts.AddRange(xenServerUpdateAlerts.Where(a=>!a.CanIgnore)); var xenServerPatchAlerts = NewXenServerPatchAlerts(XenServerVersions, XenServerPatches); if (xenServerPatchAlerts != null) @@ -703,16 +703,28 @@ namespace XenAdmin.Core } } - public static XenServerVersionAlert NewXenServerVersionAlert(List xenServerVersions) + public static List NewXenServerVersionAlerts(List xenServerVersions) { if (Helpers.CommonCriteriaCertificationRelease) return null; var latestVersion = xenServerVersions.FindAll(item => item.Latest).OrderByDescending(v => v.Version).FirstOrDefault(); - if (latestVersion == null) - return null; + var latestCrVersion = xenServerVersions.FindAll(item => item.LatestCr).OrderByDescending(v => v.Version).FirstOrDefault(); - var alert = new XenServerVersionAlert(latestVersion); + List alerts = new List(); + + if (latestVersion != null) + alerts.Add(CreateAlertForXenServerVersion(latestVersion)); + + if (latestCrVersion != null && latestCrVersion != latestVersion) + alerts.Add(CreateAlertForXenServerVersion(latestCrVersion)); + + return alerts; + } + + private static XenServerVersionAlert CreateAlertForXenServerVersion(XenServerVersion version) + { + var alert = new XenServerVersionAlert(version); foreach (IXenConnection xc in ConnectionsManager.XenConnectionsCopy) { @@ -725,7 +737,7 @@ namespace XenAdmin.Core if (master == null || pool == null) continue; - var outOfDateHosts = hosts.Where(host => new Version(Helpers.HostProductVersion(host)) < latestVersion.Version); + var outOfDateHosts = hosts.Where(host => new Version(Helpers.HostProductVersion(host)) < version.Version); if (outOfDateHosts.Count() == hosts.Count) alert.IncludeConnection(xc); @@ -736,14 +748,13 @@ namespace XenAdmin.Core return alert; } - public static void CheckServerVersion() { - var alert = NewXenServerVersionAlert(XenServerVersionsForAutoCheck); - if (alert == null) + var alerts = NewXenServerVersionAlerts(XenServerVersionsForAutoCheck); + if (alerts == null || alerts.Count == 0) return; - CheckUpdate(alert); + alerts.ForEach(a => CheckUpdate(a)); } public static void CheckServerPatches() @@ -752,8 +763,7 @@ namespace XenAdmin.Core if (alerts == null) return; - foreach (var alert in alerts) - CheckUpdate(alert); + alerts.ForEach(a => CheckUpdate(a)); } private static void CheckUpdate(XenServerUpdateAlert alert) diff --git a/XenAdminTests/UnitTests/AlertTests/XenServerUpdateAlertTests.cs b/XenAdminTests/UnitTests/AlertTests/XenServerUpdateAlertTests.cs index 57da781c0..4654e9152 100644 --- a/XenAdminTests/UnitTests/AlertTests/XenServerUpdateAlertTests.cs +++ b/XenAdminTests/UnitTests/AlertTests/XenServerUpdateAlertTests.cs @@ -55,7 +55,7 @@ namespace XenAdminTests.UnitTests.AlertTests [Test] public void TestAlertWithConnectionAndHosts() { - XenServerVersion ver = new XenServerVersion("1.2.3", "name", true, "http://url", new List(), new List(), new DateTime(2011, 4, 1).ToString(), "123"); + XenServerVersion ver = new XenServerVersion("1.2.3", "name", true, false, "http://url", new List(), new List(), new DateTime(2011, 4, 1).ToString(), "123"); var alert = new XenServerVersionAlert(ver); alert.IncludeConnection(connA.Object); alert.IncludeConnection(connB.Object); @@ -83,7 +83,7 @@ namespace XenAdminTests.UnitTests.AlertTests [Test] public void TestAlertWithHostsAndNoConnection() { - XenServerVersion ver = new XenServerVersion("1.2.3", "name", true, "http://url", new List(), new List(), new DateTime(2011, 4, 1).ToString(), "123"); + XenServerVersion ver = new XenServerVersion("1.2.3", "name", true, false, "http://url", new List(), new List(), new DateTime(2011, 4, 1).ToString(), "123"); var alert = new XenServerVersionAlert(ver); alert.IncludeHosts(new List { hostA.Object, hostB.Object }); @@ -109,7 +109,7 @@ namespace XenAdminTests.UnitTests.AlertTests [Test] public void TestAlertWithConnectionAndNoHosts() { - XenServerVersion ver = new XenServerVersion("1.2.3", "name", true, "http://url", new List(), new List(), new DateTime(2011, 4, 1).ToString(), "123"); + XenServerVersion ver = new XenServerVersion("1.2.3", "name", true, false, "http://url", new List(), new List(), new DateTime(2011, 4, 1).ToString(), "123"); var alert = new XenServerVersionAlert(ver); alert.IncludeConnection(connA.Object); alert.IncludeConnection(connB.Object); @@ -136,7 +136,7 @@ namespace XenAdminTests.UnitTests.AlertTests [Test] public void TestAlertWithNoConnectionAndNoHosts() { - XenServerVersion ver = new XenServerVersion("1.2.3", "name", true, "http://url", new List(), new List(), new DateTime(2011, 4, 1).ToString(), "123"); + XenServerVersion ver = new XenServerVersion("1.2.3", "name", true, false, "http://url", new List(), new List(), new DateTime(2011, 4, 1).ToString(), "123"); var alert = new XenServerVersionAlert(ver); IUnitTestVerifier validator = new VerifyGetters(alert); diff --git a/XenAdminTests/UnitTests/BatchUpdatesTests/BatchUpdatesTests.cs b/XenAdminTests/UnitTests/BatchUpdatesTests/BatchUpdatesTests.cs index c747b5062..9923a4158 100644 --- a/XenAdminTests/UnitTests/BatchUpdatesTests/BatchUpdatesTests.cs +++ b/XenAdminTests/UnitTests/BatchUpdatesTests/BatchUpdatesTests.cs @@ -76,7 +76,7 @@ namespace XenAdminTests.UnitTests { var serverVersions = new List(); - var version = new XenServerVersion("7.0.0", "XenServer Test 7", true, "", new List(), new List(), DateTime.MinValue.ToString(), "buildNo"); + var version = new XenServerVersion("7.0.0", "XenServer Test 7", true, false, "", new List(), new List(), DateTime.MinValue.ToString(), "buildNo"); for (int ii = 0; ii < numberOfPatches; ii++) { var patch = new XenServerPatch("patch_uuid_" + ii, "patch name " + ii, "patch description" + ii, "", "", "1.0", "", "", "1970-01-01T00:00:00Z", "", "1000"); diff --git a/XenModel/Actions/Updates/DownloadUpdatesXmlAction.cs b/XenModel/Actions/Updates/DownloadUpdatesXmlAction.cs index 60ee2f323..72892ca8a 100644 --- a/XenModel/Actions/Updates/DownloadUpdatesXmlAction.cs +++ b/XenModel/Actions/Updates/DownloadUpdatesXmlAction.cs @@ -233,6 +233,7 @@ namespace XenAdmin.Actions string version_oem = ""; string name = ""; bool is_latest = false; + bool is_latest_cr = false; string url = ""; string timestamp = ""; string buildNumber = ""; @@ -245,6 +246,8 @@ namespace XenAdmin.Actions name = attrib.Value; else if (attrib.Name == "latest") is_latest = attrib.Value.ToUpperInvariant() == bool.TrueString.ToUpperInvariant(); + else if (attrib.Name == "latestcr") + is_latest_cr = attrib.Value.ToUpperInvariant() == bool.TrueString.ToUpperInvariant(); else if (attrib.Name == "url") url = attrib.Value; else if (attrib.Name == "timestamp") @@ -285,7 +288,7 @@ namespace XenAdmin.Actions } - XenServerVersions.Add(new XenServerVersion(version_oem, name, is_latest, url, patches, minimalPatches, timestamp, + XenServerVersions.Add(new XenServerVersion(version_oem, name, is_latest, is_latest_cr, url, patches, minimalPatches, timestamp, buildNumber)); } } diff --git a/XenModel/Actions/Updates/XenServerVersion.cs b/XenModel/Actions/Updates/XenServerVersion.cs index 2187d7626..dff2954fd 100644 --- a/XenModel/Actions/Updates/XenServerVersion.cs +++ b/XenModel/Actions/Updates/XenServerVersion.cs @@ -41,6 +41,7 @@ namespace XenAdmin.Core public Version Version; public string Name; public bool Latest; + public bool LatestCr; public string Url; public string Oem; public List Patches; @@ -61,17 +62,19 @@ namespace XenAdmin.Core /// /// /// + /// /// /// /// can be null (see /// /// - public XenServerVersion(string version_oem, string name, bool latest, string url, List patches, List minimumPatches, + public XenServerVersion(string version_oem, string name, bool latest, bool latestCr, string url, List patches, List minimumPatches, string timestamp, string buildNumber) { ParseVersion(version_oem); Name = name; Latest = latest; + LatestCr = latestCr; if (url.StartsWith("/XenServer")) url = UpdateRoot + url; Url = url;