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.
|
|
|
|
*/
|
|
|
|
|
2019-01-10 14:24:42 +01:00
|
|
|
using System;
|
2013-06-24 13:41:48 +02:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Windows.Forms;
|
|
|
|
using XenAdmin.Actions;
|
|
|
|
using XenAdmin.Controls;
|
|
|
|
using XenAdmin.Dialogs;
|
|
|
|
using XenAPI;
|
|
|
|
using System.Linq;
|
2015-07-14 11:05:13 +02:00
|
|
|
using System.IO;
|
2015-07-20 15:28:44 +02:00
|
|
|
using XenAdmin.Alerts;
|
2017-01-20 12:35:25 +01:00
|
|
|
using XenAdmin.Core;
|
2019-01-10 14:24:42 +01:00
|
|
|
using XenAdmin.Wizards.PatchingWizard.PlanActions;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
namespace XenAdmin.Wizards.PatchingWizard
|
|
|
|
{
|
2017-03-24 17:43:19 +01:00
|
|
|
public enum WizardMode { SingleUpdate, AutomatedUpdates, NewVersion }
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
/// <summary>
|
2018-05-29 11:46:14 +02:00
|
|
|
/// Remember that equals for patches don't work across connections because
|
|
|
|
/// we are not allow to override equals. YOU SHOULD NOT USE ANY OPERATION THAT IMPLIES CALL EQUALS OF Pool_patch or Host_patch
|
2013-06-24 13:41:48 +02:00
|
|
|
/// You should do it manually or use delegates.
|
|
|
|
/// </summary>
|
2018-07-02 16:48:33 +02:00
|
|
|
public partial class PatchingWizard : UpdateUpgradeWizard
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
|
|
|
private readonly PatchingWizard_PatchingPage PatchingWizard_PatchingPage;
|
|
|
|
private readonly PatchingWizard_SelectPatchPage PatchingWizard_SelectPatchPage;
|
|
|
|
private readonly PatchingWizard_ModePage PatchingWizard_ModePage;
|
|
|
|
private readonly PatchingWizard_SelectServers PatchingWizard_SelectServers;
|
2015-01-09 13:54:12 +01:00
|
|
|
private readonly PatchingWizard_UploadPage PatchingWizard_UploadPage;
|
2013-06-24 13:41:48 +02:00
|
|
|
private readonly PatchingWizard_PrecheckPage PatchingWizard_PrecheckPage;
|
|
|
|
private readonly PatchingWizard_FirstPage PatchingWizard_FirstPage;
|
2016-12-10 15:44:15 +01:00
|
|
|
private readonly PatchingWizard_AutomatedUpdatesPage PatchingWizard_AutomatedUpdatesPage;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
public PatchingWizard()
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
PatchingWizard_PatchingPage = new PatchingWizard_PatchingPage();
|
|
|
|
PatchingWizard_SelectPatchPage = new PatchingWizard_SelectPatchPage();
|
|
|
|
PatchingWizard_ModePage = new PatchingWizard_ModePage();
|
|
|
|
PatchingWizard_SelectServers = new PatchingWizard_SelectServers();
|
2015-01-09 13:54:12 +01:00
|
|
|
PatchingWizard_UploadPage = new PatchingWizard_UploadPage();
|
2013-06-24 13:41:48 +02:00
|
|
|
PatchingWizard_PrecheckPage = new PatchingWizard_PrecheckPage();
|
|
|
|
PatchingWizard_FirstPage = new PatchingWizard_FirstPage();
|
2016-12-10 15:44:15 +01:00
|
|
|
PatchingWizard_AutomatedUpdatesPage = new PatchingWizard_AutomatedUpdatesPage();
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
AddPage(PatchingWizard_FirstPage);
|
|
|
|
AddPage(PatchingWizard_SelectPatchPage);
|
|
|
|
AddPage(PatchingWizard_SelectServers);
|
2015-01-09 13:54:12 +01:00
|
|
|
AddPage(PatchingWizard_UploadPage);
|
2013-06-24 13:41:48 +02:00
|
|
|
AddPage(PatchingWizard_PrecheckPage);
|
|
|
|
AddPage(PatchingWizard_ModePage);
|
|
|
|
AddPage(PatchingWizard_PatchingPage);
|
|
|
|
}
|
|
|
|
|
2015-07-20 15:28:44 +02:00
|
|
|
public void AddAlert(XenServerPatchAlert alert)
|
|
|
|
{
|
|
|
|
PatchingWizard_SelectPatchPage.SelectDownloadAlert(alert);
|
2019-01-10 14:24:42 +01:00
|
|
|
PatchingWizard_SelectPatchPage.UpdateAlertFromWeb = alert;
|
|
|
|
PatchingWizard_SelectServers.UpdateAlertFromWeb = alert;
|
2017-03-22 11:59:32 +01:00
|
|
|
PatchingWizard_PrecheckPage.UpdateAlert = alert;
|
2015-07-20 15:28:44 +02:00
|
|
|
PatchingWizard_UploadPage.SelectedUpdateAlert = alert;
|
|
|
|
}
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
public void AddFile(string path)
|
|
|
|
{
|
2018-10-04 15:33:17 +02:00
|
|
|
PatchingWizard_SelectPatchPage.FilePath = path;
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SelectServers(List<Host> selectedServers)
|
|
|
|
{
|
|
|
|
PatchingWizard_SelectServers.SelectServers(selectedServers);
|
2014-08-07 13:52:14 +02:00
|
|
|
PatchingWizard_SelectServers.DisableUnselectedServers();
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void UpdateWizardContent(XenTabPage senderPage)
|
|
|
|
{
|
|
|
|
var prevPageType = senderPage.GetType();
|
|
|
|
|
|
|
|
if (prevPageType == typeof(PatchingWizard_SelectPatchPage))
|
|
|
|
{
|
2017-03-24 17:43:19 +01:00
|
|
|
var wizardMode = PatchingWizard_SelectPatchPage.WizardMode;
|
|
|
|
var wizardIsInAutomatedUpdatesMode = wizardMode == WizardMode.AutomatedUpdates;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
2018-10-26 16:22:08 +02:00
|
|
|
var updateType = wizardIsInAutomatedUpdatesMode ? UpdateType.Legacy : PatchingWizard_SelectPatchPage.SelectedUpdateType;
|
2019-01-10 14:24:42 +01:00
|
|
|
var selectedPatchFilePath = wizardIsInAutomatedUpdatesMode ? null : PatchingWizard_SelectPatchPage.SelectedPatchFilePath;
|
|
|
|
var alertFromWeb = wizardIsInAutomatedUpdatesMode ? null : PatchingWizard_SelectPatchPage.UpdateAlertFromWeb;
|
|
|
|
var alertFromFileOnDisk = wizardIsInAutomatedUpdatesMode ? null : PatchingWizard_SelectPatchPage.AlertFromFileOnDisk;
|
2018-07-06 18:31:29 +02:00
|
|
|
var fileFromDiskHasUpdateXml = !wizardIsInAutomatedUpdatesMode && PatchingWizard_SelectPatchPage.FileFromDiskHasUpdateXml;
|
2016-06-17 15:15:59 +02:00
|
|
|
|
2017-03-24 17:43:19 +01:00
|
|
|
PatchingWizard_SelectServers.WizardMode = wizardMode;
|
2013-06-24 13:41:48 +02:00
|
|
|
PatchingWizard_SelectServers.SelectedUpdateType = updateType;
|
2019-01-10 14:24:42 +01:00
|
|
|
PatchingWizard_SelectServers.UpdateAlertFromWeb = alertFromWeb;
|
|
|
|
PatchingWizard_SelectServers.AlertFromFileOnDisk = alertFromFileOnDisk;
|
2018-07-06 18:31:29 +02:00
|
|
|
PatchingWizard_SelectServers.FileFromDiskHasUpdateXml = fileFromDiskHasUpdateXml;
|
2015-01-09 13:54:12 +01:00
|
|
|
|
2016-03-14 17:10:16 +01:00
|
|
|
RemovePage(PatchingWizard_UploadPage);
|
|
|
|
RemovePage(PatchingWizard_ModePage);
|
|
|
|
RemovePage(PatchingWizard_PatchingPage);
|
2016-12-10 15:44:15 +01:00
|
|
|
RemovePage(PatchingWizard_AutomatedUpdatesPage);
|
2017-03-24 17:43:19 +01:00
|
|
|
if (wizardMode == WizardMode.SingleUpdate)
|
2016-03-14 17:10:16 +01:00
|
|
|
{
|
|
|
|
AddAfterPage(PatchingWizard_SelectServers, PatchingWizard_UploadPage);
|
|
|
|
AddAfterPage(PatchingWizard_PrecheckPage, PatchingWizard_ModePage);
|
|
|
|
AddAfterPage(PatchingWizard_ModePage, PatchingWizard_PatchingPage);
|
|
|
|
}
|
2017-03-24 17:43:19 +01:00
|
|
|
else // AutomatedUpdates or NewVersion
|
2016-03-14 17:10:16 +01:00
|
|
|
{
|
2016-12-10 15:44:15 +01:00
|
|
|
AddAfterPage(PatchingWizard_PrecheckPage, PatchingWizard_AutomatedUpdatesPage);
|
2016-03-14 17:10:16 +01:00
|
|
|
}
|
|
|
|
|
2015-01-09 13:54:12 +01:00
|
|
|
PatchingWizard_UploadPage.SelectedUpdateType = updateType;
|
2019-01-10 14:24:42 +01:00
|
|
|
PatchingWizard_UploadPage.SelectedPatchFilePath = selectedPatchFilePath;
|
|
|
|
PatchingWizard_UploadPage.SelectedUpdateAlert = alertFromWeb ?? alertFromFileOnDisk;
|
|
|
|
PatchingWizard_UploadPage.PatchFromDisk = PatchingWizard_SelectPatchPage.PatchFromDisk;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
2017-03-24 17:48:26 +01:00
|
|
|
PatchingWizard_ModePage.SelectedUpdateType = updateType;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
2017-03-24 17:43:19 +01:00
|
|
|
PatchingWizard_PrecheckPage.WizardMode = wizardMode;
|
2017-05-04 16:14:06 +02:00
|
|
|
PatchingWizard_PrecheckPage.PoolUpdate = null; //reset the PoolUpdate property; it will be updated on leaving the Upload page, if this page is visible
|
2019-01-10 14:24:42 +01:00
|
|
|
PatchingWizard_PrecheckPage.UpdateAlert = alertFromWeb ?? alertFromFileOnDisk;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
2017-03-24 17:43:19 +01:00
|
|
|
PatchingWizard_AutomatedUpdatesPage.WizardMode = wizardMode;
|
2019-01-10 14:24:42 +01:00
|
|
|
PatchingWizard_AutomatedUpdatesPage.UpdateAlert = alertFromWeb ?? alertFromFileOnDisk;
|
2018-02-05 13:36:49 +01:00
|
|
|
PatchingWizard_AutomatedUpdatesPage.PatchFromDisk = PatchingWizard_SelectPatchPage.PatchFromDisk;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
PatchingWizard_PatchingPage.SelectedUpdateType = updateType;
|
2019-01-10 14:24:42 +01:00
|
|
|
PatchingWizard_PatchingPage.SelectedPatchFilePatch = selectedPatchFilePath;
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
else if (prevPageType == typeof(PatchingWizard_SelectServers))
|
|
|
|
{
|
|
|
|
var selectedServers = PatchingWizard_SelectServers.SelectedServers;
|
2016-08-09 17:53:02 +02:00
|
|
|
var selectedPools = PatchingWizard_SelectServers.SelectedPools;
|
2017-03-27 17:12:49 +02:00
|
|
|
var applyUpdatesToNewVersion = PatchingWizard_SelectServers.ApplyUpdatesToNewVersion;
|
2016-08-09 17:53:02 +02:00
|
|
|
|
2015-01-09 13:54:12 +01:00
|
|
|
PatchingWizard_PrecheckPage.SelectedServers = selectedServers;
|
2017-03-27 17:12:49 +02:00
|
|
|
PatchingWizard_PrecheckPage.ApplyUpdatesToNewVersion = applyUpdatesToNewVersion;
|
2015-01-09 13:54:12 +01:00
|
|
|
|
2018-08-17 13:05:16 +02:00
|
|
|
PatchingWizard_ModePage.SelectedPools = selectedPools;
|
2015-01-09 13:54:12 +01:00
|
|
|
PatchingWizard_ModePage.SelectedServers = selectedServers;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
2015-01-09 13:54:12 +01:00
|
|
|
PatchingWizard_PatchingPage.SelectedServers = selectedServers;
|
2016-08-09 17:53:02 +02:00
|
|
|
PatchingWizard_PatchingPage.SelectedPools = selectedPools;
|
2015-01-09 13:54:12 +01:00
|
|
|
|
2015-01-20 15:22:29 +01:00
|
|
|
PatchingWizard_UploadPage.SelectedServers = selectedServers;
|
2019-01-10 14:24:42 +01:00
|
|
|
PatchingWizard_UploadPage.SelectedPools = selectedPools;
|
2016-03-24 19:24:12 +01:00
|
|
|
|
2016-12-10 15:44:15 +01:00
|
|
|
PatchingWizard_AutomatedUpdatesPage.SelectedPools = selectedPools;
|
2017-03-27 17:12:49 +02:00
|
|
|
PatchingWizard_AutomatedUpdatesPage.ApplyUpdatesToNewVersion = applyUpdatesToNewVersion;
|
2015-01-09 13:54:12 +01:00
|
|
|
}
|
|
|
|
else if (prevPageType == typeof(PatchingWizard_UploadPage))
|
|
|
|
{
|
2019-01-10 14:24:42 +01:00
|
|
|
var patch = PatchingWizard_UploadPage.Patch;
|
|
|
|
var update = PatchingWizard_UploadPage.PoolUpdate;
|
|
|
|
var suppPackVdis = PatchingWizard_UploadPage.SuppPackVdis;
|
2018-10-29 10:25:56 +01:00
|
|
|
|
2019-01-10 14:24:42 +01:00
|
|
|
PatchingWizard_PrecheckPage.Patch = patch;
|
|
|
|
PatchingWizard_PrecheckPage.PoolUpdate = update;
|
2018-10-29 10:25:56 +01:00
|
|
|
|
2019-01-10 14:24:42 +01:00
|
|
|
var srsWithUploadedUpdates = new Dictionary<Pool_update, Dictionary<Host, SR>>();
|
|
|
|
foreach (var mapping in PatchingWizard_UploadPage.PatchMappings)
|
|
|
|
{
|
|
|
|
if (mapping is PoolUpdateMapping pum)
|
|
|
|
srsWithUploadedUpdates[pum.Pool_update] = pum.SrsWithUploadedUpdatesPerHost;
|
|
|
|
else if (mapping is SuppPackMapping spm && spm.Pool_update != null)
|
|
|
|
srsWithUploadedUpdates[spm.Pool_update] = spm.SrsWithUploadedUpdatesPerHost;
|
|
|
|
}
|
|
|
|
PatchingWizard_PrecheckPage.SrUploadedUpdates = srsWithUploadedUpdates;
|
|
|
|
|
|
|
|
PatchingWizard_ModePage.Patch = patch;
|
|
|
|
PatchingWizard_ModePage.PoolUpdate = update;
|
|
|
|
|
|
|
|
PatchingWizard_PatchingPage.Patch = patch;
|
|
|
|
PatchingWizard_PatchingPage.PoolUpdate = update;
|
|
|
|
PatchingWizard_PatchingPage.SuppPackVdis = suppPackVdis;
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
else if (prevPageType == typeof(PatchingWizard_ModePage))
|
|
|
|
{
|
|
|
|
PatchingWizard_PatchingPage.ManualTextInstructions = PatchingWizard_ModePage.ManualTextInstructions;
|
|
|
|
PatchingWizard_PatchingPage.IsAutomaticMode = PatchingWizard_ModePage.IsAutomaticMode;
|
2015-07-08 18:35:50 +02:00
|
|
|
PatchingWizard_PatchingPage.RemoveUpdateFile = PatchingWizard_ModePage.RemoveUpdateFile;
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
else if (prevPageType == typeof(PatchingWizard_PrecheckPage))
|
|
|
|
{
|
2018-07-02 16:48:33 +02:00
|
|
|
PatchingWizard_PatchingPage.PrecheckProblemsActuallyResolved = PatchingWizard_PrecheckPage.PrecheckProblemsActuallyResolved;
|
2016-08-23 19:16:33 +02:00
|
|
|
PatchingWizard_PatchingPage.LivePatchCodesByHost = PatchingWizard_PrecheckPage.LivePatchCodesByHost;
|
|
|
|
PatchingWizard_ModePage.LivePatchCodesByHost = PatchingWizard_PrecheckPage.LivePatchCodesByHost;
|
2018-07-02 16:48:33 +02:00
|
|
|
PatchingWizard_AutomatedUpdatesPage.PrecheckProblemsActuallyResolved = PatchingWizard_PrecheckPage.PrecheckProblemsActuallyResolved;
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
}
|
2019-01-10 14:24:42 +01:00
|
|
|
|
2018-12-20 13:33:26 +01:00
|
|
|
protected override void OnCancel(ref bool cancel)
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
2018-12-20 13:33:26 +01:00
|
|
|
base.OnCancel(ref cancel);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
2019-01-10 14:24:42 +01:00
|
|
|
RunMultipleActions(Messages.REVERT_WIZARD_CHANGES, Messages.REVERTING_WIZARD_CHANGES,
|
|
|
|
Messages.REVERTED_WIZARD_CHANGES,
|
|
|
|
GetUnwindChangesActions(PatchingWizard_PrecheckPage.PrecheckProblemsActuallyResolved));
|
2013-06-24 13:41:48 +02:00
|
|
|
|
2019-01-10 14:24:42 +01:00
|
|
|
CleanUploadedPatches(true);
|
|
|
|
RemoveDownloadedPatches();
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
2019-01-10 14:24:42 +01:00
|
|
|
|
|
|
|
protected override void FinishWizard()
|
2015-01-26 16:45:55 +01:00
|
|
|
{
|
2019-01-10 14:24:42 +01:00
|
|
|
CleanUploadedPatches();
|
|
|
|
RemoveDownloadedPatches();
|
|
|
|
Updates.CheckServerPatches();
|
|
|
|
base.FinishWizard();
|
2015-01-26 16:45:55 +01:00
|
|
|
}
|
|
|
|
|
2019-01-10 14:24:42 +01:00
|
|
|
private void CleanUploadedPatches(bool forceCleanSelectedPatch = false)
|
2015-01-26 16:45:55 +01:00
|
|
|
{
|
2019-01-10 14:24:42 +01:00
|
|
|
var list = new List<AsyncAction>();
|
2015-01-26 16:45:55 +01:00
|
|
|
|
2019-01-10 14:24:42 +01:00
|
|
|
foreach (var mapping in PatchingWizard_UploadPage.PatchMappings)
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
2019-01-10 14:24:42 +01:00
|
|
|
Pool_patch patch = null;
|
|
|
|
if (mapping is PoolPatchMapping patchMapping)
|
|
|
|
patch = patchMapping.Pool_patch;
|
|
|
|
else if (mapping is OtherLegacyMapping legacyMapping)
|
|
|
|
patch = legacyMapping.Pool_patch;
|
|
|
|
|
|
|
|
if (patch != null)
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
2019-01-10 14:24:42 +01:00
|
|
|
// exclude the selected patch; either the user wants to keep it or it has already been cleared in the patching page
|
|
|
|
if (PatchingWizard_UploadPage.Patch == null ||
|
|
|
|
!string.Equals(patch.uuid, PatchingWizard_UploadPage.Patch.uuid, StringComparison.OrdinalIgnoreCase) ||
|
|
|
|
forceCleanSelectedPatch)
|
|
|
|
list.Add(GetCleanActionForPoolPatch(patch));
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mapping is PoolUpdateMapping updateMapping)
|
|
|
|
{
|
|
|
|
list.Add(GetCleanActionForPoolUpdate(updateMapping.Pool_update));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mapping is SuppPackMapping suppPackMapping)
|
|
|
|
{
|
|
|
|
if (suppPackMapping.Pool_update!= null)
|
|
|
|
list.Add(GetCleanActionForPoolUpdate(suppPackMapping.Pool_update));
|
|
|
|
else
|
|
|
|
list.AddRange(GetRemoveVdiActions(suppPackMapping.SuppPackVdis.Values.ToList()));
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
}
|
2019-01-10 14:24:42 +01:00
|
|
|
|
|
|
|
RunMultipleActions(Messages.PATCHINGWIZARD_REMOVE_UPDATES, Messages.PATCHINGWIZARD_REMOVING_UPDATES, Messages.PATCHINGWIZARD_REMOVED_UPDATES, list);
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2019-01-10 14:24:42 +01:00
|
|
|
private AsyncAction GetCleanActionForPoolPatch(Pool_patch patch)
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
2019-01-10 14:24:42 +01:00
|
|
|
if (patch == null || patch.Connection == null || !patch.Connection.IsConnected)
|
|
|
|
return null;
|
2015-09-04 18:18:26 +02:00
|
|
|
|
2019-01-10 14:24:42 +01:00
|
|
|
if (patch.HostsAppliedTo().Count == 0)
|
|
|
|
return new RemovePatchAction(patch);
|
2018-06-29 20:49:28 +02:00
|
|
|
|
2019-01-10 14:24:42 +01:00
|
|
|
return new DelegatedAsyncAction(patch.Connection, Messages.REMOVE_PATCH, "", "", session => Pool_patch.async_pool_clean(session, patch.opaque_ref));
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2019-01-10 14:24:42 +01:00
|
|
|
private AsyncAction GetCleanActionForPoolUpdate(Pool_update update)
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
2019-01-10 14:24:42 +01:00
|
|
|
if (update == null || update.Connection == null || !update.Connection.IsConnected)
|
|
|
|
return null;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
2019-01-10 14:24:42 +01:00
|
|
|
return new DelegatedAsyncAction(update.Connection, Messages.REMOVE_PATCH, "", "", session =>
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Pool_update.pool_clean(session, update.opaque_ref);
|
|
|
|
if (!update.AppliedOnHosts().Any())
|
|
|
|
Pool_update.destroy(session, update.opaque_ref);
|
|
|
|
}
|
|
|
|
catch (Failure f)
|
|
|
|
{
|
|
|
|
log.Error("Clean up failed", f);
|
|
|
|
}
|
|
|
|
});
|
2015-01-26 16:45:55 +01:00
|
|
|
}
|
|
|
|
|
2019-01-10 14:24:42 +01:00
|
|
|
private List<AsyncAction> GetRemoveVdiActions(List<VDI> vdisToRemove)
|
2016-10-04 15:58:54 +02:00
|
|
|
{
|
2019-01-10 14:24:42 +01:00
|
|
|
var list = new List<AsyncAction>();
|
|
|
|
|
|
|
|
if (vdisToRemove != null)
|
|
|
|
foreach (var vdi in vdisToRemove)
|
|
|
|
{
|
|
|
|
if (vdi.Connection != null && vdi.Connection.IsConnected)
|
|
|
|
list.Add(new DestroyDiskAction(vdi));
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
2016-10-04 15:58:54 +02:00
|
|
|
}
|
|
|
|
|
2015-07-15 17:36:37 +02:00
|
|
|
private void RemoveDownloadedPatches()
|
|
|
|
{
|
2016-06-17 15:15:59 +02:00
|
|
|
List<string> listOfDownloadedFiles = new List<string>();
|
|
|
|
|
2018-02-26 15:02:47 +01:00
|
|
|
listOfDownloadedFiles.AddRange(PatchingWizard_AutomatedUpdatesPage.AllDownloadedPatches.Values); // AutomatedUpdates or NewVersion
|
|
|
|
listOfDownloadedFiles.AddRange(PatchingWizard_UploadPage.AllDownloadedPatches.Values); //SingleUpdate
|
|
|
|
listOfDownloadedFiles.AddRange(PatchingWizard_SelectPatchPage.UnzippedUpdateFiles);
|
2016-06-17 15:15:59 +02:00
|
|
|
|
|
|
|
foreach (string downloadedPatch in listOfDownloadedFiles)
|
2015-07-15 17:36:37 +02:00
|
|
|
{
|
2015-09-04 18:18:26 +02:00
|
|
|
try
|
|
|
|
{
|
|
|
|
if (File.Exists(downloadedPatch))
|
|
|
|
{
|
|
|
|
File.Delete(downloadedPatch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch
|
|
|
|
{
|
|
|
|
log.DebugFormat("Could not remove downloaded patch {0} ", downloadedPatch);
|
|
|
|
}
|
|
|
|
}
|
2015-07-15 17:36:37 +02:00
|
|
|
}
|
|
|
|
|
2019-01-10 14:24:42 +01:00
|
|
|
private void RunMultipleActions(string title, string startDescription, string endDescription,
|
|
|
|
List<AsyncAction> subActions)
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
2019-01-10 14:24:42 +01:00
|
|
|
if (subActions != null && subActions.Count > 0)
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
2019-01-10 14:24:42 +01:00
|
|
|
using (MultipleAction multipleAction = new MultipleAction(xenConnection, title, startDescription,
|
|
|
|
endDescription, subActions, false, true))
|
2018-11-08 11:13:15 +01:00
|
|
|
{
|
2019-01-10 14:24:42 +01:00
|
|
|
using (var dialog = new ActionProgressDialog(multipleAction, ProgressBarStyle.Blocks))
|
|
|
|
dialog.ShowDialog(Program.MainWindow);
|
2018-11-08 11:13:15 +01:00
|
|
|
}
|
2016-10-04 15:58:54 +02:00
|
|
|
}
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
2016-09-23 14:35:02 +02:00
|
|
|
}
|