mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-12-24 19:29:51 +01:00
Merge pull request #1487 from GaborApatiNagy/master_CFU
CP-21172: Support alerts for LTSR and CR XS versions at the same time
This commit is contained in:
commit
42d6331a26
@ -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<XenServerVersion> xenServerVersions)
|
||||
@ -196,11 +196,11 @@ namespace CFUValidator
|
||||
}
|
||||
|
||||
private void GeneratePatchSummary(List<XenServerPatchAlert> alerts, List<AlertFeatureValidator> validators,
|
||||
XenServerVersionAlert updateAlert, List<XenCenterUpdateAlert> xcupdateAlerts)
|
||||
List<XenServerVersionAlert> updateAlerts, List<XenCenterUpdateAlert> 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),
|
||||
|
@ -39,21 +39,21 @@ namespace CFUValidator.OutputDecorators
|
||||
{
|
||||
class XenServerUpdateDecorator : Decorator
|
||||
{
|
||||
private readonly XenServerVersionAlert alert;
|
||||
private readonly List<XenServerVersionAlert> 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<XenServerVersionAlert> 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);
|
||||
}
|
||||
}
|
||||
|
@ -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<XenServerVersion> xenServerVersions)
|
||||
public static List<XenServerVersionAlert> NewXenServerVersionAlerts(List<XenServerVersion> 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<XenServerVersionAlert> alerts = new List<XenServerVersionAlert>();
|
||||
|
||||
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)
|
||||
|
@ -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<XenServerPatch>(), new List<XenServerPatch>(), new DateTime(2011, 4, 1).ToString(), "123");
|
||||
XenServerVersion ver = new XenServerVersion("1.2.3", "name", true, false, "http://url", new List<XenServerPatch>(), new List<XenServerPatch>(), 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<XenServerPatch>(), new List<XenServerPatch>(), new DateTime(2011, 4, 1).ToString(), "123");
|
||||
XenServerVersion ver = new XenServerVersion("1.2.3", "name", true, false, "http://url", new List<XenServerPatch>(), new List<XenServerPatch>(), new DateTime(2011, 4, 1).ToString(), "123");
|
||||
var alert = new XenServerVersionAlert(ver);
|
||||
alert.IncludeHosts(new List<Host> { 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<XenServerPatch>(), new List<XenServerPatch>(), new DateTime(2011, 4, 1).ToString(), "123");
|
||||
XenServerVersion ver = new XenServerVersion("1.2.3", "name", true, false, "http://url", new List<XenServerPatch>(), new List<XenServerPatch>(), 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<XenServerPatch>(), new List<XenServerPatch>(), new DateTime(2011, 4, 1).ToString(), "123");
|
||||
XenServerVersion ver = new XenServerVersion("1.2.3", "name", true, false, "http://url", new List<XenServerPatch>(), new List<XenServerPatch>(), new DateTime(2011, 4, 1).ToString(), "123");
|
||||
var alert = new XenServerVersionAlert(ver);
|
||||
|
||||
IUnitTestVerifier validator = new VerifyGetters(alert);
|
||||
|
@ -76,7 +76,7 @@ namespace XenAdminTests.UnitTests
|
||||
{
|
||||
var serverVersions = new List<XenServerVersion>();
|
||||
|
||||
var version = new XenServerVersion("7.0.0", "XenServer Test 7", true, "", new List<XenServerPatch>(), new List<XenServerPatch>(), DateTime.MinValue.ToString(), "buildNo");
|
||||
var version = new XenServerVersion("7.0.0", "XenServer Test 7", true, false, "", new List<XenServerPatch>(), new List<XenServerPatch>(), 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");
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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<XenServerPatch> Patches;
|
||||
@ -61,17 +62,19 @@ namespace XenAdmin.Core
|
||||
/// <param name="version_oem"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="latest"></param>
|
||||
/// <param name="latestCr"></param>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="patches"></param>
|
||||
/// <param name="minimumPatches">can be null (see <paramref name="MinimalPatches"/></param>
|
||||
/// <param name="timestamp"></param>
|
||||
/// <param name="buildNumber"></param>
|
||||
public XenServerVersion(string version_oem, string name, bool latest, string url, List<XenServerPatch> patches, List<XenServerPatch> minimumPatches,
|
||||
public XenServerVersion(string version_oem, string name, bool latest, bool latestCr, string url, List<XenServerPatch> patches, List<XenServerPatch> minimumPatches,
|
||||
string timestamp, string buildNumber)
|
||||
{
|
||||
ParseVersion(version_oem);
|
||||
Name = name;
|
||||
Latest = latest;
|
||||
LatestCr = latestCr;
|
||||
if (url.StartsWith("/XenServer"))
|
||||
url = UpdateRoot + url;
|
||||
Url = url;
|
||||
|
Loading…
Reference in New Issue
Block a user