protected override void RunWithSession(ref Session session) { try { var existing = (from HostUpdateMapping hum in patchMappings let xpm = hum as XenServerPatchMapping where xpm != null && xpm.Matches(master, xenServerPatch) select xpm).FirstOrDefault(); if (!Helpers.ElyOrGreater(session.Connection)) { Pool_patch poolPatch = null; var mapping = existing as PoolPatchMapping; if (mapping != null && mapping.IsValid) { poolPatch = mapping.Pool_patch; } else { poolPatch = session.Connection.Cache.Pool_patches.FirstOrDefault(pp => string.Equals(pp.uuid, xenServerPatch.Uuid, StringComparison.InvariantCultureIgnoreCase)); } if (poolPatch != null && poolPatch.opaque_ref != null) { AddProgressStep(string.Format(Messages.UPDATES_WIZARD_REMOVING_UPDATES_FROM_POOL, poolPatch.Name())); var task = Pool_patch.async_pool_clean(session, mapping.Pool_patch.opaque_ref); PollTaskForResultAndDestroy(Connection, ref session, task); patchMappings.Remove(mapping); } } else { var mapping = existing as PoolUpdateMapping; if (mapping != null && mapping.IsValid) { var poolUpdate = mapping.Pool_update; AddProgressStep(string.Format(Messages.UPDATES_WIZARD_REMOVING_UPDATES_FROM_POOL, poolUpdate.Name())); Pool_update.pool_clean(session, poolUpdate.opaque_ref); if (!poolUpdate.AppliedOnHosts().Any()) { Pool_update.destroy(session, poolUpdate.opaque_ref); } patchMappings.Remove(mapping); } } } catch (Exception ex) { //best effort log.Error("Failed to remove update from the server.", ex); } }
protected override void RunWithSession(ref Session session) { try { var mapping = patchMappings.FirstOrDefault(pm => pm.MasterHost != null && master != null && pm.MasterHost.uuid == master.uuid && pm.XenServerPatch.Equals(patch)); if (!Helpers.ElyOrGreater(session.Connection)) { Pool_patch poolPatch = null; if (mapping != null || mapping.Pool_patch != null && mapping.Pool_patch.opaque_ref != null) { poolPatch = mapping.Pool_patch; } else { poolPatch = session.Connection.Cache.Pool_patches.FirstOrDefault(pp => string.Equals(pp.uuid, patch.Uuid, System.StringComparison.InvariantCultureIgnoreCase)); } if (poolPatch != null && poolPatch.opaque_ref != null) { var task = Pool_patch.async_pool_clean(session, mapping.Pool_patch.opaque_ref); PollTaskForResultAndDestroy(Connection, ref session, task); patchMappings.Remove(mapping); } } else { if (mapping != null || mapping.Pool_update != null && mapping.Pool_update.opaque_ref != null) { var poolUpdate = mapping.Pool_update; Pool_update.pool_clean(session, poolUpdate.opaque_ref); if (!poolUpdate.AppliedOnHosts.Any()) { Pool_update.destroy(session, poolUpdate.opaque_ref); } patchMappings.Remove(mapping); } } } catch (Exception ex) { //best effort log.Error("Failed to remove update from the server.", ex); } }
private static AsyncAction GetCleanUpPoolUpdateAction(Pool_update poolUpdate) { return (new DelegatedAsyncAction(poolUpdate.Connection, Messages.REMOVE_PATCH, "", "", session => { try { Pool_update.pool_clean(session, poolUpdate.opaque_ref); if (!poolUpdate.AppliedOnHosts().Any()) { Pool_update.destroy(session, poolUpdate.opaque_ref); } } catch (Failure f) { log.Error("Clean up failed", f); } })); }
private AsyncAction GetCleanActionForPoolUpdate(Pool_update update) { if (update == null || update.Connection == null || !update.Connection.IsConnected) { return(null); } return(new DelegatedAsyncAction(update.Connection, Messages.REMOVE_PATCH, "", "", session => { try { Pool_update.pool_clean(session, update.opaque_ref); if (!update.AppliedOnHosts().Any()) { Pool_update.destroy(session, update.opaque_ref); } } catch (Failure f) { log.Error("Clean up failed", f); } })); }
private void RemoveSuppPackFromMaster(Session session, Host master, string suppPack, Pool_update update) { var isLastHostInPool = hosts.IndexOf(host) == hosts.Count - 1; if (isLastHostInPool) { try { AddProgressStep(string.Format(Messages.UPDATES_WIZARD_REMOVING_UPDATES_FROM_POOL, suppPack)); Pool_update.pool_clean(session, update.opaque_ref); if (!update.AppliedOnHosts().Any()) { Pool_update.destroy(session, update.opaque_ref); } uploadedSuppPacks.Remove(master); } catch (Exception ex) { log.Error(string.Format("Remove update file from master failed on host {0}", master.Name()), ex); } } }