[CA-228723] Cancelling update installation leaves the update in xapi db

Modify the cleanup pool update action to also call update destroy (removing the update from xapi db) when the update has not been applied to any hosts (ie we cancelled the wizard before completion).
This commit is contained in:
Callum McIntyre 2016-11-08 15:31:35 +00:00
parent 3d9216161f
commit d7060cbdb1

View File

@ -380,16 +380,28 @@ namespace XenAdmin.Wizards.PatchingWizard
{
if (PatchingWizard_UploadPage.AllIntroducedPoolUpdates != null && PatchingWizard_UploadPage.AllIntroducedPoolUpdates.Count > 0)
{
return PatchingWizard_UploadPage.AllIntroducedPoolUpdates.Select(pu => GetCleanUpPoolUpdateAction(pu)).ToList();
return PatchingWizard_UploadPage.AllIntroducedPoolUpdates.Select(GetCleanUpPoolUpdateAction).ToList();
}
return new List<AsyncAction>();
}
private AsyncAction GetCleanUpPoolUpdateAction(Pool_update poolUpdate)
private static AsyncAction GetCleanUpPoolUpdateAction(Pool_update poolUpdate)
{
return
new DelegatedAsyncAction(poolUpdate.Connection, Messages.REMOVE_PATCH, "", "", session => Pool_update.pool_clean(session, poolUpdate.opaque_ref));
new DelegatedAsyncAction(poolUpdate.Connection, Messages.REMOVE_PATCH, "", "", session =>
{
try
{
Pool_update.pool_clean(session, poolUpdate.opaque_ref);
if(!poolUpdate.AppliedOnHosts.Any())
Pool_update.async_destroy(session, poolUpdate.opaque_ref);
}
catch (Failure f)
{
log.Error("Clean up failed", f);
}
});
}
}
}