protected override void RunWithSession(ref Session session) { var mapping = mappings.Find(m => m.XenServerPatch.Equals(xenServerPatch) && m.MasterHost != null && m.MasterHost.uuid == masterUuid); if (mapping != null && (mapping.Pool_patch != null || mapping.Pool_update != null)) { XenRef <Task> task = null; if (mapping.Pool_patch != null) { task = Pool_patch.async_apply(session, mapping.Pool_patch.opaque_ref, host.opaque_ref); } else { task = Pool_update.async_apply(session, mapping.Pool_update.opaque_ref, host.opaque_ref); } PollTaskForResultAndDestroy(Connection, ref session, task); } else { if (xenServerPatch != null) { log.ErrorFormat("Mapping not found for patch {0} on master {1}", xenServerPatch.Uuid, masterUuid); } throw new Exception("Pool_patch or Pool_update not found."); } }
protected override void Run() { SafeToExit = false; if (patch.AppliedOn(host) != DateTime.MaxValue) { return; } XenRef <Pool_patch> patchRef = BringPatchToPoolForHost(host, patch); Description = string.Format(Messages.APPLYING_PATCH, patch.Name(), host.Name()); log.DebugFormat("Applying update '{0}' to server '{1}'", patch.Name(), host.Name()); try { RelatedTask = Pool_patch.async_apply(Session, patchRef, host.opaque_ref); PollToCompletion(); } catch (Failure f) { log.ErrorFormat("Failed to apply patch '{0}' on server '{1}': '{2}'", patch.Name(), host.Name(), string.Join(", ", f.ErrorDescription)); //CA-339237 throw; } log.DebugFormat("Applied update '{0}' to server '{1}'. Result: {2}.", patch.Name(), host.Name(), Result); Description = string.Format(Messages.PATCH_APPLIED, patch.Name(), host.Name()); }
protected override void RunWithSession(ref Session session) { XenRef<Task> task = Pool_patch.async_apply(session, _patchRef.opaque_ref, _host.opaque_ref); PollTaskForResultAndDestroy(Connection, ref session, task); }
protected override void RunWithSession(ref Session session) { AddProgressStep(string.Format(Messages.UPDATES_WIZARD_APPLYING_UPDATE, _patch.Name(), _host.Name())); XenRef <Task> task = Pool_patch.async_apply(session, _patch.opaque_ref, _host.opaque_ref); PollTaskForResultAndDestroy(Connection, ref session, task); }
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) { if (xenServerPatch != null) { log.ErrorFormat("Mapping not found for patch {0} on master {1}", xenServerPatch.Uuid, master.uuid); } throw new Exception("Pool_patch or Pool_update not found."); } var host = GetResolvedHost(); try { // evacuate the host, if needed, before applying the update if (mapping.HostsThatNeedEvacuated.Contains(host.uuid)) { EvacuateHost(ref session); } AddProgressStep(string.Format(Messages.UPDATES_WIZARD_APPLYING_UPDATE, xenServerPatch.Name, host.Name())); XenRef <Task> task = null; if (mapping is PoolPatchMapping patchMapping) { task = Pool_patch.async_apply(session, patchMapping.Pool_patch.opaque_ref, host.opaque_ref); } else if (mapping is PoolUpdateMapping updateMapping) { task = Pool_update.async_apply(session, updateMapping.Pool_update.opaque_ref, host.opaque_ref); } PollTaskForResultAndDestroy(Connection, ref session, task); } catch (Failure f) { if (f.ErrorDescription.Count > 1 && (f.ErrorDescription[0] == Failure.PATCH_ALREADY_APPLIED || f.ErrorDescription[0] == Failure.UPDATE_ALREADY_APPLIED)) { log.InfoFormat("The update {0} is already applied on {1}. Ignoring this error.", xenServerPatch.Name, host.Name()); ReplaceProgressStep(string.Format(Messages.UPDATES_WIZARD_SKIPPING_UPDATE, xenServerPatch.Name, host.Name())); } else { throw; } } }
protected override void RunWithSession(ref Session session) { var host = GetResolvedHost(); // evacuate the host, if needed, before applying the update if (_hostNeedsEvacuated) { EvacuateHost(ref session); } AddProgressStep(string.Format(Messages.UPDATES_WIZARD_APPLYING_UPDATE, _patch.Name(), host.Name())); XenRef <Task> task = Pool_patch.async_apply(session, _patch.opaque_ref, host.opaque_ref); PollTaskForResultAndDestroy(Connection, ref session, task); }
protected override void Run() { SafeToExit = false; if (patch.AppliedOn(host) != DateTime.MaxValue) { return; } XenRef <Pool_patch> patchRef = BringPatchToPoolForHost(host, patch); Description = string.Format(Messages.APPLYING_PATCH, patch.Name(), host.Name()); log.Debug(Description); RelatedTask = Pool_patch.async_apply(Session, patchRef, host.opaque_ref); PollToCompletion(); log.DebugFormat(Messages.APPLY_PATCH_LOG_MESSAGE, patch.Name(), host.Name(), Result); Description = string.Format(Messages.PATCH_APPLIED, patch.Name(), host.Name()); }
protected override void RunWithSession(ref Session session) { var mapping = mappings.Find(m => m.XenServerPatch.Equals(xenServerPatch) && m.MasterHost != null && m.MasterHost.uuid == masterUuid); if (mapping != null && (mapping.Pool_patch != null || mapping.Pool_update != null)) { try { AddProgressStep(string.Format(Messages.UPDATES_WIZARD_APPLYING_UPDATE, xenServerPatch.Name, host.Name())); var task = mapping.Pool_patch == null ? Pool_update.async_apply(session, mapping.Pool_update.opaque_ref, host.opaque_ref) : Pool_patch.async_apply(session, mapping.Pool_patch.opaque_ref, host.opaque_ref); PollTaskForResultAndDestroy(Connection, ref session, task); } catch (Failure f) { if (f.ErrorDescription.Count > 1 && (f.ErrorDescription[0] == Failure.PATCH_ALREADY_APPLIED || f.ErrorDescription[0] == Failure.UPDATE_ALREADY_APPLIED)) { log.InfoFormat("The update {0} is already applied on {1}. Ignoring this error.", xenServerPatch.Name, host.Name()); ReplaceProgressStep(string.Format(Messages.UPDATES_WIZARD_SKIPPING_UPDATE, xenServerPatch.Name, host.Name())); } else { throw; } } } else { if (xenServerPatch != null) { log.ErrorFormat("Mapping not found for patch {0} on master {1}", xenServerPatch.Uuid, masterUuid); } throw new Exception("Pool_patch or Pool_update not found."); } }
protected override void RunWithSession(ref Session session) { var master = Helpers.GetMaster(host.Connection); var mapping = mappings.Find(m => m.XenServerPatch.Equals(xenServerPatch) && m.MasterHost != null && master != null && m.MasterHost.uuid == master.uuid); if (mapping != null && mapping.Pool_patch != null) { var patchRef = mapping.Pool_patch; XenRef <Task> task = Pool_patch.async_apply(session, patchRef.opaque_ref, host.opaque_ref); PollTaskForResultAndDestroy(Connection, ref session, task); } else { if (xenServerPatch != null && master != null) { log.ErrorFormat("Mapping not found for patch {0} on master {1}", xenServerPatch.Uuid, master.uuid); } throw new Exception("Pool_patch not found."); } }