public void TestAlertWithConnectionAndHosts() { XenServerPatch p = new XenServerPatch("uuid", "name", "My description", "guidance", "6.0.1", "http://url", "http://patchUrl", new DateTime(2011, 4, 1).ToString(), ""); XenServerPatchAlert alert = new XenServerPatchAlert(p); 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 = "XenServerPatchAlert", Description = "My description", HelpLinkText = "Help", Title = "New Update Available - name", Priority = "Priority2" }); Assert.IsFalse(alert.CanIgnore); VerifyConnExpectations(Times.Once); VerifyHostsExpectations(Times.Once); }
public void AddAlert(XenServerPatchAlert alert) { PatchingWizard_SelectPatchPage.SelectDownloadAlert(alert); PatchingWizard_SelectPatchPage.SelectedUpdateAlert = alert; PatchingWizard_SelectServers.SelectedUpdateAlert = alert; PatchingWizard_UploadPage.SelectedUpdateAlert = alert; }
private void DownloadPatchFile(XenServerPatchAlert patch) { if(string.IsNullOrEmpty(patch.Patch.PatchUrl)) { Results.Add("Patch conatined no URL: " + patch.Patch.Name); return; } string tempFileName = NewTempPath(); DownloadAndUnzipXenServerPatchAction action = new DownloadAndUnzipXenServerPatchAction(patch.Patch.Name, new Uri(patch.Patch.PatchUrl), tempFileName); try { Status = "Download and unzip patch " + patch.Patch.Name; ConsoleSpinner spinner = new ConsoleSpinner(); action.RunAsync(); while(!action.IsCompleted) { spinner.Turn(action.PercentComplete); } if(!action.Succeeded) Results.Add("Patch download and unzip unsuccessful: " + action.Exception.Message); } catch (Exception ex) { Results.Add("Patch download error: " + ex.Message); } }
public void CopyConnectionsAndHosts(XenServerPatchAlert alert) { connections.Clear(); connections.AddRange(alert.connections); hosts.Clear(); hosts.AddRange(alert.hosts); canIgnore = connections.Count == 0 && hosts.Count == 0; }
private void VerifyPatchDetailsMissing(XenServerPatchAlert alert) { if(string.IsNullOrEmpty(alert.Patch.Uuid)) Results.Add("Missing patch uuid for patch: " + alert.Patch.Name); if(string.IsNullOrEmpty(alert.Patch.Name)) Results.Add("Missing patch name for patch with UUID: " + alert.Patch.Uuid); if(string.IsNullOrEmpty(alert.Patch.PatchUrl)) Results.Add("Missing patch patch-url for patch with UUID: " + alert.Patch.Uuid); if (string.IsNullOrEmpty(alert.Patch.Description)) Results.Add("Missing patch description for patch with UUID: " + alert.Patch.Uuid); if (string.IsNullOrEmpty(alert.Patch.Url)) Results.Add("Missing patch webpage url for patch with UUID: " + alert.Patch.Uuid); if (string.IsNullOrEmpty(alert.Patch.Guidance)) Results.Add("Missing patch guidance for patch with UUID: " + alert.Patch.Uuid); if (string.IsNullOrEmpty(alert.Patch.TimeStamp.ToString())) Results.Add("Missing patch timestamp for patch with UUID: " + alert.Patch.Uuid); }
public void TestAlertWithNullPatch() { XenServerPatchAlert alert = new XenServerPatchAlert(null); }
public void TestAlertWithNoConnectionAndNoHosts() { XenServerPatch p = new XenServerPatch("uuid", "name", "My description", "guidance", "6.0.1", "http://url", "http://patchUrl", new DateTime(2011, 4, 1).ToString(), "5"); XenServerPatchAlert alert = new XenServerPatchAlert(p); IUnitTestVerifier validator = new VerifyGetters(alert); validator.Verify(new AlertClassUnitTestData { AppliesTo = string.Empty, FixLinkText = "Go to Web Page", HelpID = "XenServerPatchAlert", Description = "My description", HelpLinkText = "Help", Title = "New Update Available - name", Priority = "Priority5" }); Assert.IsTrue(alert.CanIgnore); VerifyConnExpectations(Times.Never); VerifyHostsExpectations(Times.Never); }
private static XenServerPatchAlert GetServerPatchAlert(List<XenServerPatchAlert> alerts, XenServerPatch patch) { XenServerPatchAlert alert = new XenServerPatchAlert(patch); XenServerPatchAlert existingAlert = alerts.Find(al => al.Equals(alert)); if (existingAlert != null) alert = existingAlert; else alerts.Add(alert); return alert; }
public static List<XenServerPatchAlert> NewXenServerPatchAlerts(List<XenServerVersion> xenServerVersions, List<XenServerPatch> xenServerPatches) { if (Helpers.CommonCriteriaCertificationRelease) return null; var alerts = new List<XenServerPatchAlert>(); foreach (IXenConnection xenConnection in ConnectionsManager.XenConnectionsCopy) { Host master = Helpers.GetMaster(xenConnection); Pool pool = Helpers.GetPoolOfOne(xenConnection); List<Host> hosts = xenConnection.Cache.Hosts.ToList(); if (master == null || pool == null) continue; var serverVersions = xenServerVersions.FindAll(version => { if (version.BuildNumber != string.Empty) return (master.BuildNumberRaw == version.BuildNumber); return Helpers.HostProductVersionWithOEM(master) == version.VersionAndOEM || (version.Oem != null && Helpers.OEMName(master).StartsWith(version.Oem) && Helpers.HostProductVersion(master) == version.Version.ToString()); }); if (serverVersions.Count == 0) continue; foreach (XenServerVersion xenServerVersion in serverVersions) { XenServerVersion version = xenServerVersion; List<XenServerPatch> patches = xenServerPatches.FindAll(patch => version.Patches.Contains(patch)); if (patches.Count == 0) continue; foreach (XenServerPatch xenServerPatch in patches) { var alert = new XenServerPatchAlert(xenServerPatch); var existingAlert = alerts.Find(al => al.Equals(alert)); if (existingAlert != null) alert = existingAlert; else alerts.Add(alert); if (!xenConnection.IsConnected) continue; XenServerPatch serverPatch = xenServerPatch; // A patch can be installed on a host if: // 1. it is not already installed and // 2. the host has all the required patches installed and // 3. the host doesn't have any of the conflicting patches installed var noPatchHosts = hosts.Where(host => { var appliedPatches = host.AppliedPatches(); // 1. patch is not already installed if (appliedPatches.Any(patch => string.Equals(patch.uuid, serverPatch.Uuid, StringComparison.OrdinalIgnoreCase))) return false; // 2. the host has all the required patches installed if (serverPatch.RequiredPatches != null && serverPatch.RequiredPatches.Count > 0 && !serverPatch.RequiredPatches.All(requiredPatchUuid => appliedPatches.Any(patch => string.Equals(patch.uuid, requiredPatchUuid, StringComparison.OrdinalIgnoreCase)))) return false; // 3. the host doesn't have any of the conflicting patches installed if (serverPatch.ConflictingPatches != null && serverPatch.ConflictingPatches.Count > 0 && serverPatch.ConflictingPatches.Any(conflictingPatchUuid => appliedPatches.Any(patch => string.Equals(patch.uuid, conflictingPatchUuid, StringComparison.OrdinalIgnoreCase)))) return false; return true; }); if (noPatchHosts.Count() == hosts.Count) alert.IncludeConnection(xenConnection); else alert.IncludeHosts(noPatchHosts); } } } return alerts; }
public void CopyConnectionsAndHosts(XenServerPatchAlert alert) { connections.Clear(); connections.AddRange(alert.connections); hosts.Clear(); hosts.AddRange(alert.hosts); canIgnore = connections.Count == 0 && hosts.Count == 0; }