protected override void RunWithSession(ref Session session) { var master = Helpers.GetMaster(Connection); var mapping = mappings.Find(m => m.XenServerPatch.Equals(patch) && m.MasterHost != null && master != null && m.MasterHost.uuid == master.uuid); if (mapping != null && (mapping.Pool_patch != null || mapping.Pool_update != null)) { if (Cancelling) throw new CancelledException(); try { AddProgressStep(string.Format(Messages.UPDATES_WIZARD_RUNNING_PRECHECK, patch.Name, host.Name())); PatchPrecheckCheck check = mapping.Pool_patch == null ? new PatchPrecheckCheck(host, mapping.Pool_update) : new PatchPrecheckCheck(host, mapping.Pool_patch); var problems = check.RunAllChecks(); Diagnostics.Problems.Problem problem = null; if (problems != null && problems.Count > 0) problem = problems[0]; if (problem != null) throw new Exception(string.Format("{0}: {1}. {2}", host, problem.Title, problem.Description)); } catch (Exception ex) { log.Error(string.Format("Precheck failed on host {0}", host.Name()), ex); throw; } } }
protected override void RunWithSession(ref Session session) { var master = Helpers.GetMaster(Connection); var mapping = mappings.Find(m => m.XenServerPatch.Equals(patch) && m.MasterHost != null && master != null && m.MasterHost.uuid == master.uuid); if (mapping != null && (mapping.Pool_patch != null || mapping.Pool_update != null)) { var livePatchStatus = new Dictionary <string, livepatch_status>(); if (Cancelling) { throw new CancelledException(); } try { AddProgressStep(string.Format(Messages.UPDATES_WIZARD_RUNNING_PRECHECK, patch.Name, host.Name())); PatchPrecheckCheck check = mapping.Pool_patch == null ? new PatchPrecheckCheck(host, mapping.Pool_update, livePatchStatus) : new PatchPrecheckCheck(host, mapping.Pool_patch, livePatchStatus); var problems = check.RunAllChecks(); Diagnostics.Problems.Problem problem = null; if (problems != null && problems.Count > 0) { problem = problems[0]; } if (problem != null) { throw new Exception(problem.Description); } } catch (Exception ex) { log.Error(string.Format("Precheck failed on host {0}", host.Name()), ex); throw; } if (livePatchStatus.ContainsKey(host.uuid) && livePatchStatus[host.uuid] != livepatch_status.ok_livepatch_complete && !hostsThatWillRequireReboot.Contains(host.uuid)) { hostsThatWillRequireReboot.Add(host.uuid); } } }
protected override void RunWithSession(ref Session session) { var master = Helpers.GetMaster(Connection); var mapping = mappings.Find(m => m.XenServerPatch.Equals(patch) && m.MasterHost != null && master != null && m.MasterHost.uuid == master.uuid); if (mapping != null && (mapping.Pool_patch != null || mapping.Pool_update != null)) { foreach (var host in hosts) { if (Cancelling) { throw new CancelledException(); } try { PatchPrecheckCheck check = null; if (mapping.Pool_patch != null) { check = new PatchPrecheckCheck(host, mapping.Pool_patch); } else { check = new PatchPrecheckCheck(host, mapping.Pool_update); } var problems = check.RunAllChecks(); Diagnostics.Problems.Problem problem = null; if (problems != null && problems.Count > 0) { problem = problems[0]; } if (problem != null) { throw new Exception(string.Format("{0}: {1}. {2}", host, problem.Title, problem.Description)); } } catch (Exception ex) { log.Error(string.Format("Precheck failed on host {0}", host.Name()), ex); throw ex; } } } }
private void PrecheckSuppPack(Pool_update update, string suppPack, out bool alreadyApplied, out bool updateRequiresHostEvacuation) { alreadyApplied = false; if (Cancelling) { throw new CancelledException(); } var livePatchStatus = new Dictionary <string, livepatch_status>(); try { AddProgressStep(string.Format(Messages.UPDATES_WIZARD_RUNNING_PRECHECK, suppPack, host.Name())); PatchPrecheckCheck check = new PatchPrecheckCheck(host, update, livePatchStatus); var problems = check.RunAllChecks(); updateRequiresHostEvacuation = WizardHelpers.IsHostRebootRequiredForUpdate(host, update, livePatchStatus); if (problems != null && problems.Count > 0) { if (problems[0] is PatchAlreadyApplied) { log.InfoFormat("The update {0} is already applied on {1}. Ignore it.", suppPack, host.Name()); ReplaceProgressStep(string.Format(Messages.UPDATES_WIZARD_SKIPPING_UPDATE, suppPack, host.Name())); alreadyApplied = true; } else { throw new Exception(problems[0].Description); } } } catch (Exception ex) { log.Error(string.Format("Precheck failed on host {0}", host.Name()), ex); throw; } if (livePatchStatus.ContainsKey(host.uuid) && livePatchStatus[host.uuid] != livepatch_status.ok_livepatch_complete && !hostsThatWillRequireReboot.Contains(host.uuid)) { hostsThatWillRequireReboot.Add(host.uuid); } }
protected override void RunWithSession(ref Session session) { var master = Helpers.GetMaster(Connection); var mapping = (from HostUpdateMapping hum in mappings let xpm = hum as XenServerPatchMapping where xpm != null && xpm.Matches(master, xenServerPatch) select xpm).FirstOrDefault(); if (mapping == null || !mapping.IsValid) { return; } var livePatchStatus = new Dictionary <string, livepatch_status>(); if (Cancelling) { throw new CancelledException(); } var updateRequiresHostReboot = false; try { AddProgressStep(string.Format(Messages.UPDATES_WIZARD_RUNNING_PRECHECK, xenServerPatch.Name, host.Name())); RefreshUpdate(host, mapping, session); List <Problem> problems = null; if (mapping is PoolPatchMapping patchMapping) { log.InfoFormat("Running patch precheck on '{0}'. Patch = '{1}' (uuid = '{2}'; opaque_ref = '{3}')", host.Name(), patchMapping.Pool_patch.Name(), patchMapping.Pool_patch.uuid, patchMapping.Pool_patch.opaque_ref); problems = new PatchPrecheckCheck(host, patchMapping.Pool_patch, livePatchStatus).RunAllChecks(); updateRequiresHostReboot = WizardHelpers.IsHostRebootRequiredForUpdate(host, patchMapping.Pool_patch, livePatchStatus); } else if (mapping is PoolUpdateMapping updateMapping) { log.InfoFormat("Running update precheck on '{0}'. Update = '{1}' (uuid = '{2}'; opaque_ref = '{3}'", host.Name(), updateMapping.Pool_update.Name(), updateMapping.Pool_update.uuid, updateMapping.Pool_update.opaque_ref); problems = new PatchPrecheckCheck(host, updateMapping.Pool_update, livePatchStatus).RunAllChecks(); updateRequiresHostReboot = WizardHelpers.IsHostRebootRequiredForUpdate(host, updateMapping.Pool_update, livePatchStatus); } Problem problem = null; if (problems != null && problems.Count > 0) { problem = problems[0]; } if (problem != null) { throw new Exception(problem.Description); } } catch (Exception ex) { log.Error(string.Format("Precheck failed on host {0}", host.Name()), ex); throw; } if (updateRequiresHostReboot && !hostsThatWillRequireReboot.Contains(host.uuid)) { hostsThatWillRequireReboot.Add(host.uuid); } if (updateRequiresHostReboot && !mapping.HostsThatNeedEvacuated.Contains(host.uuid)) { mapping.HostsThatNeedEvacuated.Add(host.uuid); } if (livePatchStatus.ContainsKey(host.uuid) && livePatchStatus[host.uuid] == livepatch_status.ok_livepatch_complete) { if (!livePatchAttempts.ContainsKey(host.uuid) || livePatchAttempts[host.uuid] == null) { livePatchAttempts[host.uuid] = new List <string>(); } livePatchAttempts[host.uuid].Add(xenServerPatch.Uuid); } }
protected override void RunWithSession(ref Session session) { var master = Helpers.GetMaster(Connection); var mapping = (from HostUpdateMapping hum in mappings let xpm = hum as XenServerPatchMapping where xpm != null && xpm.Matches(master, xenServerPatch) select xpm).FirstOrDefault(); if (mapping == null || !mapping.IsValid) { return; } var livePatchStatus = new Dictionary <string, livepatch_status>(); if (Cancelling) { throw new CancelledException(); } try { AddProgressStep(string.Format(Messages.UPDATES_WIZARD_RUNNING_PRECHECK, xenServerPatch.Name, host.Name())); List <Problem> problems = null; if (mapping is PoolPatchMapping patchMapping) { problems = new PatchPrecheckCheck(host, patchMapping.Pool_patch, livePatchStatus).RunAllChecks(); } else if (mapping is PoolUpdateMapping updateMapping) { problems = new PatchPrecheckCheck(host, updateMapping.Pool_update, livePatchStatus).RunAllChecks(); } Problem problem = null; if (problems != null && problems.Count > 0) { problem = problems[0]; } if (problem != null) { throw new Exception(problem.Description); } } catch (Exception ex) { log.Error(string.Format("Precheck failed on host {0}", host.Name()), ex); throw; } if (livePatchStatus.ContainsKey(host.uuid) && livePatchStatus[host.uuid] != livepatch_status.ok_livepatch_complete && !hostsThatWillRequireReboot.Contains(host.uuid)) { hostsThatWillRequireReboot.Add(host.uuid); } }