Merge pull request #1586 from GaborApatiNagy/master_updates

CA-252877: Precheck actions not reverted on upgrading to new XenServer version using an update
This commit is contained in:
Mihaela Stoica 2017-05-10 12:35:00 +01:00 committed by GitHub
commit 1bc43eda7d
5 changed files with 43 additions and 7 deletions

View File

@ -141,6 +141,7 @@ namespace XenAdmin.Wizards.PatchingWizard
var planActions = new List<PlanAction>();
var delayedActionsByHost = new Dictionary<Host, List<PlanAction>>();
var finalActions = new List<PlanAction>();
foreach (var host in pool.Connection.Cache.Hosts)
{
@ -177,9 +178,16 @@ namespace XenAdmin.Wizards.PatchingWizard
}//patch
}
//add a revert pre-check action for this pool
var problemsToRevert = ProblemsResolvedPreCheck.Where(p => hosts.ToList().Select(h => h.uuid).ToList().Contains(p.Check.Host.uuid)).ToList();
if (problemsToRevert.Count > 0)
{
finalActions.Add(new UnwindProblemsAction(problemsToRevert, string.Format(Messages.REVERTING_RESOLVED_PRECHECKS_POOL, pool.Connection.Name)));
}
if (planActions.Count > 0)
{
var bgw = new UpdateProgressBackgroundWorker(master, planActions, delayedActionsByHost);
var bgw = new UpdateProgressBackgroundWorker(master, planActions, delayedActionsByHost, finalActions);
backgroundWorkers.Add(bgw);
}
@ -341,9 +349,21 @@ namespace XenAdmin.Wizards.PatchingWizard
action.Visible = false;
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)

View File

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

View File

@ -44,6 +44,8 @@ namespace XenAdmin.Wizards.PatchingWizard
{
public List<PlanAction> PlanActions { get; private set; }
public Dictionary<Host, List<PlanAction>> DelayedActionsByHost {get; private set; }
public List<PlanAction> FinalActions { get; private set; }
private Host master;
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.PlanActions = planActions;
this.DelayedActionsByHost = delayedActionsByHost;
this.FinalActions = finalActions;
}
public int ActionsCount
{
get
{
return PlanActions.Count + DelayedActionsByHost.Sum(kvp => kvp.Value.Count);
return PlanActions.Count + DelayedActionsByHost.Sum(kvp => kvp.Value.Count) + FinalActions.Count;
}
}

View File

@ -29614,6 +29614,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>
/// Looks up a localized string similar to Reverting all changes done by this wizard.
/// </summary>

View File

@ -10291,6 +10291,9 @@ Click Server Status Report to open the Compile Server Status Report Wizard or cl
<data name="REVERTING_RESOLVED_PRECHECKS" xml:space="preserve">
<value>Reverting resolved prechecks</value>
</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">
<value>Reverting all changes done by this wizard</value>
</data>