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.Windows.Forms;
|
|
|
|
|
using XenAdmin.Controls;
|
|
|
|
|
using XenAdmin.Controls.DataGridViewEx;
|
|
|
|
|
using XenAdmin.Core;
|
|
|
|
|
using XenAPI;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using XenAdmin.Dialogs;
|
|
|
|
|
using System.Drawing;
|
2015-07-14 11:05:13 +02:00
|
|
|
|
using XenAdmin.Alerts;
|
2016-05-04 11:27:10 +02:00
|
|
|
|
using System.Linq;
|
2018-03-14 13:12:18 +01:00
|
|
|
|
using System.Xml;
|
|
|
|
|
using DiscUtils.Iso9660;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace XenAdmin.Wizards.PatchingWizard
|
|
|
|
|
{
|
|
|
|
|
public partial class PatchingWizard_SelectPatchPage : XenTabPage
|
|
|
|
|
{
|
2018-10-04 15:33:17 +02:00
|
|
|
|
private static readonly log4net.ILog log =
|
|
|
|
|
log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
2018-03-14 13:12:18 +01:00
|
|
|
|
|
2015-07-14 11:05:13 +02:00
|
|
|
|
private bool CheckForUpdatesInProgress;
|
2019-01-10 14:24:42 +01:00
|
|
|
|
public XenServerPatchAlert UpdateAlertFromWeb;
|
|
|
|
|
public XenServerPatchAlert AlertFromFileOnDisk;
|
2018-07-06 18:31:29 +02:00
|
|
|
|
public bool FileFromDiskHasUpdateXml { get; private set; }
|
2017-04-20 17:16:09 +02:00
|
|
|
|
private bool firstLoad = true;
|
2017-07-21 16:56:27 +02:00
|
|
|
|
private string unzippedUpdateFilePath;
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
public PatchingWizard_SelectPatchPage()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2016-08-08 12:41:42 +02:00
|
|
|
|
tableLayoutPanelSpinner.Visible = false;
|
2016-08-09 13:45:35 +02:00
|
|
|
|
|
2018-10-04 15:33:17 +02:00
|
|
|
|
labelWithAutomatedUpdates.Visible =
|
|
|
|
|
automatedUpdatesOptionLabel.Visible = AutomatedUpdatesRadioButton.Visible = false;
|
2016-08-09 13:45:35 +02:00
|
|
|
|
downloadUpdateRadioButton.Checked = true;
|
2015-07-14 11:05:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-10 12:25:11 +02:00
|
|
|
|
private void CheckForUpdates_CheckForUpdatesStarted()
|
|
|
|
|
{
|
2016-08-08 12:41:42 +02:00
|
|
|
|
Program.Invoke(Program.MainWindow, StartCheckForUpdates);
|
2015-08-10 12:25:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-08 15:37:47 +02:00
|
|
|
|
private void Updates_RestoreDismissedUpdatesStarted()
|
|
|
|
|
{
|
|
|
|
|
Program.Invoke(Program.MainWindow, StartCheckForUpdates);
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-08 12:41:42 +02:00
|
|
|
|
private void StartCheckForUpdates()
|
|
|
|
|
{
|
|
|
|
|
if (CheckForUpdatesInProgress)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
CheckForUpdatesInProgress = true;
|
|
|
|
|
dataGridViewPatches.Rows.Clear();
|
|
|
|
|
tableLayoutPanelSpinner.Visible = true;
|
|
|
|
|
RestoreDismUpdatesButton.Enabled = false;
|
|
|
|
|
RefreshListButton.Enabled = false;
|
|
|
|
|
OnPageUpdated();
|
|
|
|
|
}
|
2015-08-10 12:25:11 +02:00
|
|
|
|
|
2015-07-14 11:05:13 +02:00
|
|
|
|
private void CheckForUpdates_CheckForUpdatesCompleted(bool succeeded, string errorMessage)
|
|
|
|
|
{
|
|
|
|
|
Program.Invoke(Program.MainWindow, delegate
|
|
|
|
|
{
|
2016-08-08 12:41:42 +02:00
|
|
|
|
tableLayoutPanelSpinner.Visible = false;
|
2016-11-16 13:26:26 +01:00
|
|
|
|
PopulatePatchesBox();
|
2016-03-16 13:59:20 +01:00
|
|
|
|
RefreshListButton.Enabled = true;
|
2016-08-08 12:41:42 +02:00
|
|
|
|
RestoreDismUpdatesButton.Enabled = true;
|
2015-07-14 11:05:13 +02:00
|
|
|
|
CheckForUpdatesInProgress = false;
|
|
|
|
|
OnPageUpdated();
|
|
|
|
|
});
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-07-20 15:28:44 +02:00
|
|
|
|
public void SelectDownloadAlert(XenServerPatchAlert alert)
|
|
|
|
|
{
|
|
|
|
|
downloadUpdateRadioButton.Checked = true;
|
|
|
|
|
foreach (PatchGridViewRow row in dataGridViewPatches.Rows)
|
|
|
|
|
{
|
2018-10-04 15:33:17 +02:00
|
|
|
|
if (row.UpdateAlert.Equals(alert))
|
2015-07-20 15:28:44 +02:00
|
|
|
|
{
|
|
|
|
|
row.Selected = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
public override string Text
|
|
|
|
|
{
|
2018-10-04 15:33:17 +02:00
|
|
|
|
get { return Messages.PATCHINGWIZARD_SELECTPATCHPAGE_TEXT; }
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string PageTitle
|
|
|
|
|
{
|
2018-10-04 15:33:17 +02:00
|
|
|
|
get { return Messages.PATCHINGWIZARD_SELECTPATCHPAGE_TITLE; }
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string HelpID
|
|
|
|
|
{
|
|
|
|
|
get { return "SelectUpdate"; }
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-09 01:31:46 +01:00
|
|
|
|
protected override void PageLoadedCore(PageLoadedDirection direction)
|
|
|
|
|
{
|
2015-08-10 12:25:11 +02:00
|
|
|
|
Updates.CheckForUpdatesStarted += CheckForUpdates_CheckForUpdatesStarted;
|
2015-07-14 11:05:13 +02:00
|
|
|
|
Updates.CheckForUpdatesCompleted += CheckForUpdates_CheckForUpdatesCompleted;
|
2016-08-08 15:37:47 +02:00
|
|
|
|
Updates.RestoreDismissedUpdatesStarted += Updates_RestoreDismissedUpdatesStarted;
|
2018-10-04 15:33:17 +02:00
|
|
|
|
|
2015-07-14 11:05:13 +02:00
|
|
|
|
if (direction == PageLoadedDirection.Forward)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2016-12-10 16:01:25 +01:00
|
|
|
|
//if any connected host is licensed for automated updates
|
2018-10-04 15:33:17 +02:00
|
|
|
|
bool automatedUpdatesPossible =
|
|
|
|
|
ConnectionsManager.XenConnectionsCopy.Any(
|
|
|
|
|
c => c != null && c.Cache.Hosts.Any(h => !Host.RestrictBatchHotfixApply(h)));
|
|
|
|
|
|
|
|
|
|
labelWithAutomatedUpdates.Visible =
|
|
|
|
|
automatedUpdatesOptionLabel.Visible = AutomatedUpdatesRadioButton.Visible = automatedUpdatesPossible;
|
2016-12-10 15:44:15 +01:00
|
|
|
|
labelWithoutAutomatedUpdates.Visible = !automatedUpdatesPossible;
|
2016-08-08 12:41:42 +02:00
|
|
|
|
|
2017-04-20 17:16:09 +02:00
|
|
|
|
if (firstLoad)
|
|
|
|
|
{
|
|
|
|
|
AutomatedUpdatesRadioButton.Checked = automatedUpdatesPossible;
|
|
|
|
|
downloadUpdateRadioButton.Checked = !automatedUpdatesPossible;
|
|
|
|
|
}
|
|
|
|
|
else if (!automatedUpdatesPossible && AutomatedUpdatesRadioButton.Checked)
|
|
|
|
|
{
|
|
|
|
|
downloadUpdateRadioButton.Checked = true;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-20 12:35:25 +01:00
|
|
|
|
Updates.CheckServerPatches();
|
2015-07-14 11:05:13 +02:00
|
|
|
|
PopulatePatchesBox();
|
2016-08-08 12:41:42 +02:00
|
|
|
|
OnPageUpdated();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
2017-04-20 17:16:09 +02:00
|
|
|
|
|
|
|
|
|
firstLoad = false;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-04 15:33:17 +02:00
|
|
|
|
private bool IsInAutomatedUpdatesMode
|
|
|
|
|
{
|
|
|
|
|
get { return AutomatedUpdatesRadioButton.Visible && AutomatedUpdatesRadioButton.Checked; }
|
|
|
|
|
}
|
2017-03-24 17:43:19 +01:00
|
|
|
|
|
|
|
|
|
public WizardMode WizardMode
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (AutomatedUpdatesRadioButton.Visible && AutomatedUpdatesRadioButton.Checked)
|
|
|
|
|
return WizardMode.AutomatedUpdates;
|
2018-03-14 13:12:18 +01:00
|
|
|
|
var updateAlert = downloadUpdateRadioButton.Checked
|
2019-01-10 14:24:42 +01:00
|
|
|
|
? UpdateAlertFromWeb
|
2017-03-24 17:43:19 +01:00
|
|
|
|
: selectFromDiskRadioButton.Checked
|
2019-01-10 14:24:42 +01:00
|
|
|
|
? AlertFromFileOnDisk
|
2017-03-24 17:43:19 +01:00
|
|
|
|
: null;
|
|
|
|
|
if (updateAlert != null && updateAlert.NewServerVersion != null)
|
|
|
|
|
return WizardMode.NewVersion;
|
|
|
|
|
return WizardMode.SingleUpdate;
|
2018-10-04 15:33:17 +02:00
|
|
|
|
}
|
2017-03-24 17:43:19 +01:00
|
|
|
|
}
|
2019-01-10 14:24:42 +01:00
|
|
|
|
public KeyValuePair<XenServerPatch, string> PatchFromDisk { get; private set; }
|
2018-02-05 13:36:49 +01: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
|
|
|
|
{
|
|
|
|
|
if (direction == PageLoadedDirection.Forward)
|
|
|
|
|
{
|
2018-11-07 16:21:10 +01:00
|
|
|
|
if (IsInAutomatedUpdatesMode)
|
2016-03-14 17:10:16 +01:00
|
|
|
|
{
|
2018-11-07 16:21:10 +01:00
|
|
|
|
var succeed = Updates.CheckForUpdatesSync(this.Parent);
|
|
|
|
|
cancel = !succeed;
|
|
|
|
|
}
|
|
|
|
|
else if (downloadUpdateRadioButton.Checked)
|
|
|
|
|
{
|
2019-01-10 14:24:42 +01:00
|
|
|
|
UpdateAlertFromWeb = dataGridViewPatches.SelectedRows.Count > 0
|
2018-10-04 15:33:17 +02:00
|
|
|
|
? ((PatchGridViewRow) dataGridViewPatches.SelectedRows[0]).UpdateAlert
|
|
|
|
|
: null;
|
2016-10-05 00:26:35 +02:00
|
|
|
|
|
2019-01-10 14:24:42 +01:00
|
|
|
|
var distinctHosts = UpdateAlertFromWeb != null ? UpdateAlertFromWeb.DistinctHosts : null;
|
2018-11-07 16:21:10 +01:00
|
|
|
|
SelectedUpdateType = distinctHosts != null && distinctHosts.Any(Helpers.ElyOrGreater)
|
|
|
|
|
? UpdateType.ISO
|
|
|
|
|
: UpdateType.Legacy;
|
2016-10-05 00:26:35 +02:00
|
|
|
|
|
2019-01-10 14:24:42 +01:00
|
|
|
|
AlertFromFileOnDisk = null;
|
2018-11-07 16:21:10 +01:00
|
|
|
|
FileFromDiskHasUpdateXml = false;
|
|
|
|
|
unzippedUpdateFilePath = null;
|
2019-01-10 14:24:42 +01:00
|
|
|
|
SelectedPatchFilePath = null;
|
|
|
|
|
PatchFromDisk = new KeyValuePair<XenServerPatch, string>(null, null);
|
2018-11-07 16:21:10 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-01-10 14:24:42 +01:00
|
|
|
|
UpdateAlertFromWeb = null;
|
|
|
|
|
SelectedPatchFilePath = null;
|
2018-11-07 16:21:10 +01:00
|
|
|
|
|
|
|
|
|
if (!WizardHelpers.IsValidFile(FilePath, out var pathFailure))
|
|
|
|
|
using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(
|
|
|
|
|
SystemIcons.Error, pathFailure, Messages.UPDATES)))
|
2016-03-14 17:10:16 +01:00
|
|
|
|
{
|
2018-11-07 16:21:10 +01:00
|
|
|
|
cancel = true;
|
|
|
|
|
dlg.ShowDialog();
|
|
|
|
|
return;
|
2016-03-14 17:10:16 +01:00
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2019-01-10 14:24:42 +01:00
|
|
|
|
SelectedPatchFilePath = FilePath;
|
2018-10-28 11:36:22 +01:00
|
|
|
|
|
2018-11-07 16:21:10 +01:00
|
|
|
|
if (Path.GetExtension(FilePath).ToLowerInvariant().Equals(".zip"))
|
|
|
|
|
{
|
|
|
|
|
//check if we are installing the update the user sees in the textbox
|
|
|
|
|
if (unzippedUpdateFilePath == null || !File.Exists(unzippedUpdateFilePath) ||
|
|
|
|
|
Path.GetFileNameWithoutExtension(unzippedUpdateFilePath) != Path.GetFileNameWithoutExtension(FilePath))
|
2018-10-28 11:36:22 +01:00
|
|
|
|
{
|
2018-11-07 16:21:10 +01:00
|
|
|
|
unzippedUpdateFilePath = WizardHelpers.ExtractUpdate(FilePath, this);
|
2018-10-28 11:36:22 +01:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-07 16:21:10 +01:00
|
|
|
|
if (!WizardHelpers.IsValidFile(unzippedUpdateFilePath, out var zipFailure))
|
2018-10-28 11:36:22 +01:00
|
|
|
|
{
|
2018-11-07 16:21:10 +01:00
|
|
|
|
using (var dlg = new ThreeButtonDialog(new ThreeButtonDialog.Details(
|
|
|
|
|
SystemIcons.Error, zipFailure, Messages.UPDATES)))
|
|
|
|
|
{
|
|
|
|
|
cancel = true;
|
|
|
|
|
dlg.ShowDialog();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2018-10-28 11:36:22 +01:00
|
|
|
|
}
|
2018-11-07 16:21:10 +01:00
|
|
|
|
|
|
|
|
|
if (!unzippedFiles.Contains(unzippedUpdateFilePath))
|
|
|
|
|
unzippedFiles.Add(unzippedUpdateFilePath);
|
|
|
|
|
|
2019-01-10 14:24:42 +01:00
|
|
|
|
SelectedPatchFilePath = unzippedUpdateFilePath;
|
2016-03-14 17:10:16 +01:00
|
|
|
|
}
|
2018-11-07 16:21:10 +01:00
|
|
|
|
else
|
|
|
|
|
unzippedUpdateFilePath = null;
|
2016-05-31 20:00:35 +02:00
|
|
|
|
|
2019-01-10 14:24:42 +01:00
|
|
|
|
if (SelectedPatchFilePath.EndsWith("." + Branding.Update))
|
2018-11-07 16:21:10 +01:00
|
|
|
|
SelectedUpdateType = UpdateType.Legacy;
|
2019-01-10 14:24:42 +01:00
|
|
|
|
else if (SelectedPatchFilePath.EndsWith("." + Branding.UpdateIso))
|
2018-11-07 16:21:10 +01:00
|
|
|
|
SelectedUpdateType = UpdateType.ISO;
|
|
|
|
|
|
2019-01-10 14:24:42 +01:00
|
|
|
|
AlertFromFileOnDisk = GetAlertFromFile(SelectedPatchFilePath, out var hasUpdateXml);
|
2018-11-07 16:21:10 +01:00
|
|
|
|
FileFromDiskHasUpdateXml = hasUpdateXml;
|
2019-01-10 14:24:42 +01:00
|
|
|
|
PatchFromDisk = AlertFromFileOnDisk == null
|
|
|
|
|
? new KeyValuePair<XenServerPatch, string>(null, null)
|
|
|
|
|
: new KeyValuePair<XenServerPatch, string>(AlertFromFileOnDisk.Patch, SelectedPatchFilePath);
|
2016-05-31 20:00:35 +02:00
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
2016-03-16 13:59:20 +01:00
|
|
|
|
|
2016-05-31 20:00:35 +02:00
|
|
|
|
if (!cancel) //unsubscribe only if we are really leaving this page
|
|
|
|
|
{
|
2016-08-08 15:37:47 +02:00
|
|
|
|
Updates.RestoreDismissedUpdatesStarted -= Updates_RestoreDismissedUpdatesStarted;
|
2016-08-08 12:41:42 +02:00
|
|
|
|
Updates.CheckForUpdatesStarted -= CheckForUpdates_CheckForUpdatesStarted;
|
2016-05-31 20:00:35 +02:00
|
|
|
|
Updates.CheckForUpdatesCompleted -= CheckForUpdates_CheckForUpdatesCompleted;
|
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-06 18:31:29 +02:00
|
|
|
|
private XenServerPatchAlert GetAlertFromFile(string fileName, out bool hasUpdateXml)
|
2015-07-20 16:27:41 +02:00
|
|
|
|
{
|
2018-07-06 18:31:29 +02:00
|
|
|
|
var alertFromIso = GetAlertFromIsoFile(fileName, out hasUpdateXml);
|
2018-03-14 13:12:18 +01:00
|
|
|
|
if (alertFromIso != null)
|
|
|
|
|
return alertFromIso;
|
|
|
|
|
|
|
|
|
|
// couldn't find an alert from the information in the iso file, try matching by name
|
|
|
|
|
return Updates.FindPatchAlertByName(Path.GetFileNameWithoutExtension(fileName));
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-06 18:31:29 +02:00
|
|
|
|
private XenServerPatchAlert GetAlertFromIsoFile(string fileName, out bool hasUpdateXml)
|
2018-03-14 13:12:18 +01:00
|
|
|
|
{
|
2018-07-06 18:31:29 +02:00
|
|
|
|
hasUpdateXml = false;
|
|
|
|
|
|
2018-03-14 13:12:18 +01:00
|
|
|
|
if (!fileName.EndsWith(Branding.UpdateIso))
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
var xmlDoc = new XmlDocument();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2019-04-24 17:04:41 +02:00
|
|
|
|
using (var isoStream = File.OpenRead(fileName))
|
2018-03-14 13:12:18 +01:00
|
|
|
|
{
|
|
|
|
|
var cd = new CDReader(isoStream, true);
|
|
|
|
|
if (cd.Exists("Update.xml"))
|
|
|
|
|
{
|
|
|
|
|
using (var fileStream = cd.OpenFile("Update.xml", FileMode.Open))
|
|
|
|
|
{
|
|
|
|
|
xmlDoc.Load(fileStream);
|
2018-07-06 18:31:29 +02:00
|
|
|
|
hasUpdateXml = true;
|
2018-03-14 13:12:18 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exception)
|
2015-07-20 16:27:41 +02:00
|
|
|
|
{
|
2018-03-14 13:12:18 +01:00
|
|
|
|
log.ErrorFormat("Exception while reading the update data from the iso file: {0}", exception.Message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var elements = xmlDoc.GetElementsByTagName("update");
|
|
|
|
|
var update = elements.Count > 0 ? elements[0] : null;
|
|
|
|
|
|
|
|
|
|
if (update == null || update.Attributes == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2018-03-16 15:00:07 +01:00
|
|
|
|
var uuid = update.Attributes["uuid"];
|
|
|
|
|
return uuid != null ? Updates.FindPatchAlertByUuid(uuid.Value) : null;
|
2015-07-20 16:27:41 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
private void PopulatePatchesBox()
|
|
|
|
|
{
|
2019-01-10 14:24:42 +01:00
|
|
|
|
try
|
2017-03-24 12:37:43 +01:00
|
|
|
|
{
|
2019-01-10 14:24:42 +01:00
|
|
|
|
var updates = Updates.UpdateAlerts.ToList();
|
2017-03-23 14:58:24 +01:00
|
|
|
|
|
2019-01-10 14:24:42 +01:00
|
|
|
|
if (dataGridViewPatches.SortedColumn != null)
|
|
|
|
|
{
|
|
|
|
|
if (dataGridViewPatches.SortedColumn.Index == ColumnUpdate.Index)
|
|
|
|
|
updates.Sort(Alert.CompareOnTitle);
|
|
|
|
|
else if (dataGridViewPatches.SortedColumn.Index == ColumnDate.Index)
|
|
|
|
|
updates.Sort(Alert.CompareOnDate);
|
|
|
|
|
else if (dataGridViewPatches.SortedColumn.Index == ColumnDescription.Index)
|
|
|
|
|
updates.Sort(Alert.CompareOnDescription);
|
|
|
|
|
|
|
|
|
|
if (dataGridViewPatches.SortOrder == SortOrder.Descending)
|
|
|
|
|
updates.Reverse();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
updates.Sort(new NewVersionPriorityAlertComparer());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dataGridViewPatches.SuspendLayout();
|
|
|
|
|
dataGridViewPatches.Rows.Clear();
|
2017-03-23 14:58:24 +01:00
|
|
|
|
|
2019-01-10 14:24:42 +01:00
|
|
|
|
foreach (Alert alert in updates)
|
2017-03-23 14:58:24 +01:00
|
|
|
|
{
|
2019-01-10 14:24:42 +01:00
|
|
|
|
if (!(alert is XenServerPatchAlert patchAlert))
|
|
|
|
|
continue;
|
|
|
|
|
|
2017-03-23 14:58:24 +01:00
|
|
|
|
PatchGridViewRow row = new PatchGridViewRow(patchAlert);
|
|
|
|
|
if (!dataGridViewPatches.Rows.Contains(row))
|
|
|
|
|
{
|
|
|
|
|
dataGridViewPatches.Rows.Add(row);
|
|
|
|
|
|
|
|
|
|
if (patchAlert.RequiredXenCenterVersion != null)
|
|
|
|
|
{
|
|
|
|
|
row.Enabled = false;
|
2018-10-04 15:33:17 +02:00
|
|
|
|
row.SetToolTip(string.Format(Messages.UPDATES_WIZARD_NEWER_XENCENTER_REQUIRED,
|
|
|
|
|
patchAlert.RequiredXenCenterVersion.Version));
|
2017-03-23 14:58:24 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
2019-01-10 14:24:42 +01:00
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
dataGridViewPatches.ResumeLayout();
|
|
|
|
|
}
|
2015-07-14 11:05:13 +02:00
|
|
|
|
}
|
2018-10-04 15:33:17 +02:00
|
|
|
|
|
2018-12-20 13:33:26 +01:00
|
|
|
|
public override void PageCancelled(ref bool cancel)
|
2015-07-14 11:05:13 +02:00
|
|
|
|
{
|
2016-08-08 15:37:47 +02:00
|
|
|
|
Updates.RestoreDismissedUpdatesStarted -= Updates_RestoreDismissedUpdatesStarted;
|
2016-08-08 12:41:42 +02:00
|
|
|
|
Updates.CheckForUpdatesStarted -= CheckForUpdates_CheckForUpdatesStarted;
|
2015-07-14 11:05:13 +02:00
|
|
|
|
Updates.CheckForUpdatesCompleted -= CheckForUpdates_CheckForUpdatesCompleted;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool EnableNext()
|
|
|
|
|
{
|
2015-07-14 11:05:13 +02:00
|
|
|
|
if (CheckForUpdatesInProgress)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2016-03-14 17:10:16 +01:00
|
|
|
|
|
2016-12-10 15:44:15 +01:00
|
|
|
|
if (IsInAutomatedUpdatesMode)
|
2016-03-14 17:10:16 +01:00
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-09 17:32:08 +02:00
|
|
|
|
if (downloadUpdateRadioButton.Checked)
|
2018-10-04 15:33:17 +02:00
|
|
|
|
{
|
2015-07-09 17:32:08 +02:00
|
|
|
|
if (dataGridViewPatches.SelectedRows.Count == 1)
|
|
|
|
|
{
|
2018-10-04 15:33:17 +02:00
|
|
|
|
DataGridViewExRow row = (DataGridViewExRow) dataGridViewPatches.SelectedRows[0];
|
2015-07-09 17:32:08 +02:00
|
|
|
|
if (row.Enabled)
|
2015-07-20 15:28:44 +02:00
|
|
|
|
{
|
2015-07-09 17:32:08 +02:00
|
|
|
|
return true;
|
2015-07-20 15:28:44 +02:00
|
|
|
|
}
|
2015-07-09 17:32:08 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (selectFromDiskRadioButton.Checked)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2018-11-07 16:21:10 +01:00
|
|
|
|
if (WizardHelpers.IsValidFile(FilePath, out _))
|
2013-06-24 13:41:48 +02:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2017-07-21 16:56:27 +02:00
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-08 12:41:42 +02:00
|
|
|
|
public override bool EnablePrevious()
|
|
|
|
|
{
|
|
|
|
|
return !CheckForUpdatesInProgress;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-28 11:36:22 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// List to store unzipped files to be removed later by PatchingWizard
|
|
|
|
|
/// </summary>
|
2018-11-07 16:21:10 +01:00
|
|
|
|
private readonly List<string> unzippedFiles = new List<string>();
|
2017-07-21 16:56:27 +02:00
|
|
|
|
|
|
|
|
|
public List<string> UnzippedUpdateFiles
|
|
|
|
|
{
|
|
|
|
|
get { return unzippedFiles; }
|
2015-07-09 17:32:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-04 15:33:17 +02:00
|
|
|
|
public string FilePath
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2018-10-04 15:33:17 +02:00
|
|
|
|
get { return fileNameTextBox.Text; }
|
|
|
|
|
set { fileNameTextBox.Text = value; }
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public UpdateType SelectedUpdateType { get; set; }
|
|
|
|
|
|
2019-01-10 14:24:42 +01:00
|
|
|
|
public string SelectedPatchFilePath { get; set; }
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2016-08-08 12:41:42 +02:00
|
|
|
|
#region DataGridView
|
2015-07-14 11:05:13 +02:00
|
|
|
|
|
2016-08-08 12:41:42 +02:00
|
|
|
|
private void dataGridViewPatches_SelectionChanged(object sender, EventArgs e)
|
2015-07-14 11:05:13 +02:00
|
|
|
|
{
|
2016-08-08 12:41:42 +02:00
|
|
|
|
OnPageUpdated();
|
2015-07-14 11:05:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void dataGridViewPatches_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
|
|
|
|
|
{
|
2018-10-04 15:33:17 +02:00
|
|
|
|
Alert alert1 = ((PatchGridViewRow) dataGridViewPatches.Rows[e.RowIndex1]).UpdateAlert;
|
|
|
|
|
Alert alert2 = ((PatchGridViewRow) dataGridViewPatches.Rows[e.RowIndex2]).UpdateAlert;
|
2015-07-14 11:05:13 +02:00
|
|
|
|
|
|
|
|
|
if (e.Column.Index == ColumnDate.Index)
|
|
|
|
|
{
|
2018-08-03 12:32:51 +02:00
|
|
|
|
e.SortResult = DateTime.Compare(alert1.Timestamp, alert2.Timestamp);
|
2015-07-14 11:05:13 +02:00
|
|
|
|
e.Handled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void dataGridViewPatches_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
2016-08-08 12:41:42 +02:00
|
|
|
|
{
|
|
|
|
|
// The click is on a column header
|
2015-07-14 11:05:13 +02:00
|
|
|
|
if (e.RowIndex == -1)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
PatchGridViewRow row = dataGridViewPatches.Rows[e.RowIndex] as PatchGridViewRow;
|
|
|
|
|
if (row != null && e.ColumnIndex == 3)
|
|
|
|
|
{
|
|
|
|
|
row.UpdateAlert.FixLinkAction();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void dataGridViewPatches_Enter(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
downloadUpdateRadioButton.Checked = true;
|
2016-08-08 12:41:42 +02:00
|
|
|
|
OnPageUpdated();
|
2015-07-14 11:05:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
private class PatchGridViewRow : DataGridViewExRow, IEquatable<PatchGridViewRow>
|
|
|
|
|
{
|
2017-08-30 10:31:05 +02:00
|
|
|
|
private readonly XenServerPatchAlert _alert;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2018-10-28 11:36:22 +01:00
|
|
|
|
private DataGridViewTextBoxCell _nameCell = new DataGridViewTextBoxCell();
|
|
|
|
|
private DataGridViewTextBoxCell _descriptionCell = new DataGridViewTextBoxCell();
|
|
|
|
|
private DataGridViewTextBoxCell _dateCell = new DataGridViewTextBoxCell();
|
|
|
|
|
private DataGridViewLinkCell _webPageCell = new DataGridViewLinkCell();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2017-08-30 10:31:05 +02:00
|
|
|
|
public PatchGridViewRow(XenServerPatchAlert alert)
|
2018-10-04 15:33:17 +02:00
|
|
|
|
{
|
2015-07-14 11:05:13 +02:00
|
|
|
|
_alert = alert;
|
2018-10-28 11:36:22 +01:00
|
|
|
|
Cells.AddRange(_nameCell, _descriptionCell, _dateCell, _webPageCell);
|
2015-07-14 11:05:13 +02:00
|
|
|
|
|
|
|
|
|
_nameCell.Value = String.Format(alert.Name);
|
|
|
|
|
_descriptionCell.Value = String.Format(alert.Description);
|
2018-10-04 15:33:17 +02:00
|
|
|
|
_dateCell.Value = HelpersGUI.DateTimeToString(alert.Timestamp.ToLocalTime(), Messages.DATEFORMAT_DMY,
|
|
|
|
|
true);
|
2015-07-14 11:05:13 +02:00
|
|
|
|
_webPageCell.Value = Messages.PATCHING_WIZARD_WEBPAGE_CELL;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-08-30 10:31:05 +02:00
|
|
|
|
public XenServerPatchAlert UpdateAlert
|
2018-10-04 15:33:17 +02:00
|
|
|
|
{
|
2015-07-14 11:05:13 +02:00
|
|
|
|
get { return _alert; }
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Equals(PatchGridViewRow other)
|
|
|
|
|
{
|
2018-10-28 11:36:22 +01:00
|
|
|
|
if (other != null && other.UpdateAlert != null && UpdateAlert != null && UpdateAlert.uuid == other.UpdateAlert.uuid)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
{
|
|
|
|
|
return base.GetHashCode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
|
{
|
|
|
|
|
if (obj is PatchGridViewRow)
|
2018-10-04 15:33:17 +02:00
|
|
|
|
return this.Equals((PatchGridViewRow) obj);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2017-03-23 14:58:24 +01:00
|
|
|
|
|
|
|
|
|
public void SetToolTip(string toolTip)
|
|
|
|
|
{
|
|
|
|
|
foreach (var c in Cells)
|
|
|
|
|
{
|
|
|
|
|
if (c is DataGridViewLinkCell)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
var cell = c as DataGridViewCell;
|
|
|
|
|
if (c != null)
|
2018-10-04 15:33:17 +02:00
|
|
|
|
((DataGridViewCell) c).ToolTipText = toolTip;
|
2017-03-23 14:58:24 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-23 15:04:43 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-08 12:41:42 +02:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Buttons
|
|
|
|
|
|
2015-07-23 15:04:43 +02:00
|
|
|
|
private void RestoreDismUpdatesButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2018-10-04 15:33:17 +02:00
|
|
|
|
dataGridViewPatches.Focus();
|
2015-07-23 15:04:43 +02:00
|
|
|
|
Updates.RestoreDismissedUpdates();
|
2016-03-14 17:10:16 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-08 12:41:42 +02:00
|
|
|
|
private void RefreshListButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2018-10-04 15:33:17 +02:00
|
|
|
|
dataGridViewPatches.Focus();
|
2016-08-08 12:41:42 +02:00
|
|
|
|
Updates.CheckForUpdates(true);
|
|
|
|
|
}
|
2018-10-04 15:33:17 +02:00
|
|
|
|
|
|
|
|
|
private void BrowseButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
selectFromDiskRadioButton.Checked = true;
|
|
|
|
|
var suppPack = WizardHelpers.GetSuppPackFromDisk(this);
|
|
|
|
|
if (!string.IsNullOrEmpty(suppPack))
|
|
|
|
|
FilePath = suppPack;
|
|
|
|
|
OnPageUpdated();
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-08 12:41:42 +02:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region TextBox
|
|
|
|
|
|
|
|
|
|
private void fileNameTextBox_Enter(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
selectFromDiskRadioButton.Checked = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fileNameTextBox_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
selectFromDiskRadioButton.Checked = true;
|
|
|
|
|
OnPageUpdated();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region RadioButtons
|
|
|
|
|
|
2016-03-14 17:10:16 +01:00
|
|
|
|
private void AutomaticRadioButton_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-08-08 12:41:42 +02:00
|
|
|
|
OnPageUpdated();
|
2016-03-14 17:10:16 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void downloadUpdateRadioButton_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-08-08 12:41:42 +02:00
|
|
|
|
dataGridViewPatches.HideSelection = !downloadUpdateRadioButton.Checked;
|
|
|
|
|
if (downloadUpdateRadioButton.Checked)
|
|
|
|
|
dataGridViewPatches.Focus();
|
|
|
|
|
OnPageUpdated();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void selectFromDiskRadioButton_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
OnPageUpdated();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AutomaticRadioButton_TabStopChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-12-10 15:44:15 +01:00
|
|
|
|
if (!AutomatedUpdatesRadioButton.TabStop)
|
|
|
|
|
AutomatedUpdatesRadioButton.TabStop = true;
|
2016-08-08 12:41:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void downloadUpdateRadioButton_TabStopChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!downloadUpdateRadioButton.TabStop)
|
|
|
|
|
downloadUpdateRadioButton.TabStop = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void selectFromDiskRadioButton_TabStopChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!selectFromDiskRadioButton.TabStop)
|
|
|
|
|
selectFromDiskRadioButton.TabStop = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
2015-07-14 11:05:13 +02:00
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
2018-11-07 16:21:10 +01:00
|
|
|
|
public enum UpdateType { Legacy, ISO }
|
2016-08-08 12:41:42 +02:00
|
|
|
|
}
|