mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 07:19:18 +01:00
CA-293153: The logic calculating the resolved precheck actions to be reverted
is now in one place, namely the PatchingWizard_PrecheckPage.UnwindChangesActions. The pages following this page use now this list instead of the problems encountered, so we ensure that the update/upgrade plans do not include the unwind action if no resolution of problems took place on the prechecks page. Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
parent
741bfaa864
commit
3107c111f0
@ -33,15 +33,15 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
using XenAdmin.Controls;
|
||||
using XenAdmin.Diagnostics.Problems;
|
||||
using XenAdmin.Wizards.PatchingWizard.PlanActions;
|
||||
using XenAPI;
|
||||
using System.Linq;
|
||||
using XenAdmin.Core;
|
||||
using System.Text;
|
||||
using XenAdmin.Actions;
|
||||
|
||||
|
||||
namespace XenAdmin.Wizards.PatchingWizard
|
||||
{
|
||||
@ -53,7 +53,7 @@ namespace XenAdmin.Wizards.PatchingWizard
|
||||
private bool _thisPageIsCompleted = false;
|
||||
private bool _someWorkersFailed = false;
|
||||
|
||||
public List<Problem> ProblemsResolvedPreCheck { get; set; }
|
||||
public List<AsyncAction> UnwindChangesActions { private get; set; }
|
||||
public List<Pool> SelectedPools { private get; set; }
|
||||
public bool ApplyUpdatesToNewVersion { get; set; }
|
||||
public Status Status { get; private set; }
|
||||
@ -131,7 +131,7 @@ namespace XenAdmin.Wizards.PatchingWizard
|
||||
protected abstract string FailureMessagePerPool(bool multipleErrors);
|
||||
protected abstract string UserCancellationMessage();
|
||||
|
||||
protected virtual void GeneratePlanActions(Pool pool, List<HostPlan> planActions, List<PlanAction> finalActions) { }
|
||||
protected abstract List<HostPlan> GenerateHostPlans(Pool pool, out List<Host> applicableHosts);
|
||||
|
||||
protected virtual bool SkipInitialPlanActions(Host host)
|
||||
{
|
||||
@ -148,10 +148,17 @@ namespace XenAdmin.Wizards.PatchingWizard
|
||||
|
||||
foreach (var pool in SelectedPools)
|
||||
{
|
||||
var planActions = new List<HostPlan>();
|
||||
List<Host> applicableHosts;
|
||||
var planActions = GenerateHostPlans(pool, out applicableHosts);
|
||||
|
||||
var finalActions = new List<PlanAction>();
|
||||
|
||||
GeneratePlanActions(pool, planActions, finalActions);
|
||||
//add a revert pre-check action for this pool
|
||||
var curPool = pool;
|
||||
var problemsToRevert = UnwindChangesActions.Where(a => Helpers.GetPoolOfOne(a.Connection).Equals(curPool)).ToList();
|
||||
|
||||
if (problemsToRevert.Count > 0)
|
||||
finalActions.Add(new UnwindProblemsAction(problemsToRevert, pool.Connection));
|
||||
|
||||
if (planActions.Count > 0)
|
||||
{
|
||||
|
@ -212,10 +212,10 @@ namespace XenAdmin.Wizards.PatchingWizard
|
||||
}
|
||||
else if (prevPageType == typeof(PatchingWizard_PrecheckPage))
|
||||
{
|
||||
PatchingWizard_PatchingPage.ProblemsResolvedPreCheck = PatchingWizard_PrecheckPage.ProblemsResolvedPreCheck;
|
||||
PatchingWizard_PatchingPage.UnwindChangesActions = PatchingWizard_PrecheckPage.GetUnwindChangesActions();;
|
||||
PatchingWizard_PatchingPage.LivePatchCodesByHost = PatchingWizard_PrecheckPage.LivePatchCodesByHost;
|
||||
PatchingWizard_ModePage.LivePatchCodesByHost = PatchingWizard_PrecheckPage.LivePatchCodesByHost;
|
||||
PatchingWizard_AutomatedUpdatesPage.ProblemsResolvedPreCheck = PatchingWizard_PrecheckPage.ProblemsResolvedPreCheck;
|
||||
PatchingWizard_AutomatedUpdatesPage.UnwindChangesActions = PatchingWizard_PrecheckPage.GetUnwindChangesActions();
|
||||
}
|
||||
}
|
||||
|
||||
@ -233,20 +233,6 @@ namespace XenAdmin.Wizards.PatchingWizard
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<AsyncAction> GetUnwindChangesActions()
|
||||
{
|
||||
if (PatchingWizard_PrecheckPage.ProblemsResolvedPreCheck == null)
|
||||
return null;
|
||||
|
||||
var actionList = (from problem in PatchingWizard_PrecheckPage.ProblemsResolvedPreCheck
|
||||
where problem.SolutionActionCompleted
|
||||
select problem.UnwindChanges());
|
||||
|
||||
return actionList.Where(action => action != null &&
|
||||
action.Connection != null &&
|
||||
action.Connection.IsConnected).ToList();
|
||||
}
|
||||
|
||||
private List<AsyncAction> GetRemovePatchActions(List<Pool_patch> patchesToRemove)
|
||||
{
|
||||
if (patchesToRemove == null || patchesToRemove.Count == 0)
|
||||
@ -310,7 +296,9 @@ namespace XenAdmin.Wizards.PatchingWizard
|
||||
{
|
||||
base.OnCancel();
|
||||
|
||||
List<AsyncAction> subActions = BuildSubActions(GetUnwindChangesActions, GetRemovePatchActions, GetRemoveVdiActions, GetCleanUpPoolUpdateActions);
|
||||
var subActions = BuildSubActions(PatchingWizard_PrecheckPage.GetUnwindChangesActions,
|
||||
GetRemovePatchActions, GetRemoveVdiActions, GetCleanUpPoolUpdateActions);
|
||||
|
||||
RunMultipleActions(Messages.REVERT_WIZARD_CHANGES, Messages.REVERTING_WIZARD_CHANGES,
|
||||
Messages.REVERTED_WIZARD_CHANGES, subActions);
|
||||
|
||||
|
@ -30,12 +30,11 @@
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using XenAdmin.Wizards.PatchingWizard.PlanActions;
|
||||
using XenAPI;
|
||||
using System.Linq;
|
||||
using XenAdmin.Core;
|
||||
using XenAdmin.Alerts;
|
||||
using XenAdmin.Diagnostics.Checks;
|
||||
|
||||
|
||||
namespace XenAdmin.Wizards.PatchingWizard
|
||||
{
|
||||
@ -108,7 +107,7 @@ namespace XenAdmin.Wizards.PatchingWizard
|
||||
return Messages.PATCHINGWIZARD_AUTOUPDATINGPAGE_CANCELLATION;
|
||||
}
|
||||
|
||||
protected override void GeneratePlanActions(Pool pool, List<HostPlan> planActions, List<PlanAction> finalActions)
|
||||
protected override List<HostPlan> GenerateHostPlans(Pool pool, out List<Host> applicableHosts)
|
||||
{
|
||||
bool automatedUpdatesRestricted = pool.Connection.Cache.Hosts.Any(Host.RestrictBatchHotfixApply);
|
||||
|
||||
@ -117,29 +116,17 @@ namespace XenAdmin.Wizards.PatchingWizard
|
||||
: Updates.GetMinimalPatches(pool.Connection);
|
||||
|
||||
if (minimalPatches == null)
|
||||
return;
|
||||
{
|
||||
applicableHosts = new List<Host>();
|
||||
return new List<HostPlan>();
|
||||
}
|
||||
|
||||
var uploadedPatches = new List<XenServerPatch>();
|
||||
var hosts = pool.Connection.Cache.Hosts.ToList();
|
||||
hosts.Sort();//master first
|
||||
|
||||
foreach (var host in hosts)
|
||||
{
|
||||
var hostActions = GetUpdatePlanActionsForHost(host, hosts, minimalPatches, uploadedPatches, PatchFromDisk);
|
||||
if (hostActions.UpdatesPlanActions != null && hostActions.UpdatesPlanActions.Count > 0)
|
||||
planActions.Add(hostActions);
|
||||
}
|
||||
|
||||
//add a revert pre-check action for this pool
|
||||
var problemsToRevert = ProblemsResolvedPreCheck.Where(p =>
|
||||
{
|
||||
var hostCheck = p.Check as HostCheck;
|
||||
if (hostCheck != null)
|
||||
return hosts.Select(h => h.uuid).Contains(hostCheck.Host.uuid);
|
||||
return false;
|
||||
}).ToList();
|
||||
if (problemsToRevert.Count > 0)
|
||||
finalActions.Add(new UnwindProblemsAction(problemsToRevert, pool.Connection));
|
||||
applicableHosts = new List<Host>(hosts);
|
||||
return hosts.Select(h => GetUpdatePlanActionsForHost(h, hosts, minimalPatches, uploadedPatches, PatchFromDisk)).ToList();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ namespace XenAdmin.Wizards.PatchingWizard
|
||||
public bool IsAutomaticMode { private get; set; }
|
||||
public bool RemoveUpdateFile { private get; set; }
|
||||
public string SelectedNewPatch { private get; set; }
|
||||
public List<Problem> ProblemsResolvedPreCheck { private get; set; }
|
||||
public List<AsyncAction> UnwindChangesActions { private get; set; }
|
||||
public Dictionary<Host, VDI> SuppPackVdis { private get; set; }
|
||||
#endregion
|
||||
|
||||
@ -239,13 +239,13 @@ namespace XenAdmin.Wizards.PatchingWizard
|
||||
}
|
||||
} //end pool in foreach
|
||||
|
||||
planActions.Add(new UnwindProblemsAction(ProblemsResolvedPreCheck));
|
||||
planActions.Add(new UnwindProblemsAction(UnwindChangesActions));
|
||||
|
||||
actionsWorker = new BackgroundWorker();
|
||||
actionsWorker.DoWork += new DoWorkEventHandler(PatchingWizardAutomaticPatchWork);
|
||||
actionsWorker.DoWork += PatchingWizardAutomaticPatchWork;
|
||||
actionsWorker.WorkerReportsProgress = true;
|
||||
actionsWorker.ProgressChanged += new ProgressChangedEventHandler(actionsWorker_ProgressChanged);
|
||||
actionsWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(actionsWorker_RunWorkerCompleted);
|
||||
actionsWorker.ProgressChanged += actionsWorker_ProgressChanged;
|
||||
actionsWorker.RunWorkerCompleted += actionsWorker_RunWorkerCompleted;
|
||||
actionsWorker.WorkerSupportsCancellation = true;
|
||||
actionsWorker.RunWorkerAsync(planActions);
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ namespace XenAdmin.Wizards.PatchingWizard
|
||||
private readonly object _update_grid_lock = new object();
|
||||
private BackgroundWorker _worker;
|
||||
public List<Host> SelectedServers = new List<Host>();
|
||||
public List<Problem> ProblemsResolvedPreCheck = new List<Problem>();
|
||||
private readonly List<Problem> ProblemsResolvedPreCheck = new List<Problem>();
|
||||
private AsyncAction resolvePrechecksAction;
|
||||
public Dictionary<Pool_update, Dictionary<Host, SR>> SrUploadedUpdates = new Dictionary<Pool_update, Dictionary<Host, SR>>();
|
||||
|
||||
@ -636,9 +636,23 @@ namespace XenAdmin.Wizards.PatchingWizard
|
||||
public Pool_patch Patch { private get; set; }
|
||||
public Pool_update PoolUpdate { private get; set; }
|
||||
|
||||
public List<AsyncAction> GetUnwindChangesActions()
|
||||
{
|
||||
if (ProblemsResolvedPreCheck == null)
|
||||
return null;
|
||||
|
||||
var actions = from problem in ProblemsResolvedPreCheck
|
||||
where problem.SolutionActionCompleted
|
||||
let action = problem.UnwindChanges()
|
||||
where action != null && action.Connection != null && action.Connection.IsConnected
|
||||
select action;
|
||||
|
||||
return actions.ToList();
|
||||
}
|
||||
|
||||
#region Nested classes and enums
|
||||
|
||||
internal enum PreCheckResult { OK, Info, Warning, Failed }
|
||||
private enum PreCheckResult { OK, Info, Warning, Failed }
|
||||
|
||||
private abstract class PreCheckGridRow : XenAdmin.Controls.DataGridViewEx.DataGridViewExRow
|
||||
{
|
||||
|
@ -31,7 +31,6 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using XenAdmin.Actions;
|
||||
using XenAdmin.Diagnostics.Problems;
|
||||
using XenAdmin.Network;
|
||||
|
||||
|
||||
@ -39,12 +38,12 @@ namespace XenAdmin.Wizards.PatchingWizard.PlanActions
|
||||
{
|
||||
public class UnwindProblemsAction : PlanAction
|
||||
{
|
||||
private readonly List<Problem> _problems;
|
||||
private readonly List<AsyncAction> _actions;
|
||||
private readonly IXenConnection _connection;
|
||||
|
||||
public UnwindProblemsAction(List<Problem> problems, IXenConnection connection = null)
|
||||
public UnwindProblemsAction(List<AsyncAction> actions, IXenConnection connection = null)
|
||||
{
|
||||
_problems = problems;
|
||||
_actions = actions;
|
||||
_connection = connection;
|
||||
}
|
||||
|
||||
@ -53,16 +52,15 @@ namespace XenAdmin.Wizards.PatchingWizard.PlanActions
|
||||
var msg = _connection == null
|
||||
? Messages.REVERTING_RESOLVED_PRECHECKS
|
||||
: string.Format(Messages.REVERTING_RESOLVED_PRECHECKS_POOL, _connection.Name);
|
||||
|
||||
AddProgressStep(msg);
|
||||
|
||||
int completed = 0;
|
||||
foreach (Problem p in _problems)
|
||||
foreach (var a in _actions)
|
||||
{
|
||||
AsyncAction unwind = p.SolutionActionCompleted ? p.UnwindChanges() : null;
|
||||
if (unwind != null)
|
||||
unwind.RunExternal(null);
|
||||
a.RunExternal(null);
|
||||
completed++;
|
||||
PercentComplete = (completed * 100) / _problems.Count;
|
||||
PercentComplete = completed * 100 / _actions.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,12 +32,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using XenAdmin.Core;
|
||||
using XenAdmin.Diagnostics.Checks;
|
||||
using XenAdmin.Wizards.PatchingWizard;
|
||||
using XenAdmin.Wizards.PatchingWizard.PlanActions;
|
||||
using XenAdmin.Wizards.RollingUpgradeWizard.PlanActions;
|
||||
using XenAPI;
|
||||
|
||||
|
||||
namespace XenAdmin.Wizards.RollingUpgradeWizard
|
||||
{
|
||||
public partial class RollingUpgradeUpgradePage : AutomatedUpdatesBasePage
|
||||
@ -92,26 +92,11 @@ namespace XenAdmin.Wizards.RollingUpgradeWizard
|
||||
return Messages.ROLLING_UPGRADE_CANCELLATION;
|
||||
}
|
||||
|
||||
protected override void GeneratePlanActions(Pool pool, List<HostPlan> planActions, List<PlanAction> finalActions)
|
||||
protected override List<HostPlan> GenerateHostPlans(Pool pool, out List<Host> applicableHosts)
|
||||
{
|
||||
//Add masters first, then the slaves that are not ugpraded
|
||||
var hostNeedUpgrade = pool.HostsToUpgrade();
|
||||
|
||||
foreach (var host in hostNeedUpgrade)
|
||||
{
|
||||
planActions.Add(GetSubTasksFor(host));
|
||||
}
|
||||
|
||||
//add a revert pre-check action for this pool
|
||||
var problemsToRevert = ProblemsResolvedPreCheck.Where(p =>
|
||||
{
|
||||
var hostCheck = p.Check as HostCheck;
|
||||
if (hostCheck != null)
|
||||
return hostNeedUpgrade.Select(h => h.uuid).Contains(hostCheck.Host.uuid);
|
||||
return false;
|
||||
}).ToList();
|
||||
if (problemsToRevert.Count > 0)
|
||||
finalActions.Add(new UnwindProblemsAction(problemsToRevert, pool.Connection));
|
||||
applicableHosts = pool.HostsToUpgrade();
|
||||
return applicableHosts.Select(GetSubTasksFor).ToList();
|
||||
}
|
||||
|
||||
protected override bool SkipInitialPlanActions(Host host)
|
||||
|
@ -132,7 +132,7 @@ namespace XenAdmin.Wizards.RollingUpgradeWizard
|
||||
else if (prevPageType == typeof(RollingUpgradeWizardInstallMethodPage))
|
||||
RollingUpgradeUpgradePage.InstallMethodConfig = RollingUpgradeWizardInstallMethodPage.InstallMethodConfig;
|
||||
else if (prevPageType == typeof(RollingUpgradeWizardPrecheckPage))
|
||||
RollingUpgradeUpgradePage.ProblemsResolvedPreCheck = RollingUpgradeWizardPrecheckPage.ProblemsResolvedPreCheck;
|
||||
RollingUpgradeUpgradePage.UnwindChangesActions = RollingUpgradeWizardPrecheckPage.GetUnwindChangesActions();
|
||||
}
|
||||
|
||||
protected override void OnShown(System.EventArgs e)
|
||||
@ -143,23 +143,9 @@ namespace XenAdmin.Wizards.RollingUpgradeWizard
|
||||
NextStep();
|
||||
}
|
||||
|
||||
private List<AsyncAction> GetUnwindChangesActions()
|
||||
{
|
||||
if (RollingUpgradeWizardPrecheckPage.ProblemsResolvedPreCheck == null)
|
||||
return null;
|
||||
|
||||
var actionList = (from problem in RollingUpgradeWizardPrecheckPage.ProblemsResolvedPreCheck
|
||||
where problem.SolutionActionCompleted
|
||||
select problem.UnwindChanges());
|
||||
|
||||
return actionList.Where(action => action != null &&
|
||||
action.Connection != null &&
|
||||
action.Connection.IsConnected).ToList();
|
||||
}
|
||||
|
||||
private void RevertResolvedPreChecks()
|
||||
{
|
||||
List<AsyncAction> subActions = GetUnwindChangesActions();
|
||||
var subActions = RollingUpgradeWizardPrecheckPage.GetUnwindChangesActions();
|
||||
if (subActions.Count > 0)
|
||||
{
|
||||
using (MultipleAction multipleAction = new MultipleAction(xenConnection, Messages.REVERT_WIZARD_CHANGES,
|
||||
|
Loading…
Reference in New Issue
Block a user