CA-252877: Precheck actions not reverted on upgrading to new XenServer version using an update

Automated Updates now undo pre-check actions once it's finished wit the updates

Signed-off-by: Gabor Apati-Nagy <gabor.apati-nagy@citrix.com>
This commit is contained in:
Gabor Apati-Nagy 2017-05-10 10:06:41 +01:00
parent 5aaaf48139
commit 5eff76be28
5 changed files with 40 additions and 7 deletions

View File

@ -141,6 +141,7 @@ namespace XenAdmin.Wizards.PatchingWizard
var planActions = new List<PlanAction>(); var planActions = new List<PlanAction>();
var delayedActionsByHost = new Dictionary<Host, List<PlanAction>>(); var delayedActionsByHost = new Dictionary<Host, List<PlanAction>>();
var finalActions = new List<PlanAction>();
foreach (var host in pool.Connection.Cache.Hosts) foreach (var host in pool.Connection.Cache.Hosts)
{ {
@ -177,9 +178,13 @@ namespace XenAdmin.Wizards.PatchingWizard
}//patch }//patch
} }
//add a revert pre-check action for this pool
finalActions.Add(new UnwindProblemsAction(ProblemsResolvedPreCheck.Where(p => hosts.ToList().Select(h => h.uuid).ToList().Contains(p.Check.Host.uuid)).ToList(),
string.Format(Messages.REVERTING_RESOLVED_PRECHECKS_POOL, pool.Connection.Name)));
if (planActions.Count > 0) if (planActions.Count > 0)
{ {
var bgw = new UpdateProgressBackgroundWorker(master, planActions, delayedActionsByHost); var bgw = new UpdateProgressBackgroundWorker(master, planActions, delayedActionsByHost, finalActions);
backgroundWorkers.Add(bgw); backgroundWorkers.Add(bgw);
} }
@ -341,9 +346,21 @@ namespace XenAdmin.Wizards.PatchingWizard
action.Visible = false; action.Visible = false;
bgw.ReportProgress((int)((1.0 / (double)bgw.ActionsCount) * 100), action); //still need to report progress, mainly for the progress bar bgw.ReportProgress((int)((1.0 / (double)bgw.ActionsCount) * 100), action); //still need to report progress, mainly for the progress bar
} }
} }
}
//running final actions (eg. revert pre-checks)
foreach (var a in bgw.FinalActions)
{
action = a;
if (bgw.CancellationPending)
{
doWorkEventArgs.Cancel = true;
return;
}
RunPlanAction(bgw, action);
} }
} }
catch (Exception e) catch (Exception e)

View File

@ -40,10 +40,10 @@ namespace XenAdmin.Wizards.PatchingWizard.PlanActions
{ {
private readonly List<Problem> _problems; private readonly List<Problem> _problems;
public UnwindProblemsAction(List<Problem> problems) public UnwindProblemsAction(List<Problem> problems, string TitleOverride = null)
: base(Messages.PATCHINGWIZARD_PATCHINGPAGE_PRECHECK_REVERTING) : base(Messages.PATCHINGWIZARD_PATCHINGPAGE_PRECHECK_REVERTING)
{ {
base.TitlePlan = Messages.REVERTING_RESOLVED_PRECHECKS; base._title = base.TitlePlan = TitleOverride ?? Messages.REVERTING_RESOLVED_PRECHECKS;
_problems = problems; _problems = problems;
} }

View File

@ -44,6 +44,8 @@ namespace XenAdmin.Wizards.PatchingWizard
{ {
public List<PlanAction> PlanActions { get; private set; } public List<PlanAction> PlanActions { get; private set; }
public Dictionary<Host, List<PlanAction>> DelayedActionsByHost {get; private set; } public Dictionary<Host, List<PlanAction>> DelayedActionsByHost {get; private set; }
public List<PlanAction> FinalActions { get; private set; }
private Host master; private Host master;
public List<PlanAction> FinsihedActions = new List<PlanAction>(); public List<PlanAction> FinsihedActions = new List<PlanAction>();
@ -65,18 +67,20 @@ namespace XenAdmin.Wizards.PatchingWizard
} }
} }
public UpdateProgressBackgroundWorker(Host master, List<PlanAction> planActions, Dictionary<Host, List<PlanAction>> delayedActionsByHost) public UpdateProgressBackgroundWorker(Host master, List<PlanAction> planActions, Dictionary<Host, List<PlanAction>> delayedActionsByHost,
List<PlanAction> finalActions)
{ {
this.master = master; this.master = master;
this.PlanActions = planActions; this.PlanActions = planActions;
this.DelayedActionsByHost = delayedActionsByHost; this.DelayedActionsByHost = delayedActionsByHost;
this.FinalActions = finalActions;
} }
public int ActionsCount public int ActionsCount
{ {
get get
{ {
return PlanActions.Count + DelayedActionsByHost.Sum(kvp => kvp.Value.Count); return PlanActions.Count + DelayedActionsByHost.Sum(kvp => kvp.Value.Count) + FinalActions.Count;
} }
} }

View File

@ -29722,6 +29722,15 @@ namespace XenAdmin {
} }
} }
/// <summary>
/// Looks up a localized string similar to Reverting resolved prechecks in {0}....
/// </summary>
public static string REVERTING_RESOLVED_PRECHECKS_POOL {
get {
return ResourceManager.GetString("REVERTING_RESOLVED_PRECHECKS_POOL", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Reverting all changes done by this wizard. /// Looks up a localized string similar to Reverting all changes done by this wizard.
/// </summary> /// </summary>

View File

@ -10327,6 +10327,9 @@ Click Server Status Report to open the Compile Server Status Report Wizard or cl
<data name="REVERTING_RESOLVED_PRECHECKS" xml:space="preserve"> <data name="REVERTING_RESOLVED_PRECHECKS" xml:space="preserve">
<value>Reverting resolved prechecks</value> <value>Reverting resolved prechecks</value>
</data> </data>
<data name="REVERTING_RESOLVED_PRECHECKS_POOL" xml:space="preserve">
<value>Reverting resolved prechecks in {0}...</value>
</data>
<data name="REVERTING_WIZARD_CHANGES" xml:space="preserve"> <data name="REVERTING_WIZARD_CHANGES" xml:space="preserve">
<value>Reverting all changes done by this wizard</value> <value>Reverting all changes done by this wizard</value>
</data> </data>