mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-12-25 11:49:52 +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));
|
var xcupdateAlerts = XenAdmin.Core.Updates.NewXenCenterUpdateAlerts(xenCenterVersions, new Version(ServerVersion));
|
||||||
|
|
||||||
Status = "Determining XenServer update required...";
|
Status = "Determining XenServer update required...";
|
||||||
var updateAlert = XenAdmin.Core.Updates.NewXenServerVersionAlert(xenServerVersions);
|
var updateAlerts = XenAdmin.Core.Updates.NewXenServerVersionAlerts(xenServerVersions);
|
||||||
|
|
||||||
Status = "Determining patches required...";
|
Status = "Determining patches required...";
|
||||||
var patchAlerts = XenAdmin.Core.Updates.NewXenServerPatchAlerts(xenServerVersions, xenServerPatches).Where(alert => !alert.CanIgnore).ToList();
|
var patchAlerts = XenAdmin.Core.Updates.NewXenServerPatchAlerts(xenServerVersions, xenServerPatches).Where(alert => !alert.CanIgnore).ToList();
|
||||||
@ -135,7 +135,7 @@ namespace CFUValidator
|
|||||||
RunValidators(validators);
|
RunValidators(validators);
|
||||||
|
|
||||||
Status = "Generating summary...";
|
Status = "Generating summary...";
|
||||||
GeneratePatchSummary(patchAlerts, validators, updateAlert, xcupdateAlerts);
|
GeneratePatchSummary(patchAlerts, validators, updateAlerts, xcupdateAlerts);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckProvidedVersionNumber(List<XenServerVersion> xenServerVersions)
|
private void CheckProvidedVersionNumber(List<XenServerVersion> xenServerVersions)
|
||||||
@ -196,11 +196,11 @@ namespace CFUValidator
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void GeneratePatchSummary(List<XenServerPatchAlert> alerts, List<AlertFeatureValidator> validators,
|
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);
|
OuputComponent oc = new OutputTextOuputComponent(XmlLocation, ServerVersion);
|
||||||
XenCenterUpdateDecorator xcud = new XenCenterUpdateDecorator(oc, xcupdateAlerts);
|
XenCenterUpdateDecorator xcud = new XenCenterUpdateDecorator(oc, xcupdateAlerts);
|
||||||
XenServerUpdateDecorator xsud = new XenServerUpdateDecorator(xcud, updateAlert);
|
XenServerUpdateDecorator xsud = new XenServerUpdateDecorator(xcud, updateAlerts);
|
||||||
PatchAlertDecorator pad = new PatchAlertDecorator(xsud, alerts);
|
PatchAlertDecorator pad = new PatchAlertDecorator(xsud, alerts);
|
||||||
AlertFeatureValidatorDecorator afdCoreFields = new AlertFeatureValidatorDecorator(pad,
|
AlertFeatureValidatorDecorator afdCoreFields = new AlertFeatureValidatorDecorator(pad,
|
||||||
validators.First(v => v is CorePatchDetailsValidator),
|
validators.First(v => v is CorePatchDetailsValidator),
|
||||||
|
@ -39,21 +39,21 @@ namespace CFUValidator.OutputDecorators
|
|||||||
{
|
{
|
||||||
class XenServerUpdateDecorator : Decorator
|
class XenServerUpdateDecorator : Decorator
|
||||||
{
|
{
|
||||||
private readonly XenServerVersionAlert alert;
|
private readonly List<XenServerVersionAlert> alerts;
|
||||||
private const string header = "XenServer updates required:";
|
private const string header = "XenServer updates required:";
|
||||||
private const string updateNotFound = "XenServer update could not be found";
|
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);
|
SetComponent(ouputComponent);
|
||||||
this.alert = alert;
|
this.alerts = alerts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override StringBuilder Generate()
|
public override StringBuilder Generate()
|
||||||
{
|
{
|
||||||
StringBuilder sb = base.Generate();
|
StringBuilder sb = base.Generate();
|
||||||
sb.AppendLine(header);
|
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);
|
return sb.AppendLine(String.Empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,9 +272,9 @@ namespace XenAdmin.Core
|
|||||||
if (xenCenterAlerts != null)
|
if (xenCenterAlerts != null)
|
||||||
updateAlerts.AddRange(xenCenterAlerts.Where(a=>!a.IsDismissed()));
|
updateAlerts.AddRange(xenCenterAlerts.Where(a=>!a.IsDismissed()));
|
||||||
|
|
||||||
var xenServerUpdateAlert = NewXenServerVersionAlert(XenServerVersionsForAutoCheck);
|
var xenServerUpdateAlerts = NewXenServerVersionAlerts(XenServerVersionsForAutoCheck);
|
||||||
if (xenServerUpdateAlert != null && !xenServerUpdateAlert.CanIgnore)
|
if (xenServerUpdateAlerts != null)
|
||||||
updateAlerts.Add(xenServerUpdateAlert);
|
updateAlerts.AddRange(xenServerUpdateAlerts.Where(a=>!a.CanIgnore));
|
||||||
|
|
||||||
var xenServerPatchAlerts = NewXenServerPatchAlerts(XenServerVersions, XenServerPatches);
|
var xenServerPatchAlerts = NewXenServerPatchAlerts(XenServerVersions, XenServerPatches);
|
||||||
if (xenServerPatchAlerts != null)
|
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)
|
if (Helpers.CommonCriteriaCertificationRelease)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var latestVersion = xenServerVersions.FindAll(item => item.Latest).OrderByDescending(v => v.Version).FirstOrDefault();
|
var latestVersion = xenServerVersions.FindAll(item => item.Latest).OrderByDescending(v => v.Version).FirstOrDefault();
|
||||||
if (latestVersion == null)
|
var latestCrVersion = xenServerVersions.FindAll(item => item.LatestCr).OrderByDescending(v => v.Version).FirstOrDefault();
|
||||||
return null;
|
|
||||||
|
|
||||||
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)
|
foreach (IXenConnection xc in ConnectionsManager.XenConnectionsCopy)
|
||||||
{
|
{
|
||||||
@ -725,7 +737,7 @@ namespace XenAdmin.Core
|
|||||||
if (master == null || pool == null)
|
if (master == null || pool == null)
|
||||||
continue;
|
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)
|
if (outOfDateHosts.Count() == hosts.Count)
|
||||||
alert.IncludeConnection(xc);
|
alert.IncludeConnection(xc);
|
||||||
@ -736,14 +748,13 @@ namespace XenAdmin.Core
|
|||||||
return alert;
|
return alert;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void CheckServerVersion()
|
public static void CheckServerVersion()
|
||||||
{
|
{
|
||||||
var alert = NewXenServerVersionAlert(XenServerVersionsForAutoCheck);
|
var alerts = NewXenServerVersionAlerts(XenServerVersionsForAutoCheck);
|
||||||
if (alert == null)
|
if (alerts == null || alerts.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CheckUpdate(alert);
|
alerts.ForEach(a => CheckUpdate(a));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void CheckServerPatches()
|
public static void CheckServerPatches()
|
||||||
@ -752,8 +763,7 @@ namespace XenAdmin.Core
|
|||||||
if (alerts == null)
|
if (alerts == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (var alert in alerts)
|
alerts.ForEach(a => CheckUpdate(a));
|
||||||
CheckUpdate(alert);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CheckUpdate(XenServerUpdateAlert alert)
|
private static void CheckUpdate(XenServerUpdateAlert alert)
|
||||||
|
@ -55,7 +55,7 @@ namespace XenAdminTests.UnitTests.AlertTests
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestAlertWithConnectionAndHosts()
|
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);
|
var alert = new XenServerVersionAlert(ver);
|
||||||
alert.IncludeConnection(connA.Object);
|
alert.IncludeConnection(connA.Object);
|
||||||
alert.IncludeConnection(connB.Object);
|
alert.IncludeConnection(connB.Object);
|
||||||
@ -83,7 +83,7 @@ namespace XenAdminTests.UnitTests.AlertTests
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestAlertWithHostsAndNoConnection()
|
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);
|
var alert = new XenServerVersionAlert(ver);
|
||||||
alert.IncludeHosts(new List<Host> { hostA.Object, hostB.Object });
|
alert.IncludeHosts(new List<Host> { hostA.Object, hostB.Object });
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ namespace XenAdminTests.UnitTests.AlertTests
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestAlertWithConnectionAndNoHosts()
|
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);
|
var alert = new XenServerVersionAlert(ver);
|
||||||
alert.IncludeConnection(connA.Object);
|
alert.IncludeConnection(connA.Object);
|
||||||
alert.IncludeConnection(connB.Object);
|
alert.IncludeConnection(connB.Object);
|
||||||
@ -136,7 +136,7 @@ namespace XenAdminTests.UnitTests.AlertTests
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestAlertWithNoConnectionAndNoHosts()
|
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);
|
var alert = new XenServerVersionAlert(ver);
|
||||||
|
|
||||||
IUnitTestVerifier validator = new VerifyGetters(alert);
|
IUnitTestVerifier validator = new VerifyGetters(alert);
|
||||||
|
@ -76,7 +76,7 @@ namespace XenAdminTests.UnitTests
|
|||||||
{
|
{
|
||||||
var serverVersions = new List<XenServerVersion>();
|
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++)
|
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");
|
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 version_oem = "";
|
||||||
string name = "";
|
string name = "";
|
||||||
bool is_latest = false;
|
bool is_latest = false;
|
||||||
|
bool is_latest_cr = false;
|
||||||
string url = "";
|
string url = "";
|
||||||
string timestamp = "";
|
string timestamp = "";
|
||||||
string buildNumber = "";
|
string buildNumber = "";
|
||||||
@ -245,6 +246,8 @@ namespace XenAdmin.Actions
|
|||||||
name = attrib.Value;
|
name = attrib.Value;
|
||||||
else if (attrib.Name == "latest")
|
else if (attrib.Name == "latest")
|
||||||
is_latest = attrib.Value.ToUpperInvariant() == bool.TrueString.ToUpperInvariant();
|
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")
|
else if (attrib.Name == "url")
|
||||||
url = attrib.Value;
|
url = attrib.Value;
|
||||||
else if (attrib.Name == "timestamp")
|
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));
|
buildNumber));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@ namespace XenAdmin.Core
|
|||||||
public Version Version;
|
public Version Version;
|
||||||
public string Name;
|
public string Name;
|
||||||
public bool Latest;
|
public bool Latest;
|
||||||
|
public bool LatestCr;
|
||||||
public string Url;
|
public string Url;
|
||||||
public string Oem;
|
public string Oem;
|
||||||
public List<XenServerPatch> Patches;
|
public List<XenServerPatch> Patches;
|
||||||
@ -61,17 +62,19 @@ namespace XenAdmin.Core
|
|||||||
/// <param name="version_oem"></param>
|
/// <param name="version_oem"></param>
|
||||||
/// <param name="name"></param>
|
/// <param name="name"></param>
|
||||||
/// <param name="latest"></param>
|
/// <param name="latest"></param>
|
||||||
|
/// <param name="latestCr"></param>
|
||||||
/// <param name="url"></param>
|
/// <param name="url"></param>
|
||||||
/// <param name="patches"></param>
|
/// <param name="patches"></param>
|
||||||
/// <param name="minimumPatches">can be null (see <paramref name="MinimalPatches"/></param>
|
/// <param name="minimumPatches">can be null (see <paramref name="MinimalPatches"/></param>
|
||||||
/// <param name="timestamp"></param>
|
/// <param name="timestamp"></param>
|
||||||
/// <param name="buildNumber"></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)
|
string timestamp, string buildNumber)
|
||||||
{
|
{
|
||||||
ParseVersion(version_oem);
|
ParseVersion(version_oem);
|
||||||
Name = name;
|
Name = name;
|
||||||
Latest = latest;
|
Latest = latest;
|
||||||
|
LatestCr = latestCr;
|
||||||
if (url.StartsWith("/XenServer"))
|
if (url.StartsWith("/XenServer"))
|
||||||
url = UpdateRoot + url;
|
url = UpdateRoot + url;
|
||||||
Url = url;
|
Url = url;
|
||||||
|
Loading…
Reference in New Issue
Block a user