public void CopyConnectionsAndHosts(XenServerUpdateAlert alert) { connections.Clear(); connections.AddRange(alert.connections); hosts.Clear(); hosts.AddRange(alert.hosts); }
public void TestAlertWithConnectionAndHosts() { 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.IncludeConnection(connA.Object); alert.IncludeConnection(connB.Object); alert.IncludeHosts(new List<Host>() { hostA.Object, hostB.Object }); IUnitTestVerifier validator = new VerifyGetters(alert); validator.Verify(new AlertClassUnitTestData { AppliesTo = "HostAName, HostBName, ConnAName, ConnBName", FixLinkText = "&Go to Web Page...", HelpID = "XenServerUpdateAlert", Description = "name is now available. Download the latest at the Citrix website (April 1, 2011)", HelpLinkText = "&Help on this alert...", Title = "name is now available", Priority = "Priority5" }); Assert.IsFalse(alert.CanIgnore); VerifyConnExpectations(Times.Once); VerifyHostsExpectations(Times.Once); }
public void CopyConnectionsAndHosts(XenServerUpdateAlert alert) { connections.Clear(); connections.AddRange(alert.connections); hosts.Clear(); hosts.AddRange(alert.hosts); canIgnore = connections.Count == 0 && hosts.Count == 0; }
public void CopyConnectionsAndHosts(XenServerUpdateAlert alert) { lock (connectionsLock) { connections.Clear(); connections.AddRange(alert.Connections); } lock (hostsLock) { hosts.Clear(); hosts.AddRange(alert.Hosts); } }
public void TestAlertWithNullVersion() { XenServerUpdateAlert alert = new XenServerUpdateAlert(null); }
public static XenServerUpdateAlert NewXenServerUpdateAlert(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; 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; var outOfDateHosts = hosts.Where(host => new Version(Helpers.HostProductVersion(host)) < latestVersion.Version); if (outOfDateHosts.Count() == hosts.Count) alert.IncludeConnection(xc); else alert.IncludeHosts(outOfDateHosts); } if (alert.CanIgnore) return null; return alert; }
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; }
private void GeneratePatchSummary(List<XenServerPatchAlert> alerts, List<AlertFeatureValidator> validators, XenServerUpdateAlert updateAlert, XenCenterUpdateAlert xcupdateAlert) { OuputComponent oc = new OutputTextOuputComponent(XmlLocation, ServerVersion); XenCenterUpdateDecorator xcud = new XenCenterUpdateDecorator(oc, xcupdateAlert); XenServerUpdateDecorator xsud = new XenServerUpdateDecorator(xcud, updateAlert); PatchAlertDecorator pad = new PatchAlertDecorator(xsud, alerts); AlertFeatureValidatorDecorator afdCoreFields = new AlertFeatureValidatorDecorator(pad, validators.First(v => v is CorePatchDetailsValidator), "Core fields in patch checks:"); AlertFeatureValidatorDecorator afdPatchUrl = new AlertFeatureValidatorDecorator(afdCoreFields, validators.First(v => v is PatchURLValidator), "Required patch URL checks:"); AlertFeatureValidatorDecorator afdZipContents = new AlertFeatureValidatorDecorator(afdPatchUrl, validators.First(v => v is ZipContentsValidator), "Required patch zip content checks:"); if(CheckHotfixContents) Output = afdZipContents.Generate().Insert(0, Output).ToString(); else Output = afdPatchUrl.Generate().Insert(0, Output).ToString(); }
private static void CheckUpdate(XenServerUpdateAlert alert) { var existingAlert = FindUpdate(alert); if (existingAlert != null && alert.CanIgnore) RemoveUpdate(existingAlert); else if (existingAlert != null) ((XenServerUpdateAlert)existingAlert).CopyConnectionsAndHosts(alert); else if (!alert.CanIgnore) AddUpate(alert); }
public XenServerUpdateDecorator(OuputComponent ouputComponent, XenServerUpdateAlert alert) { SetComponent(ouputComponent); this.alert = alert; }
public void TestAlertWithNoConnectionAndNoHosts() { 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); IUnitTestVerifier validator = new VerifyGetters(alert); validator.Verify(new AlertClassUnitTestData { AppliesTo = string.Empty, FixLinkText = "&Go to Web Page...", HelpID = "XenServerUpdateAlert", Description = "name is now available. Download the latest at the Citrix website.", HelpLinkText = "&Help on this alert...", Title = "name is now available", Priority = "Priority5" }); Assert.IsTrue(alert.CanIgnore); VerifyConnExpectations(Times.Never); VerifyHostsExpectations(Times.Never); }