2017-01-16 20:59:50 +01:00
|
|
|
|
/* Copyright (c) Citrix Systems, Inc.
|
2013-06-24 13:41:48 +02:00
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms,
|
|
|
|
|
* with or without modification, are permitted provided
|
|
|
|
|
* that the following conditions are met:
|
|
|
|
|
*
|
|
|
|
|
* * Redistributions of source code must retain the above
|
|
|
|
|
* copyright notice, this list of conditions and the
|
|
|
|
|
* following disclaimer.
|
|
|
|
|
* * Redistributions in binary form must reproduce the above
|
|
|
|
|
* copyright notice, this list of conditions and the
|
|
|
|
|
* following disclaimer in the documentation and/or other
|
|
|
|
|
* materials provided with the distribution.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
|
|
|
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
|
|
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
|
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2015-01-26 16:43:36 +01:00
|
|
|
|
using System.IO;
|
2016-08-19 13:11:50 +02:00
|
|
|
|
using System.Linq;
|
2018-04-09 15:28:13 +02:00
|
|
|
|
using System.Text;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
using XenAdmin.Wizards.PatchingWizard.PlanActions;
|
|
|
|
|
using XenAPI;
|
|
|
|
|
|
|
|
|
|
namespace XenAdmin.Wizards.PatchingWizard
|
|
|
|
|
{
|
2018-08-17 13:05:16 +02:00
|
|
|
|
public partial class PatchingWizard_PatchingPage : AutomatedUpdatesBasePage
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2016-10-20 18:19:42 +02:00
|
|
|
|
public Dictionary<string, livepatch_status> LivePatchCodesByHost
|
2016-08-23 19:16:33 +02:00
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
public PatchingWizard_PatchingPage()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region Accessors
|
|
|
|
|
public List<Host> SelectedServers { private get; set; }
|
|
|
|
|
public UpdateType SelectedUpdateType { private get; set; }
|
|
|
|
|
public Pool_patch Patch { private get; set; }
|
2016-10-04 15:58:54 +02:00
|
|
|
|
public Pool_update PoolUpdate { private get; set; }
|
|
|
|
|
|
2018-08-17 13:05:16 +02:00
|
|
|
|
public Dictionary<Pool, StringBuilder> ManualTextInstructions { private get; set; }
|
2013-06-24 13:41:48 +02:00
|
|
|
|
public bool IsAutomaticMode { private get; set; }
|
2015-07-08 18:35:50 +02:00
|
|
|
|
public bool RemoveUpdateFile { private get; set; }
|
2019-01-10 14:24:42 +01:00
|
|
|
|
public string SelectedPatchFilePatch { private get; set; }
|
2015-01-26 16:43:36 +01:00
|
|
|
|
public Dictionary<Host, VDI> SuppPackVdis { private get; set; }
|
2013-06-24 13:41:48 +02:00
|
|
|
|
#endregion
|
|
|
|
|
|
2018-08-17 13:05:16 +02:00
|
|
|
|
#region XenTabPage overrides
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
public override string Text
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Messages.PATCHINGWIZARD_PATCHINGPAGE_TEXT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string PageTitle
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Messages.PATCHINGWIZARD_PATCHINGPAGE_TITLE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string HelpID
|
|
|
|
|
{
|
|
|
|
|
get { return "InstallUpdate"; }
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-17 13:05:16 +02:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region AutomatedUpdatesBesePage overrides
|
|
|
|
|
|
|
|
|
|
protected override List<HostPlan> GenerateHostPlans(Pool pool, out List<Host> applicableHosts)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2018-08-17 13:05:16 +02:00
|
|
|
|
return IsAutomaticMode
|
|
|
|
|
? CompileAutomaticHostPlan(pool, out applicableHosts)
|
|
|
|
|
: CompileManualHostPlan(pool, out applicableHosts);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-17 13:05:16 +02:00
|
|
|
|
protected override string BlurbText()
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2018-08-17 13:05:16 +02:00
|
|
|
|
return string.Format(Messages.PATCHINGWIZARD_SINGLEUPDATE_TITLE, GetUpdateName());
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-17 13:05:16 +02:00
|
|
|
|
protected override string SuccessMessageOnCompletion(bool multiplePools)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2018-08-17 13:05:16 +02:00
|
|
|
|
var msg = multiplePools
|
|
|
|
|
? Messages.PATCHINGWIZARD_SINGLEUPDATE_SUCCESS_MANY
|
|
|
|
|
: Messages.PATCHINGWIZARD_SINGLEUPDATE_SUCCESS_ONE;
|
|
|
|
|
return string.Format(msg, GetUpdateName());
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-13 18:16:40 +01:00
|
|
|
|
protected override string WarningMessageOnCompletion(bool multiplePools)
|
|
|
|
|
{
|
|
|
|
|
var msg = multiplePools
|
|
|
|
|
? Messages.PATCHINGWIZARD_SINGLEUPDATE_WARNING_MANY
|
|
|
|
|
: Messages.PATCHINGWIZARD_SINGLEUPDATE_WARNING_ONE;
|
|
|
|
|
return string.Format(msg, GetUpdateName());
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-17 13:05:16 +02:00
|
|
|
|
protected override string SuccessMessagePerPool(Pool pool)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2018-08-17 13:05:16 +02:00
|
|
|
|
var sb = new StringBuilder();
|
2016-10-04 15:58:54 +02:00
|
|
|
|
|
2018-08-17 13:05:16 +02:00
|
|
|
|
sb.AppendLine(string.Format(Messages.PATCHINGWIZARD_SINGLEUPDATE_SUCCESS_ONE, GetUpdateName())).AppendLine();
|
2016-10-04 15:58:54 +02:00
|
|
|
|
|
2019-09-01 16:12:50 +02:00
|
|
|
|
if (!IsAutomaticMode && ManualTextInstructions != null && ManualTextInstructions.ContainsKey(pool))
|
2018-08-17 13:05:16 +02:00
|
|
|
|
sb.Append(ManualTextInstructions[pool]).AppendLine();
|
2019-02-13 18:16:40 +01:00
|
|
|
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override string WarningMessagePerPool(Pool pool)
|
|
|
|
|
{
|
|
|
|
|
var sb = new StringBuilder();
|
2016-03-03 12:34:00 +01:00
|
|
|
|
|
2018-08-17 13:05:16 +02:00
|
|
|
|
var poolHosts = pool.Connection.Cache.Hosts.ToList();
|
2016-03-03 12:34:00 +01:00
|
|
|
|
|
2018-08-17 13:05:16 +02:00
|
|
|
|
var livePatchingFailedHosts = new List<Host>();
|
|
|
|
|
foreach (var host in SelectedServers)
|
|
|
|
|
{
|
|
|
|
|
if (poolHosts.Contains(host) && LivePatchingAttemptedForHost(host) && HostRequiresReboot(host))
|
|
|
|
|
livePatchingFailedHosts.Add(host);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-17 13:05:16 +02:00
|
|
|
|
if (livePatchingFailedHosts.Count == 1)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2018-08-17 13:05:16 +02:00
|
|
|
|
sb.AppendFormat(Messages.LIVE_PATCHING_FAILED_ONE_HOST, livePatchingFailedHosts[0].Name()).AppendLine();
|
2019-02-13 18:16:40 +01:00
|
|
|
|
return sb.ToString();
|
2018-08-17 13:05:16 +02:00
|
|
|
|
}
|
2019-02-13 18:16:40 +01:00
|
|
|
|
|
|
|
|
|
if (livePatchingFailedHosts.Count > 1)
|
2018-08-17 13:05:16 +02:00
|
|
|
|
{
|
|
|
|
|
var hostnames = string.Join(", ", livePatchingFailedHosts.Select(h => string.Format("'{0}'", h.Name())));
|
|
|
|
|
sb.AppendFormat(Messages.LIVE_PATCHING_FAILED_MULTI_HOST, hostnames).AppendLine();
|
2019-02-13 18:16:40 +01:00
|
|
|
|
return sb.ToString();
|
2018-08-17 13:05:16 +02:00
|
|
|
|
}
|
2019-02-13 18:16:40 +01:00
|
|
|
|
return null;
|
2018-08-17 13:05:16 +02:00
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2019-02-13 18:16:40 +01:00
|
|
|
|
|
2018-08-17 13:05:16 +02:00
|
|
|
|
protected override string FailureMessageOnCompletion(bool multiplePools)
|
|
|
|
|
{
|
|
|
|
|
var msg = multiplePools
|
|
|
|
|
? Messages.PATCHINGWIZARD_SINGLEUPDATE_FAILURE_MANY
|
|
|
|
|
: Messages.PATCHINGWIZARD_SINGLEUPDATE_FAILURE_ONE;
|
|
|
|
|
return string.Format(msg, GetUpdateName());
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-17 13:05:16 +02:00
|
|
|
|
protected override string FailureMessagePerPool(bool multipleErrors)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2018-08-17 13:05:16 +02:00
|
|
|
|
var msg = multipleErrors
|
|
|
|
|
? Messages.PATCHINGWIZARD_SINGLEUPDATE_FAILURE_PER_POOL_MANY
|
|
|
|
|
: Messages.PATCHINGWIZARD_SINGLEUPDATE_FAILURE_PER_POOL_ONE;
|
|
|
|
|
return string.Format(msg, GetUpdateName());
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
2018-08-17 13:05:16 +02:00
|
|
|
|
protected override string UserCancellationMessage()
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2018-08-17 13:05:16 +02:00
|
|
|
|
return Messages.PATCHINGWIZARD_AUTOUPDATINGPAGE_CANCELLATION;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-20 14:23:49 +01:00
|
|
|
|
protected override string ReconsiderCancellationMessage()
|
|
|
|
|
{
|
|
|
|
|
return Messages.PATCHINGWIZARD_AUTOUPDATINGPAGE_CANCELLATION_RECONSIDER;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
#endregion
|
|
|
|
|
|
2018-08-17 13:05:16 +02:00
|
|
|
|
#region Manual mode
|
2018-04-09 15:28:13 +02:00
|
|
|
|
|
2018-08-17 13:05:16 +02:00
|
|
|
|
private List<HostPlan> CompileManualHostPlan(Pool pool, out List<Host> applicableHosts)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2018-08-17 13:05:16 +02:00
|
|
|
|
var poolHosts = pool.Connection.Cache.Hosts.ToList();
|
|
|
|
|
SelectedServers.Sort(); //master first and then the slaves
|
|
|
|
|
var hostplans = new List<HostPlan>();
|
|
|
|
|
|
|
|
|
|
if (SelectedUpdateType == UpdateType.ISO)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2018-08-17 13:05:16 +02:00
|
|
|
|
if (PoolUpdate != null) //ely or greater
|
2018-04-09 15:28:13 +02:00
|
|
|
|
{
|
2018-08-17 13:05:16 +02:00
|
|
|
|
foreach (var server in SelectedServers)
|
|
|
|
|
if (poolHosts.Contains(server))
|
|
|
|
|
{
|
2019-02-13 14:02:22 +01:00
|
|
|
|
var hostRebootRequired = WizardHelpers.IsHostRebootRequiredForUpdate(server, PoolUpdate, LivePatchCodesByHost);
|
|
|
|
|
|
|
|
|
|
var updateActions = new List<PlanAction> {new ApplyPoolUpdatePlanAction(server, PoolUpdate, hostRebootRequired) };
|
2018-08-17 13:05:16 +02:00
|
|
|
|
hostplans.Add(new HostPlan(server, null, updateActions, null));
|
|
|
|
|
}
|
2018-04-09 15:28:13 +02:00
|
|
|
|
}
|
2018-08-17 13:05:16 +02:00
|
|
|
|
else if (SuppPackVdis != null) //supp pack
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2018-08-17 13:05:16 +02:00
|
|
|
|
foreach (var server in SelectedServers)
|
|
|
|
|
if (SuppPackVdis.ContainsKey(server) && poolHosts.Contains(server))
|
|
|
|
|
{
|
|
|
|
|
var updateActions = new List<PlanAction> {new InstallSupplementalPackPlanAction(server, SuppPackVdis[server])};
|
|
|
|
|
hostplans.Add(new HostPlan(server, null, updateActions, null));
|
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-17 13:05:16 +02:00
|
|
|
|
else // legacy
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2018-08-17 13:05:16 +02:00
|
|
|
|
foreach (var server in SelectedServers)
|
|
|
|
|
if (poolHosts.Contains(server))
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2019-02-13 14:02:22 +01:00
|
|
|
|
var hostRebootRequired = WizardHelpers.IsHostRebootRequiredForUpdate(server, Patch, LivePatchCodesByHost);
|
|
|
|
|
|
|
|
|
|
var updateActions = new List<PlanAction> { new ApplyPatchPlanAction(server, Patch, hostRebootRequired) };
|
2018-08-17 13:05:16 +02:00
|
|
|
|
hostplans.Add(new HostPlan(server, null, updateActions, null));
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-17 13:05:16 +02:00
|
|
|
|
if (RemoveUpdateFile && hostplans.Count > 0)
|
|
|
|
|
hostplans[hostplans.Count - 1].UpdatesPlanActions.Add(new RemoveUpdateFile(pool, Patch));
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-17 13:05:16 +02:00
|
|
|
|
applicableHosts = hostplans.Select(h => h.Host).ToList();
|
|
|
|
|
return hostplans;
|
2018-04-09 15:28:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-17 13:05:16 +02:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Automatic mode
|
|
|
|
|
|
|
|
|
|
private List<HostPlan> CompileAutomaticHostPlan(Pool pool, out List<Host> applicableHosts)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2018-08-17 13:05:16 +02:00
|
|
|
|
var poolHosts = pool.Connection.Cache.Hosts.ToList();
|
|
|
|
|
SelectedServers.Sort(); //master first and then the slaves
|
|
|
|
|
var hostplans = new List<HostPlan>();
|
|
|
|
|
|
|
|
|
|
if (SelectedUpdateType == UpdateType.ISO)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2018-08-17 13:05:16 +02:00
|
|
|
|
var poolUpdates = new List<Pool_update>(pool.Connection.Cache.Pool_updates);
|
|
|
|
|
var poolUpdate = poolUpdates.FirstOrDefault(u => u != null && string.Equals(u.uuid, PoolUpdate.uuid, StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
|
|
|
|
|
if (poolUpdate != null) //ely or greater
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2018-08-17 13:05:16 +02:00
|
|
|
|
foreach (var server in SelectedServers)
|
|
|
|
|
if (poolHosts.Contains(server) && !poolUpdate.AppliedOn(server))
|
|
|
|
|
hostplans.Add(new HostPlan(server, null, CompilePoolUpdateActionList(server, poolUpdate), null));
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
2018-08-17 13:05:16 +02:00
|
|
|
|
else if (SuppPackVdis != null) // supp pack
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2018-08-17 13:05:16 +02:00
|
|
|
|
foreach (var server in SelectedServers)
|
|
|
|
|
if (SuppPackVdis.ContainsKey(server) && poolHosts.Contains(server))
|
|
|
|
|
{
|
|
|
|
|
var updateActions = new List<PlanAction>
|
|
|
|
|
{
|
|
|
|
|
new InstallSupplementalPackPlanAction(server, SuppPackVdis[server]),
|
|
|
|
|
new RestartHostPlanAction(server, server.GetRunningVMs())
|
|
|
|
|
};
|
|
|
|
|
hostplans.Add(new HostPlan(server, null, updateActions, null));
|
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-17 13:05:16 +02:00
|
|
|
|
else //legacy
|
|
|
|
|
{
|
|
|
|
|
var poolPatches = new List<Pool_patch>(pool.Connection.Cache.Pool_patches);
|
|
|
|
|
var poolPatch = poolPatches.Find(p => Patch != null && string.Equals(p.uuid, Patch.uuid, StringComparison.OrdinalIgnoreCase));
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2018-08-17 13:05:16 +02:00
|
|
|
|
if (poolPatch != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (Host server in SelectedServers)
|
|
|
|
|
if (poolHosts.Contains(server) && poolPatch.AppliedOn(server) == DateTime.MaxValue)
|
|
|
|
|
hostplans.Add(new HostPlan(server, null, CompilePatchActionList(server, poolPatch), null));
|
|
|
|
|
}
|
2015-01-26 16:43:36 +01:00
|
|
|
|
|
2018-08-17 13:05:16 +02:00
|
|
|
|
if (RemoveUpdateFile && hostplans.Count > 0)
|
|
|
|
|
hostplans[hostplans.Count - 1].UpdatesPlanActions.Add(new RemoveUpdateFile(pool, poolPatch));
|
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2018-08-17 13:05:16 +02:00
|
|
|
|
applicableHosts = hostplans.Select(h => h.Host).ToList();
|
|
|
|
|
return hostplans;
|
|
|
|
|
}
|
2015-01-26 16:43:36 +01:00
|
|
|
|
|
2018-08-17 13:05:16 +02:00
|
|
|
|
private List<PlanAction> CompilePatchActionList(Host host, Pool_patch patch)
|
|
|
|
|
{
|
2019-02-13 14:02:22 +01:00
|
|
|
|
var hostRebootRequired = WizardHelpers.IsHostRebootRequiredForUpdate(host, patch, LivePatchCodesByHost);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2019-02-13 14:02:22 +01:00
|
|
|
|
var actions = new List<PlanAction> {new ApplyPatchPlanAction(host, patch, hostRebootRequired) };
|
|
|
|
|
|
|
|
|
|
if (hostRebootRequired)
|
2018-03-06 16:12:04 +01:00
|
|
|
|
actions.Add(new RestartHostPlanAction(host, host.GetRunningVMs()));
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
if (patch.after_apply_guidance.Contains(after_apply_guidance.restartXAPI))
|
|
|
|
|
actions.Add(new RestartAgentPlanAction(host));
|
|
|
|
|
|
|
|
|
|
if (patch.after_apply_guidance.Contains(after_apply_guidance.restartHVM))
|
2018-03-01 13:42:33 +01:00
|
|
|
|
actions.Add(new RebootVMsPlanAction(host, host.GetRunningHvmVMs()));
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
if (patch.after_apply_guidance.Contains(after_apply_guidance.restartPV))
|
2018-03-01 13:42:33 +01:00
|
|
|
|
actions.Add(new RebootVMsPlanAction(host, host.GetRunningPvVMs()));
|
2015-01-26 16:43:36 +01:00
|
|
|
|
|
|
|
|
|
return actions;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-04 15:58:54 +02:00
|
|
|
|
private List<PlanAction> CompilePoolUpdateActionList(Host host, Pool_update poolUpdate)
|
|
|
|
|
{
|
2019-02-13 14:02:22 +01:00
|
|
|
|
var hostRebootRequired = WizardHelpers.IsHostRebootRequiredForUpdate(host, poolUpdate, LivePatchCodesByHost);
|
2016-10-04 15:58:54 +02:00
|
|
|
|
|
2019-02-13 14:02:22 +01:00
|
|
|
|
var actions = new List<PlanAction> {new ApplyPoolUpdatePlanAction(host, poolUpdate, hostRebootRequired) };
|
|
|
|
|
|
|
|
|
|
if (hostRebootRequired)
|
2018-03-06 16:12:04 +01:00
|
|
|
|
actions.Add(new RestartHostPlanAction(host, host.GetRunningVMs()));
|
2016-10-04 15:58:54 +02:00
|
|
|
|
|
|
|
|
|
if (poolUpdate.after_apply_guidance.Contains(update_after_apply_guidance.restartXAPI))
|
|
|
|
|
actions.Add(new RestartAgentPlanAction(host));
|
|
|
|
|
|
|
|
|
|
if (poolUpdate.after_apply_guidance.Contains(update_after_apply_guidance.restartHVM))
|
2018-03-01 13:42:33 +01:00
|
|
|
|
actions.Add(new RebootVMsPlanAction(host, host.GetRunningHvmVMs()));
|
2016-10-04 15:58:54 +02:00
|
|
|
|
|
|
|
|
|
if (poolUpdate.after_apply_guidance.Contains(update_after_apply_guidance.restartPV))
|
2018-03-01 13:42:33 +01:00
|
|
|
|
actions.Add(new RebootVMsPlanAction(host, host.GetRunningPvVMs()));
|
2018-08-17 13:05:16 +02:00
|
|
|
|
|
2016-10-04 15:58:54 +02:00
|
|
|
|
return actions;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
#endregion
|
|
|
|
|
|
2016-08-19 13:11:50 +02:00
|
|
|
|
/// <summary>
|
2018-08-17 13:05:16 +02:00
|
|
|
|
/// Live patching is attempted for a host if the LivePatchCodesByHost
|
|
|
|
|
/// contains the LIVEPATCH_COMPLETE value for that host
|
2016-08-19 13:11:50 +02:00
|
|
|
|
/// </summary>
|
|
|
|
|
private bool LivePatchingAttemptedForHost(Host host)
|
|
|
|
|
{
|
|
|
|
|
return LivePatchCodesByHost != null && LivePatchCodesByHost.ContainsKey(host.uuid) &&
|
2016-10-20 18:19:42 +02:00
|
|
|
|
LivePatchCodesByHost[host.uuid] == livepatch_status.ok_livepatch_complete;
|
2016-08-19 13:11:50 +02:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2018-08-17 13:05:16 +02:00
|
|
|
|
/// Returns true if the host has to be rebooted for this update
|
2016-08-19 13:11:50 +02:00
|
|
|
|
/// </summary>
|
2016-10-12 15:48:17 +02:00
|
|
|
|
private bool HostRequiresReboot(Host host)
|
2016-08-19 13:11:50 +02:00
|
|
|
|
{
|
2018-08-17 13:05:16 +02:00
|
|
|
|
return host.updates_requiring_reboot != null && PoolUpdate != null
|
2016-10-12 15:48:17 +02:00
|
|
|
|
&& host.updates_requiring_reboot.Select(uRef => host.Connection.Resolve(uRef)).Any(u => u != null && u.uuid.Equals(PoolUpdate.uuid));
|
2016-08-19 13:11:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-01-26 16:43:36 +01:00
|
|
|
|
private string GetUpdateName()
|
|
|
|
|
{
|
2018-08-17 13:05:16 +02:00
|
|
|
|
if (PoolUpdate != null)
|
|
|
|
|
return PoolUpdate.Name();
|
|
|
|
|
|
2015-01-28 10:51:25 +01:00
|
|
|
|
if (Patch != null)
|
2017-09-03 04:33:29 +02:00
|
|
|
|
return Patch.Name();
|
2018-08-17 13:05:16 +02:00
|
|
|
|
|
2015-01-28 10:51:25 +01:00
|
|
|
|
try
|
|
|
|
|
{
|
2019-01-10 14:24:42 +01:00
|
|
|
|
return new FileInfo(SelectedPatchFilePatch).Name;
|
2015-01-28 10:51:25 +01:00
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
2019-01-10 14:24:42 +01:00
|
|
|
|
return SelectedPatchFilePatch;
|
2015-01-28 10:51:25 +01:00
|
|
|
|
}
|
2015-01-26 16:43:36 +01:00
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|