protected override void Run() { SafeToExit = false; if (update.AppliedOn(host)) { return; } Description = string.Format(Messages.APPLYING_PATCH, update.Name(), host.Name()); log.Debug(Description); var poolUpdates = new List <Pool_update>(Connection.Cache.Pool_updates); var poolUpdate = poolUpdates.FirstOrDefault(u => u != null && string.Equals(u.uuid, update.uuid, StringComparison.OrdinalIgnoreCase)); if (poolUpdate == null) { throw new Failure(Failure.INTERNAL_ERROR, Messages.POOL_UPDATE_GONE); } if (!poolUpdate.AppliedOn(host)) { Pool_update.apply(Session, poolUpdate.opaque_ref, host.opaque_ref); Description = string.Format(Messages.PATCH_APPLIED, update.Name(), host.Name()); } else { Description = string.Format(Messages.PATCH_APPLIED_ALREADY, update.Name(), host.Name()); } }
private void ApplyUpdate(Host host, Pool_update update) { // Set the correct connection object, for RecomputeCanCancel Connection = host.Connection; Session session = host.Connection.DuplicateSession(); try { this.Description = String.Format(Messages.APPLYING_PATCH, update.Name, host.Name); output += String.Format(Messages.APPLY_PATCH_LOG_MESSAGE, update.Name, host.Name); var poolUpdates = new List <Pool_update>(session.Connection.Cache.Pool_updates); var poolUpdate = poolUpdates.FirstOrDefault(u => u != null && string.Equals(u.uuid, update.uuid, StringComparison.OrdinalIgnoreCase)); if (poolUpdate == null) { throw new Exception("Pool_update not found"); } if (!poolUpdate.AppliedOn(host)) { Pool_update.apply(session, poolUpdate.opaque_ref, host.opaque_ref); this.Description = String.Format(Messages.PATCH_APPLIED, update.Name, host.Name); } else { this.Description = String.Format(Messages.PATCH_APPLIED, update.Name, host.Name); } } catch (Failure f) { if (f.ErrorDescription.Count > 1 && f.ErrorDescription[0] == XenAPI.Failure.PATCH_APPLY_FAILED) { output += Messages.APPLY_PATCH_FAILED_LOG_MESSAGE; output += f.ErrorDescription[1]; } log.Error(output, f); throw; } finally { Connection = null; } }
private void UploadAndApplyUpdate(Host host, Session session) { var update = host.Connection.Cache.Find_By_Uuid <Pool_update>(UUID); if (update == null) { var master = Helpers.GetMaster(host.Connection); var filePath = Path.Combine(Program.AssemblyDir, String.Format("{0}.{1}", Filename, Branding.UpdateIso)); var action = new Actions.UploadSupplementalPackAction(master.Connection, new List <Host>() { master }, filePath, true); action.RunExternal(session); update = action.PoolUpdate; } Pool_update.apply(session, update.opaque_ref, host.opaque_ref); }
private void ApplyUpdate() { try { this.Description = String.Format(Messages.APPLYING_PATCH, update.Name(), host.Name()); output += String.Format(Messages.APPLY_PATCH_LOG_MESSAGE, update.Name(), host.Name()); var poolUpdates = new List <Pool_update>(Connection.Cache.Pool_updates); var poolUpdate = poolUpdates.FirstOrDefault(u => u != null && string.Equals(u.uuid, update.uuid, StringComparison.OrdinalIgnoreCase)); if (poolUpdate == null) { throw new Failure(Failure.INTERNAL_ERROR, Messages.POOL_UPDATE_GONE); } if (!poolUpdate.AppliedOn(host)) { Pool_update.apply(Session, poolUpdate.opaque_ref, host.opaque_ref); this.Description = String.Format(Messages.PATCH_APPLIED, update.Name(), host.Name()); } else { this.Description = String.Format(Messages.PATCH_APPLIED, update.Name(), host.Name()); } } catch (Failure f) { if (f.ErrorDescription.Count > 1 && f.ErrorDescription[0] == XenAPI.Failure.PATCH_APPLY_FAILED) { output += Messages.APPLY_PATCH_FAILED_LOG_MESSAGE; output += f.ErrorDescription[1]; } log.Error(output, f); throw; } }