Fixed issue where supp-packs could be installed only on LCM servers.

Signed-off-by: Konstantina Chremmou <Konstantina.Chremmou@cloud.com>
This commit is contained in:
Konstantina Chremmou 2023-08-10 23:50:44 +01:00
parent 5e860b03f7
commit 81841c2a2b
7 changed files with 58 additions and 44 deletions

View File

@ -44,8 +44,8 @@ using XenAdmin.Alerts;
namespace XenAdmin.Wizards.PatchingWizard
{
public enum WizardMode { SingleUpdate, AutomatedUpdates, NewVersion, UpdatesFromCdn, Unknown }
public enum WizardMode { SingleUpdate, AutomatedUpdates, NewVersion }
/// <summary>
/// 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
@ -64,6 +64,9 @@ namespace XenAdmin.Wizards.PatchingWizard
private readonly PatchingWizard_FirstPage PatchingWizard_FirstPage;
private readonly PatchingWizard_AutomatedUpdatesPage PatchingWizard_AutomatedUpdatesPage;
private bool _isNewGeneration;
private WizardMode _wizardMode;
public PatchingWizard()
{
InitializeComponent();
@ -84,12 +87,12 @@ namespace XenAdmin.Wizards.PatchingWizard
AddPage(PatchingWizard_PatchingPage);
}
public void PrepareToInstallUpdate(bool isUpdatesFromCdn)
public void PrepareToInstallUpdate(bool isNewGeneration)
{
if (!IsFirstPage())
return;
PatchingWizard_FirstPage.IsUpdatesFromCdn = isUpdatesFromCdn;
PatchingWizard_FirstPage.IsNewGeneration = isNewGeneration;
}
public void PrepareToInstallUpdate(XenServerPatchAlert alert, List<Host> hosts)
@ -98,7 +101,7 @@ namespace XenAdmin.Wizards.PatchingWizard
return;
//set the pages before landing on them so they are populated correctly
PatchingWizard_FirstPage.IsUpdatesFromCdn = false;
PatchingWizard_FirstPage.IsNewGeneration = false;
PatchingWizard_SelectPatchPage.UpdateAlertFromWeb = alert;
PatchingWizard_SelectPatchPage.UpdateAlertFromWebSelected += page_UpdateAlertFromWebSelected;
PatchingWizard_SelectServers.SelectedServers = hosts;
@ -122,11 +125,13 @@ namespace XenAdmin.Wizards.PatchingWizard
RemovePage(PatchingWizard_PatchingPage);
RemovePage(PatchingWizard_AutomatedUpdatesPage);
var mode = PatchingWizard_FirstPage.IsUpdatesFromCdn ? WizardMode.UpdatesFromCdn : WizardMode.Unknown;
PatchingWizard_SelectPatchPage.WizardMode = mode;
PatchingWizard_AutomatedUpdatesPage.WizardMode = mode;
_isNewGeneration = PatchingWizard_FirstPage.IsNewGeneration;
if (mode == WizardMode.UpdatesFromCdn)
PatchingWizard_SelectPatchPage.IsNewGeneration = _isNewGeneration;
PatchingWizard_ModePage.IsNewGeneration = _isNewGeneration;
PatchingWizard_AutomatedUpdatesPage.IsNewGeneration = _isNewGeneration;
if (_isNewGeneration)
{
AddAfterPage(PatchingWizard_PrecheckPage, PatchingWizard_ModePage);
AddAfterPage(PatchingWizard_ModePage, PatchingWizard_AutomatedUpdatesPage);
@ -138,8 +143,8 @@ namespace XenAdmin.Wizards.PatchingWizard
}
else if (prevPageType == typeof(PatchingWizard_SelectPatchPage))
{
var wizardMode = PatchingWizard_SelectPatchPage.WizardMode;
var wizardIsInAutomatedUpdatesMode = wizardMode == WizardMode.AutomatedUpdates || wizardMode == WizardMode.UpdatesFromCdn;
_wizardMode = PatchingWizard_SelectPatchPage.WizardMode;
var wizardIsInAutomatedUpdatesMode = _wizardMode == WizardMode.AutomatedUpdates;
var updateType = wizardIsInAutomatedUpdatesMode ? UpdateType.Legacy : PatchingWizard_SelectPatchPage.SelectedUpdateType;
var selectedPatchFilePath = wizardIsInAutomatedUpdatesMode ? null : PatchingWizard_SelectPatchPage.SelectedPatchFilePath;
@ -147,7 +152,8 @@ namespace XenAdmin.Wizards.PatchingWizard
var alertFromFileOnDisk = wizardIsInAutomatedUpdatesMode ? null : PatchingWizard_SelectPatchPage.AlertFromFileOnDisk;
var fileFromDiskHasUpdateXml = !wizardIsInAutomatedUpdatesMode && PatchingWizard_SelectPatchPage.FileFromDiskHasUpdateXml;
PatchingWizard_SelectServers.WizardMode = wizardMode;
PatchingWizard_SelectServers.IsNewGeneration = _isNewGeneration;
PatchingWizard_SelectServers.WizardMode = _wizardMode;
PatchingWizard_SelectServers.SelectedUpdateType = updateType;
PatchingWizard_SelectServers.UpdateAlertFromWeb = alertFromWeb;
PatchingWizard_SelectServers.AlertFromFileOnDisk = alertFromFileOnDisk;
@ -158,13 +164,13 @@ namespace XenAdmin.Wizards.PatchingWizard
RemovePage(PatchingWizard_PatchingPage);
RemovePage(PatchingWizard_AutomatedUpdatesPage);
if (wizardMode == WizardMode.SingleUpdate)
if (_wizardMode == WizardMode.SingleUpdate)
{
AddAfterPage(PatchingWizard_SelectServers, PatchingWizard_UploadPage);
AddAfterPage(PatchingWizard_PrecheckPage, PatchingWizard_ModePage);
AddAfterPage(PatchingWizard_ModePage, PatchingWizard_PatchingPage);
}
else if (wizardMode == WizardMode.UpdatesFromCdn)
else if (_isNewGeneration)
{
AddAfterPage(PatchingWizard_PrecheckPage, PatchingWizard_ModePage);
AddAfterPage(PatchingWizard_ModePage, PatchingWizard_AutomatedUpdatesPage);
@ -180,12 +186,14 @@ namespace XenAdmin.Wizards.PatchingWizard
PatchingWizard_UploadPage.PatchFromDisk = PatchingWizard_SelectPatchPage.PatchFromDisk;
PatchingWizard_ModePage.SelectedUpdateType = updateType;
PatchingWizard_ModePage.WizardMode = _wizardMode;
PatchingWizard_PrecheckPage.WizardMode = wizardMode;
PatchingWizard_PrecheckPage.IsNewGeneration = _isNewGeneration;
PatchingWizard_PrecheckPage.WizardMode = _wizardMode;
PatchingWizard_PrecheckPage.PoolUpdate = null; //reset the PoolUpdate property; it will be updated on leaving the Upload page, if this page is visible
PatchingWizard_PrecheckPage.UpdateAlert = alertFromWeb ?? alertFromFileOnDisk;
PatchingWizard_AutomatedUpdatesPage.WizardMode = wizardMode;
PatchingWizard_AutomatedUpdatesPage.WizardMode = _wizardMode;
PatchingWizard_AutomatedUpdatesPage.UpdateAlert = alertFromWeb ?? alertFromFileOnDisk;
PatchingWizard_AutomatedUpdatesPage.PatchFromDisk = PatchingWizard_SelectPatchPage.PatchFromDisk;
@ -241,7 +249,7 @@ namespace XenAdmin.Wizards.PatchingWizard
}
else if (prevPageType == typeof(PatchingWizard_ModePage))
{
if (PatchingWizard_ModePage.WizardMode == WizardMode.UpdatesFromCdn)
if (_isNewGeneration)
{
PatchingWizard_AutomatedUpdatesPage.PostUpdateTasksAutomatically = PatchingWizard_ModePage.IsAutomaticMode;
PatchingWizard_AutomatedUpdatesPage.ManualTextInstructions = PatchingWizard_ModePage.ManualTextInstructions;
@ -258,7 +266,6 @@ namespace XenAdmin.Wizards.PatchingWizard
PatchingWizard_PatchingPage.PrecheckProblemsActuallyResolved = PatchingWizard_PrecheckPage.PrecheckProblemsActuallyResolved;
PatchingWizard_PatchingPage.LivePatchCodesByHost = PatchingWizard_PrecheckPage.LivePatchCodesByHost;
PatchingWizard_ModePage.LivePatchCodesByHost = PatchingWizard_PrecheckPage.LivePatchCodesByHost;
PatchingWizard_ModePage.WizardMode = PatchingWizard_PrecheckPage.WizardMode;
PatchingWizard_AutomatedUpdatesPage.PrecheckProblemsActuallyResolved = PatchingWizard_PrecheckPage.PrecheckProblemsActuallyResolved;
}
}

View File

@ -43,6 +43,7 @@ namespace XenAdmin.Wizards.PatchingWizard
{
public XenServerPatchAlert UpdateAlert { private get; set; }
public WizardMode WizardMode { private get; set; }
public bool IsNewGeneration { get; set; }
public KeyValuePair<XenServerPatch, string> PatchFromDisk { private get; set; }
public bool PostUpdateTasksAutomatically { private get; set; }
public Dictionary<Pool, StringBuilder> ManualTextInstructions { private get; set; }
@ -54,7 +55,7 @@ namespace XenAdmin.Wizards.PatchingWizard
#region XenTabPage overrides
public override string Text => WizardMode == WizardMode.UpdatesFromCdn
public override string Text => IsNewGeneration
? Messages.PATCHINGWIZARD_AUTOUPDATINGPAGE_TEXT_CDN
: Messages.PATCHINGWIZARD_AUTOUPDATINGPAGE_TEXT;
@ -68,9 +69,9 @@ namespace XenAdmin.Wizards.PatchingWizard
protected override string BlurbText()
{
return string.Format(WizardMode == WizardMode.AutomatedUpdates || WizardMode == WizardMode.UpdatesFromCdn
? Messages.PATCHINGWIZARD_UPLOAD_AND_INSTALL_TITLE_AUTOMATED_MODE
: Messages.PATCHINGWIZARD_UPLOAD_AND_INSTALL_TITLE_NEW_VERSION_AUTOMATED_MODE,
return string.Format(WizardMode == WizardMode.NewVersion
? Messages.PATCHINGWIZARD_UPLOAD_AND_INSTALL_TITLE_NEW_VERSION_AUTOMATED_MODE
: Messages.PATCHINGWIZARD_UPLOAD_AND_INSTALL_TITLE_AUTOMATED_MODE,
BrandManager.BrandConsole);
}
@ -93,7 +94,7 @@ namespace XenAdmin.Wizards.PatchingWizard
{
var sb = new StringBuilder(Messages.PATCHINGWIZARD_AUTOUPDATINGPAGE_SUCCESS_ONE).AppendLine();
if (WizardMode == WizardMode.UpdatesFromCdn && !PostUpdateTasksAutomatically && ManualTextInstructions != null && ManualTextInstructions.ContainsKey(pool))
if (IsNewGeneration && !PostUpdateTasksAutomatically && ManualTextInstructions != null && ManualTextInstructions.ContainsKey(pool))
{
sb.AppendLine(Messages.PATCHINGWIZARD_SINGLEUPDATE_MANUAL_POST_UPDATE);
sb.Append(ManualTextInstructions[pool]).AppendLine();

View File

@ -66,7 +66,7 @@ namespace XenAdmin.Wizards.PatchingWizard
public override string HelpID => "Beforeyoustart";
public bool IsUpdatesFromCdn
public bool IsNewGeneration
{
get => radioButtonCdn.Checked;
set

View File

@ -66,12 +66,12 @@ namespace XenAdmin.Wizards.PatchingWizard
public override string NextText(bool isLastPage)
{
return WizardMode == WizardMode.UpdatesFromCdn ? Messages.UPDATES_WIZARD_APPLY_UPDATES : Messages.UPDATES_WIZARD_APPLY_UPDATE;
return WizardMode == WizardMode.AutomatedUpdates ? Messages.UPDATES_WIZARD_APPLY_UPDATES : Messages.UPDATES_WIZARD_APPLY_UPDATE;
}
protected override void PageLoadedCore(PageLoadedDirection direction)
{
removeUpdateFileCheckBox.Visible = WizardMode != WizardMode.UpdatesFromCdn;
removeUpdateFileCheckBox.Visible = !IsNewGeneration;
var anyPoolForbidsAutostart = SelectedServers.Select(s => Helpers.GetPoolOfOne(s.Connection)).Any(p => p.IsAutoUpdateRestartsForbidden());
@ -79,7 +79,7 @@ namespace XenAdmin.Wizards.PatchingWizard
bool someHostMayRequireRestart;
bool automaticDisabled;
if (WizardMode == WizardMode.UpdatesFromCdn)
if (IsNewGeneration)
{
ManualTextInstructions = ModeCdnUpdates();
automaticDisabled = anyPoolForbidsAutostart;
@ -177,6 +177,7 @@ namespace XenAdmin.Wizards.PatchingWizard
#region Accessors
public WizardMode WizardMode { get; set; }
public bool IsNewGeneration { get; set; }
public Dictionary<Pool, StringBuilder> ManualTextInstructions { get; private set; }

View File

@ -82,6 +82,7 @@ namespace XenAdmin.Wizards.PatchingWizard
public XenServerPatchAlert UpdateAlert { private get; set; }
public WizardMode WizardMode { get; set; }
public bool IsNewGeneration { get; set; }
public bool ApplyUpdatesToNewVersion { protected get; set; }
public Pool_patch Patch { private get; set; }
@ -132,7 +133,7 @@ namespace XenAdmin.Wizards.PatchingWizard
if (direction == PageLoadedDirection.Back)
return;
if (WizardMode == WizardMode.AutomatedUpdates || WizardMode == WizardMode.UpdatesFromCdn)
if (WizardMode == WizardMode.AutomatedUpdates)
{
labelPrechecksFirstLine.Text = Messages.PATCHINGWIZARD_PRECHECKPAGE_FIRSTLINE_AUTOMATED_UPDATES_MODE;
}

View File

@ -43,6 +43,7 @@ using System.Linq;
using System.Xml;
using DiscUtils.Iso9660;
using XenCenterLib;
using XenAdmin.Wizards.CrossPoolMigrateWizard;
namespace XenAdmin.Wizards.PatchingWizard
@ -56,7 +57,7 @@ namespace XenAdmin.Wizards.PatchingWizard
private bool CheckForUpdatesInProgress;
private bool firstLoad = true;
private string unzippedUpdateFilePath;
private WizardMode _wizardMode;
private bool _isNewGeneration;
public PatchingWizard_SelectPatchPage()
{
@ -70,7 +71,7 @@ namespace XenAdmin.Wizards.PatchingWizard
get
{
if (AutomatedUpdatesRadioButton.Visible && AutomatedUpdatesRadioButton.Checked)
return _wizardMode == WizardMode.UpdatesFromCdn ? _wizardMode : WizardMode.AutomatedUpdates;
return WizardMode.AutomatedUpdates;
var updateAlert = downloadUpdateRadioButton.Visible && downloadUpdateRadioButton.Checked
? UpdateAlertFromWeb
@ -83,17 +84,22 @@ namespace XenAdmin.Wizards.PatchingWizard
return WizardMode.SingleUpdate;
}
}
public bool IsNewGeneration
{
get => _isNewGeneration;
set
{
_wizardMode = value;
_isNewGeneration = value;
downloadUpdateRadioButton.Visible = dataGridViewPatches.Visible
= RefreshListButton.Visible = RestoreDismUpdatesButton.Visible = value != WizardMode.UpdatesFromCdn;
= RefreshListButton.Visible = RestoreDismUpdatesButton.Visible = !_isNewGeneration;
tableLayoutPanel1.SuspendLayout();
try
{
if (value == WizardMode.UpdatesFromCdn)
if (_isNewGeneration)
{
tableLayoutPanel1.RowStyles[4].SizeType = SizeType.AutoSize;
tableLayoutPanel1.RowStyles[4].Height = 0;
@ -113,7 +119,7 @@ namespace XenAdmin.Wizards.PatchingWizard
tableLayoutPanel1.ResumeLayout();
}
}
}
}
public XenServerPatchAlert UpdateAlertFromWeb { get; set; }
@ -224,7 +230,7 @@ namespace XenAdmin.Wizards.PatchingWizard
automatedUpdatesOptionLabel.Visible = AutomatedUpdatesRadioButton.Visible = automatedUpdatesPossible;
if (_wizardMode == WizardMode.UpdatesFromCdn)
if (_isNewGeneration)
{
labelBlurb.Text = automatedUpdatesPossible
? Messages.PATCHINGWIZARD_SELECTPATCHPAGE_BLURB_CDN
@ -254,7 +260,7 @@ namespace XenAdmin.Wizards.PatchingWizard
else
downloadUpdateRadioButton.Checked = true;
}
else if (_wizardMode == WizardMode.UpdatesFromCdn && downloadUpdateRadioButton.Checked)
else if (_isNewGeneration && downloadUpdateRadioButton.Checked)
{
if (automatedUpdatesPossible)
AutomatedUpdatesRadioButton.Checked = true;
@ -266,7 +272,7 @@ namespace XenAdmin.Wizards.PatchingWizard
downloadUpdateRadioButton.Checked = true;
}
if (_wizardMode != WizardMode.UpdatesFromCdn)
if (!IsNewGeneration)
{
StartCheckForUpdates(); //call this before starting the _backgroundWorker
_backgroundWorker.RunWorkerAsync();
@ -281,7 +287,7 @@ namespace XenAdmin.Wizards.PatchingWizard
if (direction == PageLoadedDirection.Forward)
{
if ((AutomatedUpdatesRadioButton.Visible && AutomatedUpdatesRadioButton.Checked || downloadUpdateRadioButton.Checked) &&
!Updates.CheckCanDownloadUpdates() && _wizardMode != WizardMode.UpdatesFromCdn)
!Updates.CheckCanDownloadUpdates() && !IsNewGeneration)
{
cancel = true;
using (var errDlg = new ClientIdDialog())
@ -291,7 +297,7 @@ namespace XenAdmin.Wizards.PatchingWizard
if (AutomatedUpdatesRadioButton.Visible && AutomatedUpdatesRadioButton.Checked)
{
if (_wizardMode != WizardMode.UpdatesFromCdn && !Updates.CheckForServerUpdates(userRequested: true, asynchronous: false, this))
if (!_isNewGeneration && !Updates.CheckForServerUpdates(userRequested: true, asynchronous: false, this))
{
cancel = true;
return;

View File

@ -60,6 +60,7 @@ namespace XenAdmin.Wizards.PatchingWizard
public XenServerPatchAlert AlertFromFileOnDisk { private get; set; }
public bool FileFromDiskHasUpdateXml { private get; set; }
public WizardMode WizardMode { private get; set; }
public bool IsNewGeneration { get; set; }
public PatchingWizard_SelectServers()
{
@ -76,13 +77,11 @@ namespace XenAdmin.Wizards.PatchingWizard
protected override void PageLoadedCore(PageLoadedDirection direction)
{
poolSelectionOnly = WizardMode == WizardMode.AutomatedUpdates ||
WizardMode == WizardMode.UpdatesFromCdn ||
UpdateAlertFromWeb != null ||
AlertFromFileOnDisk != null;
switch (WizardMode)
{
case WizardMode.UpdatesFromCdn:
case WizardMode.AutomatedUpdates:
label1.Text = Messages.PATCHINGWIZARD_SELECTSERVERPAGE_RUBRIC_AUTOMATED_MODE;
break;
@ -97,7 +96,7 @@ namespace XenAdmin.Wizards.PatchingWizard
}
var xenConnections = ConnectionsManager.XenConnectionsCopy
.Where(c => WizardMode == WizardMode.UpdatesFromCdn ? Helpers.CloudOrGreater(c) : !Helpers.CloudOrGreater(c)).ToList();
.Where(c => IsNewGeneration ? Helpers.CloudOrGreater(c) : !Helpers.CloudOrGreater(c)).ToList();
xenConnections.Sort();
int licensedPoolCount = 0;
@ -187,7 +186,7 @@ namespace XenAdmin.Wizards.PatchingWizard
return false;
}
return WizardMode == WizardMode.AutomatedUpdates || WizardMode == WizardMode.UpdatesFromCdn
return WizardMode == WizardMode.AutomatedUpdates
? CanEnableRowAutomatedUpdates(host, out tooltipText)
: CanEnableRowNonAutomated(host, out tooltipText);
}
@ -296,7 +295,6 @@ namespace XenAdmin.Wizards.PatchingWizard
//from Ely onwards, iso does not mean supplemental pack
if (WizardMode == WizardMode.AutomatedUpdates ||
WizardMode == WizardMode.UpdatesFromCdn ||
UpdateAlertFromWeb != null ||
AlertFromFileOnDisk != null)
return IsHostAmongApplicable(host, out tooltipText);