From 1bd439a2afdceb96e9f0d06b4bfbe4233e5e3057 Mon Sep 17 00:00:00 2001 From: Mihaela Stoica Date: Mon, 25 Jun 2018 16:31:46 +0100 Subject: [PATCH] CP-28279: Corrections to the plan actions - In the RPU case, re-enable the host after the upgrade is done, as the host will be put back into maintenance mode when needed during the update process. - The VMs should not be repatriated during the RPU - When a host is rebooted, it needs to be disabled first (even if an evacuation is not needed), otherwise the reboot won't happen Signed-off-by: Mihaela Stoica --- .../AutomatedUpdatesBasePage.cs | 14 +++++++++----- .../PlanActions/HostPlanAction.cs | 19 +++++++++++++------ .../PlanActions/RestartHostPlanAction.cs | 12 ++++-------- .../RollingUpgradeUpgradePage.cs | 11 ++++------- 4 files changed, 30 insertions(+), 26 deletions(-) diff --git a/XenAdmin/Wizards/PatchingWizard/AutomatedUpdatesBasePage.cs b/XenAdmin/Wizards/PatchingWizard/AutomatedUpdatesBasePage.cs index 68949ff23..3f377391a 100644 --- a/XenAdmin/Wizards/PatchingWizard/AutomatedUpdatesBasePage.cs +++ b/XenAdmin/Wizards/PatchingWizard/AutomatedUpdatesBasePage.cs @@ -488,7 +488,8 @@ namespace XenAdmin.Wizards.PatchingWizard RetryFailedActions(); } - protected HostPlan GetUpdatePlanActionsForHost(Host host, List hosts, List minimalPatches, List uploadedPatches, KeyValuePair patchFromDisk) + protected HostPlan GetUpdatePlanActionsForHost(Host host, List hosts, List minimalPatches, + List uploadedPatches, KeyValuePair patchFromDisk, bool repatriateVms = true) { var patchSequence = Updates.GetPatchSequenceForHost(host, minimalPatches); if (patchSequence == null) @@ -541,11 +542,14 @@ namespace XenAdmin.Wizards.PatchingWizard } } - var lastRestart = delayedActionsPerHost.FindLast(a => a is RestartHostPlanAction) - ?? planActionsPerHost.FindLast(a => a is RestartHostPlanAction); + if (repatriateVms) + { + var lastRestart = delayedActionsPerHost.FindLast(a => a is RestartHostPlanAction) + ?? planActionsPerHost.FindLast(a => a is RestartHostPlanAction); - if (lastRestart != null) - ((RestartHostPlanAction)lastRestart).EnableOnly = false; + if (lastRestart != null) + ((RestartHostPlanAction) lastRestart).EnableOnly = false; + } return new HostPlan(host, null, planActionsPerHost, delayedActionsPerHost); } diff --git a/XenAdmin/Wizards/PatchingWizard/PlanActions/HostPlanAction.cs b/XenAdmin/Wizards/PatchingWizard/PlanActions/HostPlanAction.cs index 788ae91cf..0aef6e496 100644 --- a/XenAdmin/Wizards/PatchingWizard/PlanActions/HostPlanAction.cs +++ b/XenAdmin/Wizards/PatchingWizard/PlanActions/HostPlanAction.cs @@ -66,16 +66,23 @@ namespace XenAdmin.Wizards.PatchingWizard.PlanActions var hostObj = GetResolvedHost(); Title = string.Format(Messages.PLANACTION_VMS_MIGRATING, hostObj.Name()); - PBD.CheckAndPlugPBDsFor(Connection.ResolveAll(hostObj.resident_VMs)); + + var vms = hostObj.GetRunningVMs(); + if (vms.Count > 0) + { + PBD.CheckAndPlugPBDsFor(Connection.ResolveAll(hostObj.resident_VMs)); + } log.DebugFormat("Disabling host {0}", hostObj.Name()); Host.disable(session, HostXenRef.opaque_ref); - Status = Messages.PLAN_ACTION_STATUS_MIGRATING_VMS_FROM_HOST; - log.DebugFormat("Migrating VMs from host {0}", hostObj.Name()); - XenRef task = Host.async_evacuate(session, HostXenRef.opaque_ref); - - PollTaskForResultAndDestroy(Connection, ref session, task); + if (vms.Count > 0) + { + Status = Messages.PLAN_ACTION_STATUS_MIGRATING_VMS_FROM_HOST; + log.DebugFormat("Migrating VMs from host {0}", hostObj.Name()); + XenRef task = Host.async_evacuate(session, HostXenRef.opaque_ref); + PollTaskForResultAndDestroy(Connection, ref session, task); + } } protected void BringBabiesBack(ref Session session, List> vmrefs, bool enableOnly) diff --git a/XenAdmin/Wizards/PatchingWizard/PlanActions/RestartHostPlanAction.cs b/XenAdmin/Wizards/PatchingWizard/PlanActions/RestartHostPlanAction.cs index b28af8659..a02deaed3 100644 --- a/XenAdmin/Wizards/PatchingWizard/PlanActions/RestartHostPlanAction.cs +++ b/XenAdmin/Wizards/PatchingWizard/PlanActions/RestartHostPlanAction.cs @@ -84,14 +84,10 @@ namespace XenAdmin.Wizards.PatchingWizard.PlanActions Visible = true; var sb = new StringBuilder(); - var vms = hostObj.GetRunningVMs(); - if (vms.Count > 0) - { - sb.Append(string.Format(Messages.PLANACTION_VMS_MIGRATING, hostObj.Name())); - ProgressDescription = sb.ToString(); - EvacuateHost(ref session); - sb.AppendLine(Messages.DONE); - } + sb.Append(string.Format(Messages.PLANACTION_VMS_MIGRATING, hostObj.Name())); + ProgressDescription = sb.ToString(); + EvacuateHost(ref session); + sb.AppendLine(Messages.DONE); sb.AppendIndented(string.Format(Messages.UPDATES_WIZARD_REBOOTING, hostObj.Name()), sb.Length > 0 ? 2 : 0); ProgressDescription = sb.ToString(); diff --git a/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeUpgradePage.cs b/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeUpgradePage.cs index 368cb1829..53b4fdf4d 100644 --- a/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeUpgradePage.cs +++ b/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeUpgradePage.cs @@ -156,7 +156,7 @@ namespace XenAdmin.Wizards.RollingUpgradeWizard AllUploadedPatches.Add(bgw, new List()); var uploadedPatches = AllUploadedPatches[bgw]; - var hp = GetUpdatePlanActionsForHost(host, hosts, minimalPatches, uploadedPatches, new KeyValuePair()); + var hp = GetUpdatePlanActionsForHost(host, hosts, minimalPatches, uploadedPatches, new KeyValuePair(), false); if (hp.UpdatesPlanActions != null && hp.UpdatesPlanActions.Count > 0) { theHostPlan.UpdatesPlanActions.AddRange(hp.UpdatesPlanActions); @@ -179,14 +179,11 @@ namespace XenAdmin.Wizards.RollingUpgradeWizard var initialPlanActions = new List() { new EvacuateHostPlanAction(host), - upgradeAction - }; - - var delayedActions = new List() - { + upgradeAction, new BringBabiesBackAction(runningVMs, host, true) }; - return new HostPlan(host, initialPlanActions, null, delayedActions); + + return new HostPlan(host, initialPlanActions, null, new List()); } #endregion