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;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using XenAdmin.Actions;
|
2017-03-22 11:59:32 +01:00
|
|
|
|
using XenAdmin.Alerts;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
using XenAdmin.Controls;
|
|
|
|
|
using XenAdmin.Core;
|
|
|
|
|
using XenAdmin.Diagnostics.Checks;
|
|
|
|
|
using XenAdmin.Diagnostics.Problems;
|
|
|
|
|
using XenAdmin.Diagnostics.Problems.HostProblem;
|
|
|
|
|
using XenAdmin.Dialogs;
|
|
|
|
|
using XenAPI;
|
2018-03-05 14:43:56 +01:00
|
|
|
|
using CheckGroup = System.Collections.Generic.KeyValuePair<string, System.Collections.Generic.List<XenAdmin.Diagnostics.Checks.Check>>;
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
namespace XenAdmin.Wizards.PatchingWizard
|
|
|
|
|
{
|
|
|
|
|
public partial class PatchingWizard_PrecheckPage : XenTabPage
|
|
|
|
|
{
|
|
|
|
|
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
|
|
|
|
2018-02-28 12:20:00 +01:00
|
|
|
|
private readonly object _lock = new object();
|
|
|
|
|
private readonly object _update_grid_lock = new object();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
public List<Host> SelectedServers = new List<Host>();
|
2018-06-29 20:49:28 +02:00
|
|
|
|
private readonly List<Problem> ProblemsResolvedPreCheck = new List<Problem>();
|
2018-02-28 12:20:00 +01:00
|
|
|
|
private AsyncAction resolvePrechecksAction;
|
2018-07-26 17:11:53 +02:00
|
|
|
|
private List<DataGridViewRow> allRows = new List<DataGridViewRow>();
|
2018-07-03 16:17:57 +02:00
|
|
|
|
|
|
|
|
|
private bool _isRecheckQueued;
|
2018-03-14 13:19:14 +01:00
|
|
|
|
public Dictionary<Pool_update, Dictionary<Host, SR>> SrUploadedUpdates = new Dictionary<Pool_update, Dictionary<Host, SR>>();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
protected List<Pool> SelectedPools
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2017-09-07 15:15:48 +02:00
|
|
|
|
return SelectedServers.Select(host => Helpers.GetPoolOfOne(host.Connection)).Where(pool => pool != null).Distinct().ToList();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-22 11:59:32 +01:00
|
|
|
|
public XenServerPatchAlert UpdateAlert { private get; set; }
|
2017-03-24 17:43:19 +01:00
|
|
|
|
public WizardMode WizardMode { private get; set; }
|
2018-06-19 18:50:01 +02:00
|
|
|
|
public bool ApplyUpdatesToNewVersion { protected get; set; }
|
2017-03-22 11:59:32 +01:00
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
public PatchingWizard_PrecheckPage()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string PageTitle
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Messages.PATCHINGWIZARD_PRECHECKPAGE_TITLE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Text
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Messages.PATCHINGWIZARD_PRECHECKPAGE_TEXT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string HelpID
|
|
|
|
|
{
|
|
|
|
|
get { return "UpdatePrechecks"; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Connection_ConnectionStateChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2018-02-28 12:56:24 +01:00
|
|
|
|
Program.Invoke(this, RefreshRechecks);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RegisterEventHandlers()
|
|
|
|
|
{
|
|
|
|
|
foreach (Host selectedServer in SelectedServers)
|
|
|
|
|
{
|
|
|
|
|
selectedServer.Connection.ConnectionStateChanged += Connection_ConnectionStateChanged;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DeregisterEventHandlers()
|
|
|
|
|
{
|
|
|
|
|
foreach (Host selectedServer in SelectedServers)
|
|
|
|
|
{
|
|
|
|
|
selectedServer.Connection.ConnectionStateChanged -= Connection_ConnectionStateChanged;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-09 01:31:46 +01:00
|
|
|
|
protected override void PageLoadedCore(PageLoadedDirection direction)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2018-07-06 02:46:12 +02:00
|
|
|
|
RegisterEventHandlers();
|
|
|
|
|
if (direction == PageLoadedDirection.Back)
|
|
|
|
|
return;
|
2016-03-17 17:35:00 +01:00
|
|
|
|
|
2018-07-06 02:46:12 +02:00
|
|
|
|
if (WizardMode == WizardMode.AutomatedUpdates)
|
|
|
|
|
{
|
|
|
|
|
labelPrechecksFirstLine.Text = Messages.PATCHINGWIZARD_PRECHECKPAGE_FIRSTLINE_AUTOMATED_UPDATES_MODE;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
2018-07-06 02:46:12 +02:00
|
|
|
|
else
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2018-07-06 02:46:12 +02:00
|
|
|
|
string patchName = null;
|
|
|
|
|
if (Patch != null)
|
|
|
|
|
patchName = Patch.Name();
|
|
|
|
|
if (PoolUpdate != null)
|
|
|
|
|
patchName = PoolUpdate.Name();
|
|
|
|
|
|
|
|
|
|
labelPrechecksFirstLine.Text = patchName != null
|
|
|
|
|
? string.Format(Messages.PATCHINGWIZARD_PRECHECKPAGE_FIRSTLINE, patchName)
|
|
|
|
|
: Messages.PATCHINGWIZARD_PRECHECKPAGE_FIRSTLINE_NO_PATCH_NAME;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
2018-07-06 02:46:12 +02:00
|
|
|
|
|
|
|
|
|
RefreshRechecks();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-08 15:47:58 +01:00
|
|
|
|
public override void SelectDefaultControl()
|
|
|
|
|
{
|
|
|
|
|
dataGridView1.Select();
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
protected void RefreshRechecks()
|
|
|
|
|
{
|
2018-07-03 16:17:57 +02:00
|
|
|
|
if (IsCheckInProgress)
|
|
|
|
|
{
|
|
|
|
|
_isRecheckQueued = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-10-04 15:58:54 +02:00
|
|
|
|
|
|
|
|
|
if (Patch != null)
|
|
|
|
|
_worker.RunWorkerAsync(Patch);
|
|
|
|
|
else
|
2016-10-13 15:53:46 +02:00
|
|
|
|
_worker.RunWorkerAsync(PoolUpdate);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!e.Cancelled)
|
|
|
|
|
{
|
2018-02-28 12:56:24 +01:00
|
|
|
|
progressBar1.Value = 100;
|
|
|
|
|
labelProgress.Text = string.Empty;
|
|
|
|
|
OnPageUpdated();
|
2018-07-03 16:17:57 +02:00
|
|
|
|
|
|
|
|
|
if (_isRecheckQueued)
|
|
|
|
|
{
|
|
|
|
|
_isRecheckQueued = false;
|
|
|
|
|
RefreshRechecks();
|
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddRowToGridView(DataGridViewRow row)
|
|
|
|
|
{
|
|
|
|
|
lock (_update_grid_lock)
|
|
|
|
|
{
|
|
|
|
|
dataGridView1.Rows.Add(row);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
PreCheckHostRow rowHost = e.UserState as PreCheckHostRow;
|
|
|
|
|
if (rowHost != null)
|
|
|
|
|
{
|
2018-07-26 17:11:53 +02:00
|
|
|
|
allRows.Add(rowHost);
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
if (checkBoxViewPrecheckFailuresOnly.Checked && rowHost.Problem != null || !checkBoxViewPrecheckFailuresOnly.Checked)
|
|
|
|
|
AddRowToGridView(rowHost);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var row = e.UserState as DataGridViewRow;
|
|
|
|
|
if (row != null && !dataGridView1.Rows.Contains(row))
|
|
|
|
|
{
|
2018-07-26 17:11:53 +02:00
|
|
|
|
allRows.Add(row);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
AddRowToGridView(row);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-02-28 12:20:00 +01:00
|
|
|
|
|
|
|
|
|
progressBar1.Value = e.ProgressPercentage;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
catch (Exception) { }
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-19 16:45:16 +02:00
|
|
|
|
private bool IsCheckInProgress
|
|
|
|
|
{
|
2018-07-03 16:17:57 +02:00
|
|
|
|
get { return _worker.IsBusy; }
|
2016-08-19 16:45:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool IsResolveActionInProgress
|
|
|
|
|
{
|
|
|
|
|
get { return resolvePrechecksAction != null && !resolvePrechecksAction.IsCompleted; }
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-07 18:40:59 +02:00
|
|
|
|
private List<PreCheckHostRow> ExecuteCheck(Check check)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2016-06-07 18:40:59 +02:00
|
|
|
|
var rows = new List<PreCheckHostRow>();
|
|
|
|
|
|
|
|
|
|
var problems = check.RunAllChecks();
|
|
|
|
|
if (problems.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
rows.Add(new PreCheckHostRow(check));
|
|
|
|
|
return rows;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var pr in problems)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2016-06-07 18:40:59 +02:00
|
|
|
|
var problem = pr; // we need this line because we sometimes reassign it below
|
2013-06-24 13:41:48 +02:00
|
|
|
|
if (problem is HostNotLive)
|
|
|
|
|
{
|
|
|
|
|
// this host is no longer live -> remove all previous problems regarding this host
|
|
|
|
|
Problem curProblem = problem;
|
2018-06-28 17:01:39 +02:00
|
|
|
|
ProblemsResolvedPreCheck.RemoveAll(p =>
|
2018-07-12 17:17:18 +02:00
|
|
|
|
p.Check != null && p.Check.XenObject != null && curProblem.Check != null &&
|
|
|
|
|
p.Check.XenObject.Equals(curProblem.Check.XenObject));
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ProblemsResolvedPreCheck.Contains(problem))
|
|
|
|
|
{
|
|
|
|
|
Problem curProblem = problem;
|
|
|
|
|
problem = ProblemsResolvedPreCheck.Find(p => p.Equals(curProblem));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
ProblemsResolvedPreCheck.Add(problem);
|
2016-06-07 18:40:59 +02:00
|
|
|
|
|
|
|
|
|
rows.Add(new PreCheckHostRow(problem));
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
2016-06-07 18:40:59 +02:00
|
|
|
|
return rows;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void worker_DoWork(object sender, DoWorkEventArgs e)
|
|
|
|
|
{
|
2018-07-03 16:17:57 +02:00
|
|
|
|
var bgw = sender as BackgroundWorker;
|
|
|
|
|
if (bgw == null)
|
|
|
|
|
return;
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
lock (_lock)
|
|
|
|
|
{
|
2018-07-03 16:17:57 +02:00
|
|
|
|
bgw.ReportProgress(0, null);
|
2015-04-16 15:17:02 +02:00
|
|
|
|
Program.Invoke(this, () =>
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
dataGridView1.Rows.Clear();
|
2016-08-12 14:15:18 +02:00
|
|
|
|
labelProgress.Text = Messages.PATCHING_WIZARD_RUNNING_PRECHECKS;
|
2018-02-28 12:56:24 +01:00
|
|
|
|
OnPageUpdated();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
});
|
|
|
|
|
Pool_patch patch = e.Argument as Pool_patch;
|
2016-10-04 15:58:54 +02:00
|
|
|
|
Pool_update update = e.Argument as Pool_update;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2016-11-08 12:43:54 +01:00
|
|
|
|
LivePatchCodesByHost = new Dictionary<string, livepatch_status>();
|
|
|
|
|
|
2018-03-05 14:43:56 +01:00
|
|
|
|
// Note: represent the groups as list so as to enforce the order of checks;
|
|
|
|
|
// a dictionary that looks sensible from a first look is not guranteed to
|
|
|
|
|
// keep the order, especially if items are removed (although not the case here)
|
2018-02-28 12:20:00 +01:00
|
|
|
|
var groups = update != null ? GenerateChecks(update) : GenerateChecks(patch); //patch is expected to be null for RPU
|
|
|
|
|
|
2018-03-05 14:43:56 +01:00
|
|
|
|
int totalChecks = groups.Sum(c => c.Value == null ? 0 : c.Value.Count);
|
2018-02-28 12:20:00 +01:00
|
|
|
|
int doneCheckIndex = 0;
|
|
|
|
|
|
2018-07-26 17:11:53 +02:00
|
|
|
|
allRows.Clear();
|
|
|
|
|
|
2018-02-28 12:20:00 +01:00
|
|
|
|
foreach (var group in groups)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2018-07-03 16:17:57 +02:00
|
|
|
|
if (bgw.CancellationPending)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
e.Cancel = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-28 12:20:00 +01:00
|
|
|
|
var headerRow = new PreCheckHeaderRow(string.Format(Messages.PATCHING_WIZARD_PRECHECK_STATUS, group.Key));
|
|
|
|
|
//multiply with 100 first, otherwise the quotient is 0
|
2018-07-03 16:17:57 +02:00
|
|
|
|
bgw.ReportProgress(doneCheckIndex * 100 / totalChecks, headerRow);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
PreCheckResult precheckResult = PreCheckResult.OK;
|
2018-02-28 12:20:00 +01:00
|
|
|
|
var checks = group.Value;
|
|
|
|
|
|
|
|
|
|
foreach (var check in checks)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2018-07-03 16:17:57 +02:00
|
|
|
|
if (bgw.CancellationPending)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
e.Cancel = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-28 12:20:00 +01:00
|
|
|
|
var rows = ExecuteCheck(check);
|
|
|
|
|
doneCheckIndex++;
|
|
|
|
|
|
|
|
|
|
foreach (PreCheckHostRow row in rows)
|
2016-06-07 18:40:59 +02:00
|
|
|
|
{
|
|
|
|
|
if (precheckResult != PreCheckResult.Failed && row.Problem != null)
|
2016-10-20 14:09:48 +02:00
|
|
|
|
precheckResult = row.PrecheckResult;
|
2018-02-28 12:20:00 +01:00
|
|
|
|
|
|
|
|
|
//multiply with 100 first, otherwise the quotient is 0
|
2018-07-03 16:17:57 +02:00
|
|
|
|
bgw.ReportProgress(doneCheckIndex * 100 / totalChecks, row);
|
2016-06-07 18:40:59 +02:00
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lock (_update_grid_lock)
|
|
|
|
|
{
|
|
|
|
|
headerRow.UpdateDescription(precheckResult);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-20 18:19:42 +02:00
|
|
|
|
public Dictionary<string, livepatch_status> LivePatchCodesByHost
|
2016-08-23 19:16:33 +02:00
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-05 14:43:56 +01:00
|
|
|
|
protected virtual List<CheckGroup> GenerateCommonChecks(List<Host> applicableServers)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2018-03-05 14:43:56 +01:00
|
|
|
|
var groups = new List<CheckGroup>();
|
2017-03-22 11:59:32 +01:00
|
|
|
|
|
2018-06-22 12:38:38 +02:00
|
|
|
|
//XenCenter version check
|
2017-03-22 11:59:32 +01:00
|
|
|
|
if (UpdateAlert != null && UpdateAlert.NewServerVersion != null)
|
2018-06-18 11:46:41 +02:00
|
|
|
|
{
|
2018-03-05 14:43:56 +01:00
|
|
|
|
groups.Add(new CheckGroup(Messages.CHECKING_XENCENTER_VERSION, new List<Check> {new XenCenterVersionCheck(UpdateAlert.NewServerVersion)}));
|
2018-06-18 11:46:41 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
//HostLivenessCheck checks
|
2018-02-28 12:20:00 +01:00
|
|
|
|
var livenessChecks = new List<Check>();
|
2017-05-04 15:25:36 +02:00
|
|
|
|
foreach (Host host in applicableServers)
|
2018-02-28 12:20:00 +01:00
|
|
|
|
livenessChecks.Add(new HostLivenessCheck(host));
|
|
|
|
|
|
2018-03-05 14:43:56 +01:00
|
|
|
|
groups.Add(new CheckGroup(Messages.CHECKING_HOST_LIVENESS_STATUS, livenessChecks));
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
//HA checks
|
2018-02-28 12:20:00 +01:00
|
|
|
|
|
|
|
|
|
var haChecks = new List<Check>();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
foreach (Host host in SelectedServers)
|
|
|
|
|
{
|
|
|
|
|
if (Helpers.HostIsMaster(host))
|
2018-02-28 12:20:00 +01:00
|
|
|
|
haChecks.Add(new HAOffCheck(host));
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
2018-03-05 14:43:56 +01:00
|
|
|
|
groups.Add(new CheckGroup(Messages.CHECKING_HA_STATUS, haChecks));
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
//PBDsPluggedCheck
|
2018-02-28 12:20:00 +01:00
|
|
|
|
var pbdChecks = new List<Check>();
|
2017-05-04 15:25:36 +02:00
|
|
|
|
foreach (Host host in applicableServers)
|
2018-03-14 13:19:14 +01:00
|
|
|
|
{
|
|
|
|
|
SR uploadSr = null;
|
|
|
|
|
if (PoolUpdate != null && SrUploadedUpdates != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var dict in SrUploadedUpdates)
|
|
|
|
|
{
|
|
|
|
|
if (dict.Key.uuid == PoolUpdate.uuid && dict.Value.ContainsKey(host))
|
|
|
|
|
{
|
|
|
|
|
uploadSr = dict.Value[host];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
pbdChecks.Add(new PBDsPluggedCheck(host, uploadSr));
|
|
|
|
|
}
|
2018-02-28 12:20:00 +01:00
|
|
|
|
|
2018-03-05 14:43:56 +01:00
|
|
|
|
groups.Add(new CheckGroup(Messages.CHECKING_STORAGE_CONNECTIONS_STATUS, pbdChecks));
|
2018-02-28 12:20:00 +01:00
|
|
|
|
|
2018-07-26 17:01:48 +02:00
|
|
|
|
//Disk space, reboot required and can evacuate host checks for automated and version updates
|
2017-03-24 17:43:19 +01:00
|
|
|
|
if (WizardMode != WizardMode.SingleUpdate)
|
2016-10-05 00:26:35 +02:00
|
|
|
|
{
|
2018-02-28 12:20:00 +01:00
|
|
|
|
var diskChecks = new List<Check>();
|
2018-07-26 17:01:48 +02:00
|
|
|
|
var rebootChecks = new List<Check>();
|
|
|
|
|
var evacuateChecks = new List<Check>();
|
2016-10-05 00:26:35 +02:00
|
|
|
|
|
|
|
|
|
foreach (Pool pool in SelectedPools)
|
|
|
|
|
{
|
2017-03-27 12:11:26 +02:00
|
|
|
|
//if any host is not licensed for automated updates
|
|
|
|
|
bool automatedUpdatesRestricted = pool.Connection.Cache.Hosts.Any(Host.RestrictBatchHotfixApply);
|
|
|
|
|
|
2018-06-05 12:50:34 +02:00
|
|
|
|
var minimalPatches = WizardMode == WizardMode.NewVersion
|
2018-08-03 17:11:06 +02:00
|
|
|
|
? Updates.GetMinimalPatches(UpdateAlert, ApplyUpdatesToNewVersion && !automatedUpdatesRestricted)
|
2018-06-05 12:50:34 +02:00
|
|
|
|
: Updates.GetMinimalPatches(pool.Connection);
|
2017-08-29 17:59:49 +02:00
|
|
|
|
|
2018-06-05 12:50:34 +02:00
|
|
|
|
if (minimalPatches == null)
|
2017-03-24 17:43:19 +01:00
|
|
|
|
continue;
|
2016-10-05 00:26:35 +02:00
|
|
|
|
|
2018-06-05 12:50:34 +02:00
|
|
|
|
var us = new Dictionary<Host, List<XenServerPatch>>();
|
|
|
|
|
var hosts = pool.Connection.Cache.Hosts;
|
2018-08-20 16:46:58 +02:00
|
|
|
|
Array.Sort(hosts);
|
2018-06-05 12:50:34 +02:00
|
|
|
|
|
|
|
|
|
foreach (var h in hosts)
|
|
|
|
|
{
|
|
|
|
|
var ps = Updates.GetPatchSequenceForHost(h, minimalPatches);
|
|
|
|
|
if (ps != null)
|
|
|
|
|
us[h] = ps;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.InfoFormat("Minimal patches for {0}: {1}", pool.Name(), string.Join(",", minimalPatches.Select(p => p.Name)));
|
|
|
|
|
|
2018-08-03 17:11:06 +02:00
|
|
|
|
// we check the contains-livepatch property of all the applicable patches to determine if a host will need to be rebooted after patch installation,
|
|
|
|
|
// because the minimal patches might roll-up patches that are not live-patchable
|
|
|
|
|
var allPatches = WizardMode == WizardMode.NewVersion
|
|
|
|
|
? Updates.GetAllPatches(UpdateAlert, ApplyUpdatesToNewVersion && !automatedUpdatesRestricted)
|
|
|
|
|
: Updates.GetAllPatches(pool.Connection);
|
|
|
|
|
|
2016-10-05 00:26:35 +02:00
|
|
|
|
foreach (Host host in us.Keys)
|
|
|
|
|
{
|
2018-06-13 18:22:52 +02:00
|
|
|
|
diskChecks.Add(new DiskSpaceForAutomatedUpdatesCheck(host, us));
|
2018-07-26 17:01:48 +02:00
|
|
|
|
|
|
|
|
|
if (us[host] != null && us[host].Count > 0)
|
|
|
|
|
{
|
2018-08-03 17:11:06 +02:00
|
|
|
|
var allApplicablePatches = Updates.GetPatchSequenceForHost(host, allPatches);
|
|
|
|
|
var restartHostPatches = allApplicablePatches != null
|
|
|
|
|
? allApplicablePatches.Where(p => p.after_apply_guidance == after_apply_guidance.restartHost).ToList()
|
|
|
|
|
: new List<XenServerPatch>();
|
|
|
|
|
|
2018-07-26 17:01:48 +02:00
|
|
|
|
rebootChecks.Add(new HostNeedsRebootCheck(host, restartHostPatches));
|
|
|
|
|
if (restartHostPatches.Any(p => !p.ContainsLivepatch))
|
|
|
|
|
evacuateChecks.Add(new AssertCanEvacuateCheck(host));
|
|
|
|
|
}
|
2016-10-05 00:26:35 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-03-05 14:43:56 +01:00
|
|
|
|
groups.Add(new CheckGroup(Messages.PATCHINGWIZARD_PRECHECKPAGE_CHECKING_DISK_SPACE, diskChecks));
|
2018-07-26 17:01:48 +02:00
|
|
|
|
if (rebootChecks.Count > 0)
|
|
|
|
|
groups.Add(new CheckGroup(Messages.CHECKING_SERVER_NEEDS_REBOOT, rebootChecks));
|
|
|
|
|
if (evacuateChecks.Count > 0)
|
|
|
|
|
groups.Add(new CheckGroup(Messages.CHECKING_CANEVACUATE_STATUS, evacuateChecks));
|
2016-10-05 00:26:35 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-26 17:01:48 +02:00
|
|
|
|
//GFS2 check for version updates
|
2018-07-09 11:59:09 +02:00
|
|
|
|
if (WizardMode == WizardMode.NewVersion)
|
|
|
|
|
{
|
|
|
|
|
var gfs2Checks = new List<Check>();
|
|
|
|
|
|
|
|
|
|
foreach (Pool pool in SelectedPools.Where(p =>
|
|
|
|
|
Helpers.KolkataOrGreater(p.Connection) && !Helpers.LimaOrGreater(p.Connection)))
|
|
|
|
|
{
|
|
|
|
|
Host host = pool.Connection.Resolve(pool.master);
|
|
|
|
|
gfs2Checks.Add(new PoolHasGFS2SR(host));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (gfs2Checks.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
groups.Add(new CheckGroup(Messages.CHECKING_CLUSTERING_STATUS, gfs2Checks));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-28 12:20:00 +01:00
|
|
|
|
return groups;
|
2016-10-04 15:58:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-05 14:43:56 +01:00
|
|
|
|
protected virtual List<CheckGroup> GenerateChecks(Pool_patch patch)
|
2016-10-04 15:58:54 +02:00
|
|
|
|
{
|
2017-05-04 15:25:36 +02:00
|
|
|
|
List<Host> applicableServers = patch != null ? SelectedServers.Where(h => patch.AppliedOn(h) == DateTime.MaxValue).ToList() : SelectedServers;
|
|
|
|
|
|
2018-02-28 12:20:00 +01:00
|
|
|
|
var groups = GenerateCommonChecks(applicableServers);
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
//Checking other things
|
2015-01-20 15:22:29 +01:00
|
|
|
|
if (patch != null)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2018-02-28 12:20:00 +01:00
|
|
|
|
var serverChecks = new List<Check>();
|
2015-01-20 15:22:29 +01:00
|
|
|
|
foreach (Host host in SelectedServers)
|
|
|
|
|
{
|
|
|
|
|
List<Pool_patch> poolPatches = new List<Pool_patch>(host.Connection.Cache.Pool_patches);
|
2016-02-08 11:14:05 +01:00
|
|
|
|
Pool_patch poolPatchFromHost = poolPatches.Find(otherPatch => string.Equals(otherPatch.uuid, patch.uuid, StringComparison.OrdinalIgnoreCase));
|
2018-02-28 12:20:00 +01:00
|
|
|
|
serverChecks.Add(new PatchPrecheckCheck(host, poolPatchFromHost, LivePatchCodesByHost));
|
2016-08-23 19:16:33 +02:00
|
|
|
|
}
|
2018-03-05 14:43:56 +01:00
|
|
|
|
groups.Add(new CheckGroup(Messages.CHECKING_SERVER_SIDE_STATUS, serverChecks));
|
2016-08-23 19:16:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-19 14:10:24 +02:00
|
|
|
|
//Checking if the host needs a reboot
|
2017-03-27 15:34:20 +02:00
|
|
|
|
if (WizardMode == WizardMode.SingleUpdate)
|
2016-10-19 14:10:24 +02:00
|
|
|
|
{
|
2018-02-28 12:20:00 +01:00
|
|
|
|
var rebootChecks = new List<Check>();
|
2016-10-19 14:10:24 +02:00
|
|
|
|
var guidance = patch != null
|
|
|
|
|
? patch.after_apply_guidance
|
|
|
|
|
: new List<after_apply_guidance> {after_apply_guidance.restartHost};
|
2018-02-28 12:20:00 +01:00
|
|
|
|
|
2017-05-04 15:25:36 +02:00
|
|
|
|
foreach (var host in applicableServers)
|
2018-02-28 12:20:00 +01:00
|
|
|
|
rebootChecks.Add(new HostNeedsRebootCheck(host, guidance, LivePatchCodesByHost));
|
|
|
|
|
|
2018-03-05 14:43:56 +01:00
|
|
|
|
groups.Add(new CheckGroup(Messages.CHECKING_SERVER_NEEDS_REBOOT, rebootChecks));
|
2016-10-19 14:10:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-23 19:16:33 +02:00
|
|
|
|
//Checking can evacuate host
|
|
|
|
|
//CA-97061 - evacuate host -> suspended VMs. This is only needed for restartHost
|
|
|
|
|
//Also include this check for the supplemental packs (patch == null), as their guidance is restartHost
|
2018-07-26 17:01:48 +02:00
|
|
|
|
if (WizardMode == WizardMode.SingleUpdate && (patch == null || patch.after_apply_guidance.Contains(after_apply_guidance.restartHost)))
|
2016-08-23 19:16:33 +02:00
|
|
|
|
{
|
2018-02-28 12:20:00 +01:00
|
|
|
|
var evacuateChecks = new List<Check>();
|
2017-05-04 15:25:36 +02:00
|
|
|
|
foreach (Host host in applicableServers)
|
2018-02-28 12:20:00 +01:00
|
|
|
|
evacuateChecks.Add(new AssertCanEvacuateCheck(host, LivePatchCodesByHost));
|
|
|
|
|
|
2018-03-05 14:43:56 +01:00
|
|
|
|
groups.Add(new CheckGroup(Messages.CHECKING_CANEVACUATE_STATUS, evacuateChecks));
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
2016-08-23 19:16:33 +02:00
|
|
|
|
|
2018-07-02 15:44:29 +02:00
|
|
|
|
//Checking if a reboot is pending on master
|
|
|
|
|
var restartChecks = new List<Check>();
|
|
|
|
|
foreach (var pool in SelectedPools)
|
|
|
|
|
restartChecks.Add(new RestartHostOrToolstackPendingOnMasterCheck(pool, patch == null ? null : patch.uuid));
|
2018-02-28 12:20:00 +01:00
|
|
|
|
|
2018-07-02 15:44:29 +02:00
|
|
|
|
groups.Add(new CheckGroup(Messages.CHECKING_FOR_PENDING_RESTART, restartChecks));
|
2017-10-13 14:52:41 +02:00
|
|
|
|
|
2018-02-28 12:20:00 +01:00
|
|
|
|
return groups;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-05 14:43:56 +01:00
|
|
|
|
protected virtual List<CheckGroup> GenerateChecks(Pool_update update)
|
2016-10-04 15:58:54 +02:00
|
|
|
|
{
|
2017-05-04 15:25:36 +02:00
|
|
|
|
List<Host> applicableServers = update != null ? SelectedServers.Where(h => !update.AppliedOn(h)).ToList() : SelectedServers;
|
2018-02-28 12:20:00 +01:00
|
|
|
|
var groups = GenerateCommonChecks(applicableServers);
|
2016-10-04 15:58:54 +02:00
|
|
|
|
|
2018-01-09 12:29:48 +01:00
|
|
|
|
//Update Homogeneity check for InvernessOrGreater
|
|
|
|
|
if (update != null)
|
|
|
|
|
{
|
|
|
|
|
var homogeneityChecks = new List<Check>();
|
|
|
|
|
foreach (var pool in SelectedPools.Where(pool => Helpers.InvernessOrGreater(pool.Connection)))
|
|
|
|
|
homogeneityChecks.Add(new ServerSelectionCheck(pool, update, SelectedServers));
|
|
|
|
|
|
|
|
|
|
if (homogeneityChecks.Count > 0)
|
2018-03-05 14:43:56 +01:00
|
|
|
|
groups.Add(new CheckGroup(Messages.CHECKING_SERVER_SELECTION, homogeneityChecks));
|
2018-01-09 12:29:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-04 15:58:54 +02:00
|
|
|
|
//Checking other things
|
|
|
|
|
if (update != null)
|
|
|
|
|
{
|
2018-02-28 12:20:00 +01:00
|
|
|
|
var serverChecks = new List<Check>();
|
2016-10-04 15:58:54 +02:00
|
|
|
|
foreach (Host host in SelectedServers)
|
|
|
|
|
{
|
2018-11-29 15:22:46 +01:00
|
|
|
|
var updates = new List<Pool_update>(host.Connection.Cache.Pool_updates);
|
|
|
|
|
var poolUpdateFromHost = updates.Find(p => string.Equals(p.uuid, update.uuid, StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
|
2018-03-14 13:19:14 +01:00
|
|
|
|
SR uploadSr = null;
|
2018-11-29 15:22:46 +01:00
|
|
|
|
if (SrUploadedUpdates != null && poolUpdateFromHost != null &&
|
|
|
|
|
SrUploadedUpdates.ContainsKey(poolUpdateFromHost) && SrUploadedUpdates[poolUpdateFromHost].ContainsKey(host))
|
2018-03-14 13:19:14 +01:00
|
|
|
|
uploadSr = SrUploadedUpdates[poolUpdateFromHost][host];
|
2018-11-29 15:22:46 +01:00
|
|
|
|
|
2018-03-14 13:19:14 +01:00
|
|
|
|
serverChecks.Add(new PatchPrecheckCheck(host, poolUpdateFromHost, LivePatchCodesByHost, uploadSr));
|
2016-10-04 15:58:54 +02:00
|
|
|
|
}
|
2018-03-05 14:43:56 +01:00
|
|
|
|
groups.Add(new CheckGroup(Messages.CHECKING_SERVER_SIDE_STATUS, serverChecks));
|
2016-10-04 15:58:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-19 14:10:24 +02:00
|
|
|
|
//Checking if the host needs a reboot
|
2017-03-24 17:43:19 +01:00
|
|
|
|
if (WizardMode == WizardMode.SingleUpdate)
|
2016-10-19 14:10:24 +02:00
|
|
|
|
{
|
2018-02-28 12:20:00 +01:00
|
|
|
|
var rebootChecks = new List<Check>();
|
2016-10-19 14:10:24 +02:00
|
|
|
|
var guidance = update != null
|
|
|
|
|
? update.after_apply_guidance
|
|
|
|
|
: new List<update_after_apply_guidance> {update_after_apply_guidance.restartHost};
|
2017-05-04 15:25:36 +02:00
|
|
|
|
foreach (var host in applicableServers)
|
2018-02-28 12:20:00 +01:00
|
|
|
|
rebootChecks.Add(new HostNeedsRebootCheck(host, guidance, LivePatchCodesByHost));
|
|
|
|
|
|
2018-03-05 14:43:56 +01:00
|
|
|
|
groups.Add(new CheckGroup(Messages.CHECKING_SERVER_NEEDS_REBOOT, rebootChecks));
|
2016-10-19 14:10:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-04 15:58:54 +02:00
|
|
|
|
//Checking can evacuate host
|
2018-07-26 17:01:48 +02:00
|
|
|
|
if (WizardMode == WizardMode.SingleUpdate && (update == null || update.after_apply_guidance.Contains(update_after_apply_guidance.restartHost)))
|
2016-10-04 15:58:54 +02:00
|
|
|
|
{
|
2018-02-28 12:20:00 +01:00
|
|
|
|
var evacuateChecks = new List<Check>();
|
2017-05-04 15:25:36 +02:00
|
|
|
|
foreach (Host host in applicableServers)
|
2018-02-28 12:20:00 +01:00
|
|
|
|
evacuateChecks.Add(new AssertCanEvacuateCheck(host, LivePatchCodesByHost));
|
|
|
|
|
|
2018-03-05 14:43:56 +01:00
|
|
|
|
groups.Add(new CheckGroup(Messages.CHECKING_CANEVACUATE_STATUS, evacuateChecks));
|
2016-10-04 15:58:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-02 15:44:29 +02:00
|
|
|
|
//Checking if a reboot is pending on master
|
|
|
|
|
var restartChecks = new List<Check>();
|
|
|
|
|
foreach (var pool in SelectedPools)
|
|
|
|
|
restartChecks.Add(new RestartHostOrToolstackPendingOnMasterCheck(pool, update == null ? null : update.uuid));
|
|
|
|
|
groups.Add(new CheckGroup(Messages.CHECKING_FOR_PENDING_RESTART, restartChecks));
|
2017-10-13 14:52:41 +02:00
|
|
|
|
|
2018-02-28 12:20:00 +01:00
|
|
|
|
return groups;
|
2016-10-04 15:58:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
public override void PageCancelled()
|
|
|
|
|
{
|
|
|
|
|
DeregisterEventHandlers();
|
2018-07-03 16:17:57 +02:00
|
|
|
|
_worker.CancelAsync();
|
2016-08-12 14:15:18 +02:00
|
|
|
|
if (resolvePrechecksAction != null && !resolvePrechecksAction.IsCompleted)
|
|
|
|
|
resolvePrechecksAction.Cancel();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-09 00:55:50 +01:00
|
|
|
|
protected override void PageLeaveCore(PageLoadedDirection direction, ref bool cancel)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
DeregisterEventHandlers();
|
2018-07-03 16:17:57 +02:00
|
|
|
|
if (direction == PageLoadedDirection.Back)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
_worker.CancelAsync();
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-19 16:45:16 +02:00
|
|
|
|
public override bool EnablePrevious()
|
|
|
|
|
{
|
|
|
|
|
return !IsCheckInProgress && !IsResolveActionInProgress;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
public override bool EnableNext()
|
|
|
|
|
{
|
2018-02-28 12:56:24 +01:00
|
|
|
|
// CA-65508: if the problem cannot be solved immediately there's no point in
|
|
|
|
|
// enabling the Resolve All button
|
|
|
|
|
// CA-136211: Changed the code below to enable the Resolve All button only
|
|
|
|
|
// when there is at least one problem and all the problems have solution/fix.
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
bool problemsFound = false;
|
2018-02-28 12:56:24 +01:00
|
|
|
|
bool allFixable = true;
|
|
|
|
|
|
|
|
|
|
foreach (PreCheckGridRow row in dataGridView1.Rows)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2018-02-28 12:56:24 +01:00
|
|
|
|
PreCheckHostRow hostRow = row as PreCheckHostRow;
|
|
|
|
|
if (hostRow != null && hostRow.IsProblem)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
problemsFound = true;
|
2018-02-28 12:56:24 +01:00
|
|
|
|
|
|
|
|
|
if (!hostRow.IsFixable)
|
|
|
|
|
{
|
|
|
|
|
allFixable = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-28 12:56:24 +01:00
|
|
|
|
bool actionInProgress = IsResolveActionInProgress;
|
|
|
|
|
bool checkInProgress = IsCheckInProgress;
|
|
|
|
|
|
|
|
|
|
buttonResolveAll.Enabled = !actionInProgress && !checkInProgress && problemsFound && allFixable;
|
|
|
|
|
buttonReCheckProblems.Enabled = !actionInProgress && !checkInProgress;
|
|
|
|
|
checkBoxViewPrecheckFailuresOnly.Enabled = !actionInProgress && !checkInProgress;
|
|
|
|
|
|
|
|
|
|
labelProgress.Visible = actionInProgress || checkInProgress;
|
|
|
|
|
pictureBoxIssues.Visible = labelIssues.Visible = problemsFound && !actionInProgress && !checkInProgress;
|
|
|
|
|
|
2018-03-05 11:15:39 +01:00
|
|
|
|
return !checkInProgress && !actionInProgress && !problemsFound;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Pool_patch Patch { private get; set; }
|
2016-10-13 15:53:46 +02:00
|
|
|
|
public Pool_update PoolUpdate { private get; set; }
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2018-07-02 16:48:33 +02:00
|
|
|
|
public List<Problem> PrecheckProblemsActuallyResolved
|
2018-06-29 20:49:28 +02:00
|
|
|
|
{
|
2018-07-02 16:48:33 +02:00
|
|
|
|
get { return ProblemsResolvedPreCheck.Where(p => p.SolutionActionCompleted).ToList(); }
|
2018-06-29 20:49:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-02-28 12:20:00 +01:00
|
|
|
|
#region Nested classes and enums
|
|
|
|
|
|
2018-06-29 20:49:28 +02:00
|
|
|
|
private enum PreCheckResult { OK, Info, Warning, Failed }
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2016-08-12 14:15:18 +02:00
|
|
|
|
private abstract class PreCheckGridRow : XenAdmin.Controls.DataGridViewEx.DataGridViewExRow
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
protected DataGridViewImageCell _iconCell = new DataGridViewImageCell();
|
|
|
|
|
protected DataGridViewTextBoxCell _descriptionCell = new DataGridViewTextBoxCell();
|
|
|
|
|
protected DataGridViewCell _solutionCell = null;
|
|
|
|
|
protected PreCheckGridRow(DataGridViewCell solutionCell)
|
|
|
|
|
{
|
|
|
|
|
_solutionCell = solutionCell;
|
2018-07-06 02:46:12 +02:00
|
|
|
|
Cells.AddRange(_iconCell, _descriptionCell, _solutionCell);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class PreCheckHeaderRow : PreCheckGridRow
|
|
|
|
|
{
|
|
|
|
|
private string description;
|
|
|
|
|
|
|
|
|
|
public PreCheckHeaderRow(string text)
|
|
|
|
|
: base(new DataGridViewTextBoxCell())
|
|
|
|
|
{
|
|
|
|
|
_iconCell.Value = new Bitmap(1, 1);
|
|
|
|
|
description = text;
|
|
|
|
|
_descriptionCell.Value = text;
|
|
|
|
|
_descriptionCell.Style.Font = new Font(Program.DefaultFont, FontStyle.Bold);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateDescription(PreCheckResult precheckResult)
|
|
|
|
|
{
|
2016-10-20 14:09:48 +02:00
|
|
|
|
string result;
|
|
|
|
|
switch (precheckResult)
|
|
|
|
|
{
|
|
|
|
|
case PreCheckResult.OK:
|
|
|
|
|
result = Messages.GENERAL_STATE_OK;
|
|
|
|
|
break;
|
|
|
|
|
case PreCheckResult.Info:
|
|
|
|
|
result = Messages.INFORMATION;
|
|
|
|
|
break;
|
|
|
|
|
case PreCheckResult.Warning:
|
|
|
|
|
result = Messages.WARNING;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
result = Messages.FAILED;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
_descriptionCell.Value = string.Format("{0} {1}", description, result);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class PreCheckHostRow : PreCheckGridRow
|
|
|
|
|
{
|
|
|
|
|
private Problem _problem = null;
|
|
|
|
|
private Check _check = null;
|
|
|
|
|
public PreCheckHostRow(Problem problem)
|
|
|
|
|
: base(new DataGridViewTextBoxCell())
|
|
|
|
|
{
|
|
|
|
|
_problem = problem;
|
|
|
|
|
_check = problem.Check;
|
|
|
|
|
UpdateRowFields();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public PreCheckHostRow(Check check)
|
|
|
|
|
: base(new DataGridViewTextBoxCell())
|
|
|
|
|
{
|
|
|
|
|
_check = check;
|
|
|
|
|
UpdateRowFields();
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-26 16:16:05 +02:00
|
|
|
|
public bool IsFixable
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Problem != null && Problem.IsFixable && !string.IsNullOrEmpty(this.Solution);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
private void UpdateRowFields()
|
|
|
|
|
{
|
|
|
|
|
_iconCell.Value = Problem == null
|
2016-10-20 14:09:48 +02:00
|
|
|
|
? Images.GetImage16For(Icons.Ok)
|
|
|
|
|
: Problem.Image;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2018-06-29 20:33:57 +02:00
|
|
|
|
string description = null;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
if (Problem != null)
|
|
|
|
|
description = Problem.Description;
|
|
|
|
|
else if (_check != null)
|
2016-10-19 14:10:24 +02:00
|
|
|
|
description = _check.SuccessfulCheckDescription;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2018-06-29 20:33:57 +02:00
|
|
|
|
if (!string.IsNullOrEmpty(description))
|
2013-06-24 13:41:48 +02:00
|
|
|
|
_descriptionCell.Value = String.Format(Messages.PATCHING_WIZARD_DESC_CELL_INDENT, null, description);
|
|
|
|
|
|
|
|
|
|
_solutionCell.Value = Problem == null ? string.Empty : Problem.HelpMessage;
|
|
|
|
|
|
|
|
|
|
if (Problem is WarningWithInformationUrl)
|
|
|
|
|
_solutionCell.Value = (Problem as WarningWithInformationUrl).LinkText;
|
|
|
|
|
|
2014-09-26 16:16:05 +02:00
|
|
|
|
if (Problem is ProblemWithInformationUrl)
|
|
|
|
|
_solutionCell.Value = (Problem as ProblemWithInformationUrl).LinkText;
|
|
|
|
|
|
2016-08-12 14:15:18 +02:00
|
|
|
|
UpdateSolutionCellStyle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateSolutionCellStyle()
|
|
|
|
|
{
|
|
|
|
|
if (_solutionCell == null)
|
|
|
|
|
return;
|
|
|
|
|
if (Enabled)
|
|
|
|
|
{
|
|
|
|
|
_solutionCell.Style.Font = new Font(Program.DefaultFont, FontStyle.Underline);
|
|
|
|
|
_solutionCell.Style.ForeColor = Color.Blue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
_solutionCell.Style = DefaultCellStyle;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Problem Problem
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _problem;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Solution
|
|
|
|
|
{
|
2014-09-26 16:16:05 +02:00
|
|
|
|
get { return (string)_solutionCell.Value; }
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsProblem
|
|
|
|
|
{
|
|
|
|
|
get { return _problem != null && !(_problem is Warning); }
|
|
|
|
|
}
|
2016-10-20 14:09:48 +02:00
|
|
|
|
|
|
|
|
|
public PreCheckResult PrecheckResult
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (Problem == null)
|
|
|
|
|
return PreCheckResult.OK;
|
|
|
|
|
if (_problem is Information)
|
|
|
|
|
return PreCheckResult.Info;
|
|
|
|
|
if (_problem is Warning)
|
|
|
|
|
return PreCheckResult.Warning;
|
|
|
|
|
return PreCheckResult.Failed;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
|
{
|
|
|
|
|
PreCheckHostRow other = obj as PreCheckHostRow;
|
|
|
|
|
if (other != null && other.Problem != null && _problem != null)
|
|
|
|
|
return _problem.CompareTo(other.Problem) == 0;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
{
|
|
|
|
|
return (_problem != null ? _problem.GetHashCode() : 0);
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-12 14:15:18 +02:00
|
|
|
|
public override bool Enabled
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return base.Enabled;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
base.Enabled = value;
|
|
|
|
|
UpdateSolutionCellStyle();
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-02-28 12:20:00 +01:00
|
|
|
|
#endregion
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
PreCheckHostRow preCheckHostRow = dataGridView1.Rows[e.RowIndex] as PreCheckHostRow;
|
2016-08-12 14:15:18 +02:00
|
|
|
|
if (preCheckHostRow != null && preCheckHostRow.Enabled && e.ColumnIndex == 2)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
ExecuteSolution(preCheckHostRow);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void dataGridView1_KeyPress(object sender, KeyPressEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.KeyChar == (char)Keys.Enter && dataGridView1.CurrentCell != null)
|
|
|
|
|
{
|
|
|
|
|
PreCheckHostRow preCheckHostRow = dataGridView1.CurrentCell.OwningRow as PreCheckHostRow;
|
|
|
|
|
int columnIndex = dataGridView1.CurrentCell.ColumnIndex;
|
|
|
|
|
|
2016-08-12 14:15:18 +02:00
|
|
|
|
if (preCheckHostRow != null && preCheckHostRow.Enabled && columnIndex == 2)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
ExecuteSolution(preCheckHostRow);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ExecuteSolution(PreCheckHostRow preCheckHostRow)
|
|
|
|
|
{
|
|
|
|
|
bool cancelled;
|
2018-06-29 15:48:49 +02:00
|
|
|
|
resolvePrechecksAction = preCheckHostRow.Problem.GetSolutionAction(out cancelled);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2016-08-12 14:15:18 +02:00
|
|
|
|
if (resolvePrechecksAction != null)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2016-08-12 14:15:18 +02:00
|
|
|
|
// disable all problems
|
|
|
|
|
foreach (DataGridViewRow row in dataGridView1.Rows)
|
|
|
|
|
{
|
|
|
|
|
PreCheckHostRow preCheckRow = row as PreCheckHostRow;
|
|
|
|
|
if (preCheckRow != null && preCheckRow.Problem != null)
|
|
|
|
|
{
|
|
|
|
|
preCheckRow.Enabled = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
StartResolvePrechecksAction();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-05-21 14:47:51 +02:00
|
|
|
|
if (preCheckHostRow.Problem is WarningWithInformationUrl)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
(preCheckHostRow.Problem as WarningWithInformationUrl).LaunchUrlInBrowser();
|
2014-09-26 16:16:05 +02:00
|
|
|
|
else if (preCheckHostRow.Problem is ProblemWithInformationUrl)
|
|
|
|
|
(preCheckHostRow.Problem as ProblemWithInformationUrl).LaunchUrlInBrowser();
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
else if (!cancelled)
|
2016-06-20 11:49:12 +02:00
|
|
|
|
using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Information,
|
2013-06-24 13:41:48 +02:00
|
|
|
|
string.Format(Messages.PATCHING_WIZARD_SOLVE_MANUALLY, preCheckHostRow.Problem.Description).Replace("\\n", "\n"),
|
2016-06-20 11:49:12 +02:00
|
|
|
|
Messages.PATCHINGWIZARD_PRECHECKPAGE_TEXT)))
|
|
|
|
|
{
|
|
|
|
|
dlg.ShowDialog(this);
|
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonReCheckProblems_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
RefreshRechecks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonResolveAll_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
List<AsyncAction> actions = new List<AsyncAction>();
|
|
|
|
|
foreach (DataGridViewRow row in dataGridView1.Rows)
|
|
|
|
|
{
|
|
|
|
|
PreCheckHostRow preCheckHostRow = row as PreCheckHostRow;
|
|
|
|
|
if (preCheckHostRow != null && preCheckHostRow.Problem != null)
|
|
|
|
|
{
|
|
|
|
|
bool cancelled;
|
2018-06-29 15:48:49 +02:00
|
|
|
|
AsyncAction action = preCheckHostRow.Problem.GetSolutionAction(out cancelled);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
if (action != null)
|
2016-08-12 14:15:18 +02:00
|
|
|
|
{
|
|
|
|
|
preCheckHostRow.Enabled = false;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
actions.Add(action);
|
2016-08-12 14:15:18 +02:00
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-08-12 14:15:18 +02:00
|
|
|
|
resolvePrechecksAction = new ParallelAction(Messages.PATCHINGWIZARD_PRECHECKPAGE_RESOLVING_ALL, Messages.PATCHINGWIZARD_PRECHECKPAGE_RESOLVING_ALL, Messages.COMPLETED, actions, true, false);
|
|
|
|
|
StartResolvePrechecksAction();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void resolvePrecheckAction_Changed(object sender)
|
|
|
|
|
{
|
|
|
|
|
var action = sender as AsyncAction;
|
|
|
|
|
if (action == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Program.Invoke(this, () => UpdateActionProgress(action));
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-12 14:15:18 +02:00
|
|
|
|
private void resolvePrecheckAction_Completed(object sender)
|
|
|
|
|
{
|
|
|
|
|
var action = sender as AsyncAction;
|
|
|
|
|
if (action == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
action.Changed -= resolvePrecheckAction_Changed;
|
|
|
|
|
action.Completed -= resolvePrecheckAction_Completed;
|
|
|
|
|
|
2018-02-28 12:56:24 +01:00
|
|
|
|
Program.Invoke(this, RefreshRechecks);
|
2016-08-12 14:15:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void StartResolvePrechecksAction()
|
|
|
|
|
{
|
|
|
|
|
if (resolvePrechecksAction == null)
|
|
|
|
|
return;
|
|
|
|
|
resolvePrechecksAction.Changed += resolvePrecheckAction_Changed;
|
|
|
|
|
resolvePrechecksAction.Completed += resolvePrecheckAction_Completed;
|
|
|
|
|
resolvePrechecksAction.RunAsync();
|
|
|
|
|
UpdateActionProgress(resolvePrechecksAction);
|
|
|
|
|
OnPageUpdated();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateActionProgress(AsyncAction action)
|
|
|
|
|
{
|
|
|
|
|
progressBar1.Value = action == null ? 0 : action.PercentComplete;
|
|
|
|
|
labelProgress.Text = action == null ? string.Empty : action.Description;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void checkBox1_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2018-07-26 17:11:53 +02:00
|
|
|
|
RefreshDataGridViewList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RefreshDataGridViewList()
|
|
|
|
|
{
|
|
|
|
|
lock (_update_grid_lock)
|
|
|
|
|
{
|
|
|
|
|
dataGridView1.Rows.Clear();
|
|
|
|
|
|
|
|
|
|
foreach (var row in allRows)
|
|
|
|
|
{
|
|
|
|
|
var hostRow = row as PreCheckHostRow;
|
|
|
|
|
if (hostRow != null)
|
|
|
|
|
{
|
|
|
|
|
if (hostRow.Problem != null || !checkBoxViewPrecheckFailuresOnly.Checked)
|
|
|
|
|
{
|
|
|
|
|
AddRowToGridView(hostRow);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
AddRowToGridView(row);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void dataGridView1_CellMouseMove(object sender, DataGridViewCellMouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
PreCheckHostRow preCheckHostRow = dataGridView1.Rows[e.RowIndex] as PreCheckHostRow;
|
2016-08-12 14:15:18 +02:00
|
|
|
|
if (preCheckHostRow != null && preCheckHostRow.Enabled && e.ColumnIndex == 2 && !string.IsNullOrEmpty(preCheckHostRow.Solution))
|
2013-06-24 13:41:48 +02:00
|
|
|
|
Cursor = Cursors.Hand;
|
|
|
|
|
else
|
|
|
|
|
Cursor = Cursors.Arrow;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|