public void TestAlertWithHostsAndNoConnection() { XenServerVersion ver = new XenServerVersion("1.2.3", "name", true, "http://url", new List <XenServerPatch>(), new DateTime(2011, 4, 1).ToString(), "123"); XenServerUpdateAlert alert = new XenServerUpdateAlert(ver); alert.IncludeHosts(new List <Host>() { hostA.Object, hostB.Object }); IUnitTestVerifier validator = new VerifyGetters(alert); validator.Verify(new AlertClassUnitTestData { AppliesTo = "HostAName, HostBName", FixLinkText = "Go to Web Page", HelpID = "XenServerUpdateAlert", Description = "name is now available. Download the latest at the Citrix website.", HelpLinkText = "Help", Title = "name is now available", Priority = "Priority5" }); Assert.IsFalse(alert.CanIgnore); VerifyConnExpectations(Times.Never); VerifyHostsExpectations(Times.Once); }
public static XenServerUpdateAlert NewServerVersionAlert(List <XenServerVersion> xenServerVersions, bool checkAlertIsAlreadyDismissed) { if (Helpers.CommonCriteriaCertificationRelease) { return(null); } List <XenServerVersion> latestVersions = xenServerVersions.FindAll(item => item.Latest); if (latestVersions.Count == 0) { return(null); } XenServerVersion latestVersion = latestVersions[0]; for (int i = 1; i < latestVersions.Count; i++) { XenServerVersion version = latestVersions[i]; if (version.Version > latestVersion.Version) { latestVersion = version; } } XenServerUpdateAlert alert = new XenServerUpdateAlert(latestVersion); foreach (IXenConnection xc in ConnectionsManager.XenConnectionsCopy) { Host master = Helpers.GetMaster(xc); Pool pool = Helpers.GetPoolOfOne(xc); List <Host> hosts = xc.Cache.Hosts.ToList(); if (master == null || pool == null) { continue; } //check if the latest version has been already dismissed if (checkAlertIsAlreadyDismissed && GetLatestSeenVersion(pool).Contains(latestVersion.VersionAndOEM)) { return(null); } List <Host> outOfDateHosts = hosts.Where(host => new Version(Helpers.HostProductVersion(host)) < latestVersion.Version).ToList(); if (outOfDateHosts.Count == hosts.Count) { alert.IncludeConnection(xc); } else { alert.IncludeHosts(outOfDateHosts); } } if (alert.CanIgnore) { return(null); } return(alert); }