From f2c967968d649236ca4bbdd7c41bd0e3f59db967 Mon Sep 17 00:00:00 2001 From: Danilo Del Busso Date: Mon, 24 Apr 2023 09:20:53 +0100 Subject: [PATCH 1/8] CA-375803: Catch exceptions when creating a new template from snapshot Both when user cancels and when action fails Signed-off-by: Danilo Del Busso --- .../NewTemplateFromSnapshotCommand.cs | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/XenAdmin/Commands/NewTemplateFromSnapshotCommand.cs b/XenAdmin/Commands/NewTemplateFromSnapshotCommand.cs index 52d2fe8a6..78b574777 100644 --- a/XenAdmin/Commands/NewTemplateFromSnapshotCommand.cs +++ b/XenAdmin/Commands/NewTemplateFromSnapshotCommand.cs @@ -30,6 +30,7 @@ using System; using System.Collections.Generic; +using System.Reflection; using System.Windows.Forms; using XenAPI; using XenAdmin.Actions; @@ -45,6 +46,8 @@ namespace XenAdmin.Commands /// internal class NewTemplateFromSnapshotCommand : Command { + private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod()?.DeclaringType); + /// /// Initializes a new instance of this Command. The parameter-less constructor is required in the derived /// class if it is to be attached to a ToolStrip menu item or button. It should not be used in any other scenario. @@ -92,11 +95,22 @@ namespace XenAdmin.Commands void action_Completed(ActionBase sender) { - AsyncAction action = (AsyncAction)sender; - var vm = action.Connection.Resolve(new XenRef(action.Result)); + var action = (AsyncAction)sender; + VM vm = null; + try + { + vm = action.Connection.Resolve(new XenRef(action.Result)); + } + catch (CancelledException) + { + Log.Info("User cancelled RBAC check when creating new template from snapshot."); + } + catch (Exception ex) + { + Log.Error(ex); + } if (vm != null) new SetVMOtherConfigAction(vm.Connection, vm, "instant", "true").RunAsync(); - } protected override bool CanRunCore(SelectedItemCollection selection) From 99ea8bcf687056035f63dcd899fa6517ba1fae92 Mon Sep 17 00:00:00 2001 From: Danilo Del Busso Date: Mon, 24 Apr 2023 11:06:07 +0100 Subject: [PATCH 2/8] Tidy up `NewTemplateFromSnapshotCommand` Signed-off-by: Danilo Del Busso --- .../NewTemplateFromSnapshotCommand.cs | 22 +++++++------------ XenModel/Messages.Designer.cs | 9 ++++++++ XenModel/Messages.resx | 3 +++ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/XenAdmin/Commands/NewTemplateFromSnapshotCommand.cs b/XenAdmin/Commands/NewTemplateFromSnapshotCommand.cs index 78b574777..106c2be07 100644 --- a/XenAdmin/Commands/NewTemplateFromSnapshotCommand.cs +++ b/XenAdmin/Commands/NewTemplateFromSnapshotCommand.cs @@ -68,15 +68,16 @@ namespace XenAdmin.Commands protected override void RunCore(SelectedItemCollection selection) { - VM snapshot = (VM)selection[0].XenObject; + var snapshot = (VM)selection[0].XenObject; // Generate list of all taken VM/snapshot/template names - List takenNames = new List(snapshot.Connection.Cache.VMs).ConvertAll(v => v.Name()); + var takenNames = new List(snapshot.Connection.Cache.VMs).ConvertAll(v => v.Name()); // Generate a unique suggested name for the new template - string defaultName = Helpers.MakeUniqueName(String.Format(Messages.TEMPLATE_FROM_SNAPSHOT_DEFAULT_NAME, snapshot.Name()), takenNames); + var defaultName = Helpers.MakeUniqueName(string.Format(Messages.TEMPLATE_FROM_SNAPSHOT_DEFAULT_NAME, snapshot.Name()), takenNames); - using (var dialog = new InputPromptDialog { + using (var dialog = new InputPromptDialog + { Text = Messages.SAVE_AS_TEMPLATE, PromptText = Messages.NEW_TEMPLATE_PROMPT, InputText = defaultName, @@ -85,15 +86,14 @@ namespace XenAdmin.Commands { if (dialog.ShowDialog(Parent) == DialogResult.OK) { - // TODO: work out what the new description should be - var action = new VMCloneAction(snapshot, dialog.InputText, ""); + var action = new VMCloneAction(snapshot, dialog.InputText, string.Format(Messages.TEMPLATE_FROM_SNAPSHOT_DEFAULT_DESCRIPTION, BrandManager.BrandConsole, snapshot.Name())); action.Completed += action_Completed; action.RunAsync(); } } } - void action_Completed(ActionBase sender) + private static void action_Completed(ActionBase sender) { var action = (AsyncAction)sender; VM vm = null; @@ -118,12 +118,6 @@ namespace XenAdmin.Commands return selection.ContainsOneItemOfType() && selection.AtLeastOneXenObjectCan(v => v.is_a_snapshot); } - public override string MenuText - { - get - { - return Messages.CREATE_TEMPLATE_FROM_SNAPSHOT_MENU_ITEM; - } - } + public override string MenuText => Messages.CREATE_TEMPLATE_FROM_SNAPSHOT_MENU_ITEM; } } diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index ef7a07629..5fd5673ee 100755 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -35816,6 +35816,15 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to Template generated by {0} from snapshot '{1}'. + /// + public static string TEMPLATE_FROM_SNAPSHOT_DEFAULT_DESCRIPTION { + get { + return ResourceManager.GetString("TEMPLATE_FROM_SNAPSHOT_DEFAULT_DESCRIPTION", resourceCulture); + } + } + /// /// Looks up a localized string similar to Template from snapshot '{0}'. /// diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index db76ca439..bc04a70f0 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -12404,6 +12404,9 @@ Do you want to connect to the pool coordinator '{1}'? Template + + Template generated by {0} from snapshot '{1}' + Template from snapshot '{0}' From 30291cc3bdd05e4f4aa03a73d95bbb1178e59445 Mon Sep 17 00:00:00 2001 From: Danilo Del Busso Date: Fri, 28 Apr 2023 10:06:18 +0100 Subject: [PATCH 3/8] CA-375803: Check if actions have succeeded before accessing action result Also add check to non-relevant actions Signed-off-by: Danilo Del Busso --- XenAdmin/Commands/NewFolderCommand.cs | 6 +- .../NewTemplateFromSnapshotCommand.cs | 18 ++---- .../Commands/RestoreHostFromBackupCommand.cs | 7 +-- XenAdmin/Controls/Wlb/WlbOptimizePool.cs | 51 +++++++++-------- XenAdmin/Dialogs/GraphDetailsDialog.cs | 2 +- .../ScheduledSnapshotsDialog.cs | 8 +-- XenAdmin/SettingsPanels/ClusteringEditPage.cs | 3 +- XenAdmin/TabPages/DockerDetailsPage.cs | 3 +- XenAdmin/TabPages/DockerProcessPage.cs | 3 +- XenAdmin/TabPages/HistoryPage.cs | 3 +- XenAdmin/TabPages/PerformancePage.cs | 2 +- XenAdmin/TabPages/WlbPage.cs | 56 +++++++++---------- .../DRWizards/DRFailoverWizardPrecheckPage.cs | 12 ++-- 13 files changed, 72 insertions(+), 102 deletions(-) diff --git a/XenAdmin/Commands/NewFolderCommand.cs b/XenAdmin/Commands/NewFolderCommand.cs index 4214fcf3d..e9e0f8d36 100644 --- a/XenAdmin/Commands/NewFolderCommand.cs +++ b/XenAdmin/Commands/NewFolderCommand.cs @@ -136,11 +136,9 @@ namespace XenAdmin.Commands { sender.Completed -= Action_Completed; - var action = sender as CreateFolderAction; - if (action != null && action.Succeeded) + if (sender is CreateFolderAction action && action.Succeeded) { - if (FoldersCreated != null) - FoldersCreated(action.NewPaths); + FoldersCreated?.Invoke(action.NewPaths); Program.MainWindow.TrySelectNewNode(delegate(object o) { diff --git a/XenAdmin/Commands/NewTemplateFromSnapshotCommand.cs b/XenAdmin/Commands/NewTemplateFromSnapshotCommand.cs index 106c2be07..ec5cb087e 100644 --- a/XenAdmin/Commands/NewTemplateFromSnapshotCommand.cs +++ b/XenAdmin/Commands/NewTemplateFromSnapshotCommand.cs @@ -95,20 +95,10 @@ namespace XenAdmin.Commands private static void action_Completed(ActionBase sender) { - var action = (AsyncAction)sender; - VM vm = null; - try - { - vm = action.Connection.Resolve(new XenRef(action.Result)); - } - catch (CancelledException) - { - Log.Info("User cancelled RBAC check when creating new template from snapshot."); - } - catch (Exception ex) - { - Log.Error(ex); - } + if (!sender.Succeeded || !(sender is AsyncAction action)) + return; + + var vm = action.Connection.Resolve(new XenRef(action.Result)); if (vm != null) new SetVMOtherConfigAction(vm.Connection, vm, "instant", "true").RunAsync(); } diff --git a/XenAdmin/Commands/RestoreHostFromBackupCommand.cs b/XenAdmin/Commands/RestoreHostFromBackupCommand.cs index b11d7a7f9..4467d76c3 100644 --- a/XenAdmin/Commands/RestoreHostFromBackupCommand.cs +++ b/XenAdmin/Commands/RestoreHostFromBackupCommand.cs @@ -142,12 +142,9 @@ namespace XenAdmin.Commands private void RestoreAction_Completed(ActionBase sender) { - HostBackupRestoreAction action = (HostBackupRestoreAction)sender; - - if (!action.Succeeded) + if (!(sender is HostBackupRestoreAction action) || !action.Succeeded) { - // Do nothing - failure will be reflected in the logs tab. - return; + return; } MainWindowCommandInterface.Invoke(delegate diff --git a/XenAdmin/Controls/Wlb/WlbOptimizePool.cs b/XenAdmin/Controls/Wlb/WlbOptimizePool.cs index f6595e492..bcc6749af 100644 --- a/XenAdmin/Controls/Wlb/WlbOptimizePool.cs +++ b/XenAdmin/Controls/Wlb/WlbOptimizePool.cs @@ -594,39 +594,38 @@ namespace XenAdmin.Controls.Wlb /// protected void OptRecRetrieveAction_Completed(ActionBase sender) { - AsyncAction action = (AsyncAction)sender; - if (action.IsCompleted) + if (!(sender is AsyncAction asyncAction) || !action.IsCompleted) + return; + + asyncAction.Completed -= OptRecRetrieveAction_Completed; + + if (asyncAction is WlbRetrieveRecommendationsAction thisAction) { - action.Completed -= OptRecRetrieveAction_Completed; - - if (action is WlbRetrieveRecommendationsAction thisAction) - { - _recommendations = thisAction.Recommendations; + _recommendations = thisAction.Recommendations; - if (_recommendations != null && IsGoodRecommendation(_recommendations) && _xenObject.Connection == action.Connection) + if (_recommendations != null && IsGoodRecommendation(_recommendations) && _xenObject.Connection == asyncAction.Connection) + { + Program.Invoke(this, delegate() { - Program.Invoke(this, delegate() - { - PopulateData(_recommendations); + PopulateData(_recommendations); - // In case optimizePoolListView is empty - if (optimizePoolListView.Items.Count == 0) - { - statusLabel.Text = Messages.WLB_OPT_POOL_NO_RECOMMENDATION; - EnableControls(true, false); - } - else - EnableControls(false, true); - }); - } - else - { - Program.Invoke(this, delegate() + // In case optimizePoolListView is empty + if (optimizePoolListView.Items.Count == 0) { statusLabel.Text = Messages.WLB_OPT_POOL_NO_RECOMMENDATION; EnableControls(true, false); - }); - } + } + else + EnableControls(false, true); + }); + } + else + { + Program.Invoke(this, delegate() + { + statusLabel.Text = Messages.WLB_OPT_POOL_NO_RECOMMENDATION; + EnableControls(true, false); + }); } } } diff --git a/XenAdmin/Dialogs/GraphDetailsDialog.cs b/XenAdmin/Dialogs/GraphDetailsDialog.cs index c215cb051..5118d308e 100644 --- a/XenAdmin/Dialogs/GraphDetailsDialog.cs +++ b/XenAdmin/Dialogs/GraphDetailsDialog.cs @@ -208,7 +208,7 @@ namespace XenAdmin.Dialogs private void getDataSourcesAction_Completed(ActionBase sender) { - if (!(sender is GetDataSourcesAction action)) + if (!(sender is GetDataSourcesAction action) || !action.Succeeded) return; Program.Invoke(this, () => diff --git a/XenAdmin/Dialogs/ScheduledSnapshots/ScheduledSnapshotsDialog.cs b/XenAdmin/Dialogs/ScheduledSnapshots/ScheduledSnapshotsDialog.cs index cfaf68b74..c5b72f454 100644 --- a/XenAdmin/Dialogs/ScheduledSnapshots/ScheduledSnapshotsDialog.cs +++ b/XenAdmin/Dialogs/ScheduledSnapshots/ScheduledSnapshotsDialog.cs @@ -208,13 +208,9 @@ namespace XenAdmin.Dialogs.ScheduledSnapshots { sender.Completed -= action_Completed; - var action = sender as GetServerLocalTimeAction; - if (action == null) + if (!(sender is GetServerLocalTimeAction action) || !action.Succeeded) return; - - if (!action.Succeeded) - return; - + Program.Invoke(Program.MainWindow, () => { try diff --git a/XenAdmin/SettingsPanels/ClusteringEditPage.cs b/XenAdmin/SettingsPanels/ClusteringEditPage.cs index b7d3b757f..b2797ed1f 100644 --- a/XenAdmin/SettingsPanels/ClusteringEditPage.cs +++ b/XenAdmin/SettingsPanels/ClusteringEditPage.cs @@ -154,8 +154,7 @@ namespace XenAdmin.SettingsPanels private void action_Completed(ActionBase sender) { - var action = (AsyncAction) sender; - if (!action.Succeeded) + if (!(sender is AsyncAction action) || !action.Succeeded) commonNetwork = null; Program.Invoke(ParentForm, delegate diff --git a/XenAdmin/TabPages/DockerDetailsPage.cs b/XenAdmin/TabPages/DockerDetailsPage.cs index a35c64397..67be1c6ed 100755 --- a/XenAdmin/TabPages/DockerDetailsPage.cs +++ b/XenAdmin/TabPages/DockerDetailsPage.cs @@ -99,8 +99,7 @@ namespace XenAdmin.TabPages private void action_Completed(ActionBase sender) { - var action = sender as RunContainerPluginAction; - if (action == null || action.Container != container) + if (!(sender is RunContainerPluginAction action) || action.Container != container) return; Program.Invoke(Program.MainWindow, () => { diff --git a/XenAdmin/TabPages/DockerProcessPage.cs b/XenAdmin/TabPages/DockerProcessPage.cs index e32e8ed3d..54157934c 100644 --- a/XenAdmin/TabPages/DockerProcessPage.cs +++ b/XenAdmin/TabPages/DockerProcessPage.cs @@ -110,8 +110,7 @@ namespace XenAdmin.TabPages private void action_Completed(ActionBase sender) { - var action = sender as RunContainerPluginAction; - if (action == null || action.Container != container) + if (!(sender is RunContainerPluginAction action) || action.Container != container) return; Program.Invoke(Program.MainWindow, () => { diff --git a/XenAdmin/TabPages/HistoryPage.cs b/XenAdmin/TabPages/HistoryPage.cs index fda9283f0..ffa935e63 100644 --- a/XenAdmin/TabPages/HistoryPage.cs +++ b/XenAdmin/TabPages/HistoryPage.cs @@ -140,8 +140,7 @@ namespace XenAdmin.TabPages private void action_Changed(ActionBase sender) { - var asyncAction = sender as AsyncAction; - if (asyncAction != null) + if (sender is AsyncAction asyncAction) asyncAction.RecomputeCanCancel(); Program.Invoke(Program.MainWindow, () => diff --git a/XenAdmin/TabPages/PerformancePage.cs b/XenAdmin/TabPages/PerformancePage.cs index c31038afe..b1cc116bc 100644 --- a/XenAdmin/TabPages/PerformancePage.cs +++ b/XenAdmin/TabPages/PerformancePage.cs @@ -416,7 +416,7 @@ namespace XenAdmin.TabPages private void SaveGraphs(ActionBase sender) { - if (!(sender is GetDataSourcesAction action)) + if (!(sender is GetDataSourcesAction action) || !action.Succeeded) return; Program.Invoke(Program.MainWindow, () => diff --git a/XenAdmin/TabPages/WlbPage.cs b/XenAdmin/TabPages/WlbPage.cs index 47da78a3e..d07dd591a 100644 --- a/XenAdmin/TabPages/WlbPage.cs +++ b/XenAdmin/TabPages/WlbPage.cs @@ -214,43 +214,41 @@ namespace XenAdmin.TabPages protected void action_Completed(ActionBase sender) { - // This seems to be called off the event thread - AsyncAction action = (AsyncAction)sender; - if (action.IsCompleted) + if (!(sender is AsyncAction action) || !action.IsCompleted) + return; + + action.Completed -= action_Completed; + if (action is EnableWLBAction || action is RetrieveWlbConfigurationAction || action is DisableWLBAction) { - action.Completed -= action_Completed; - if (action is EnableWLBAction || action is RetrieveWlbConfigurationAction || action is DisableWLBAction) + if (action is EnableWLBAction) { - if (action is EnableWLBAction) + EnableWLBAction thisAction = (EnableWLBAction)action; + _wlbPoolConfiguration = new WlbPoolConfiguration(thisAction.WlbConfiguration); + } + else if (action is RetrieveWlbConfigurationAction) + { + RetrieveWlbConfigurationAction thisAction = (RetrieveWlbConfigurationAction)action; + if (thisAction.Succeeded) { - EnableWLBAction thisAction = (EnableWLBAction)action; _wlbPoolConfiguration = new WlbPoolConfiguration(thisAction.WlbConfiguration); } - else if (action is RetrieveWlbConfigurationAction) + else { - RetrieveWlbConfigurationAction thisAction = (RetrieveWlbConfigurationAction)action; - if (thisAction.Succeeded) - { - _wlbPoolConfiguration = new WlbPoolConfiguration(thisAction.WlbConfiguration); - } - else - { - //_statusError = thisAction.Exception.Message; - _wlbPoolConfiguration = null; - } + //_statusError = thisAction.Exception.Message; + _wlbPoolConfiguration = null; } - else if (action is DisableWLBAction) - { - } - - Program.Invoke(Program.MainWindow, delegate() - { - if (_pool != null && _pool.Connection == action.Connection) - { - RefreshControls(); - } - }); } + else if (action is DisableWLBAction) + { + } + + Program.Invoke(Program.MainWindow, delegate() + { + if (_pool != null && _pool.Connection == action.Connection) + { + RefreshControls(); + } + }); } } diff --git a/XenAdmin/Wizards/DRWizards/DRFailoverWizardPrecheckPage.cs b/XenAdmin/Wizards/DRWizards/DRFailoverWizardPrecheckPage.cs index 3f10b9e8e..69af27348 100644 --- a/XenAdmin/Wizards/DRWizards/DRFailoverWizardPrecheckPage.cs +++ b/XenAdmin/Wizards/DRWizards/DRFailoverWizardPrecheckPage.cs @@ -491,19 +491,15 @@ namespace XenAdmin.Wizards.DRWizards Thread.Sleep(1000); Program.Invoke(Program.MainWindow, RefreshRechecks); - var drTaskCreateAction = sender as DrTaskCreateAction; - if (drTaskCreateAction != null && drTaskCreateAction.Succeeded) + if (sender is DrTaskCreateAction drTaskCreateAction && drTaskCreateAction.Succeeded) { - if (NewDrTaskIntroduced != null) - NewDrTaskIntroduced(drTaskCreateAction.Result); + NewDrTaskIntroduced?.Invoke(drTaskCreateAction.Result); return; } - var srIntroduceAction = sender as SrIntroduceAction; - if (srIntroduceAction != null && srIntroduceAction.Succeeded) + if (sender is SrIntroduceAction srIntroduceAction && srIntroduceAction.Succeeded) { - if (SrIntroduced != null) - SrIntroduced(new XenRef(srIntroduceAction.Result)); + SrIntroduced?.Invoke(new XenRef(srIntroduceAction.Result)); } } From d221ae7d61d15514bf3c132b9efeab6c47ea6dc2 Mon Sep 17 00:00:00 2001 From: Danilo Del Busso Date: Fri, 28 Apr 2023 10:07:29 +0100 Subject: [PATCH 4/8] Add missing article to new template message Signed-off-by: Danilo Del Busso --- XenModel/Messages.Designer.cs | 2 +- XenModel/Messages.resx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index 5fd5673ee..af8507f81 100755 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -25791,7 +25791,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to Enter &name for new template:. + /// Looks up a localized string similar to Enter a &name for new template:. /// public static string NEW_TEMPLATE_PROMPT { get { diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index bc04a70f0..0775342dc 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -8989,7 +8989,7 @@ It is strongly recommended that you Cancel and apply the latest version of the p Edit tags... - Enter &name for new template: + Enter a &name for new template: New Update Available - {0} From 4a1c13c6b201de759b28d8debb82e2283c19231b Mon Sep 17 00:00:00 2001 From: Danilo Del Busso Date: Fri, 28 Apr 2023 10:11:31 +0100 Subject: [PATCH 5/8] Suppress history when running user authorization action in `RoleElevationDialog` RBAC check sometimes runs after the action that is being checked. This results in the status bar being cleared if the RBAC check passes. Signed-off-by: Danilo Del Busso --- XenAdmin/Dialogs/RoleElevationDialog.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/XenAdmin/Dialogs/RoleElevationDialog.cs b/XenAdmin/Dialogs/RoleElevationDialog.cs index 1f3c57675..258ba5580 100644 --- a/XenAdmin/Dialogs/RoleElevationDialog.cs +++ b/XenAdmin/Dialogs/RoleElevationDialog.cs @@ -94,7 +94,7 @@ namespace XenAdmin.Dialogs { Exception delegateException = null; log.Debug("Testing logging in with the new credentials"); - DelegatedAsyncAction loginAction = new DelegatedAsyncAction(connection, + var loginAction = new DelegatedAsyncAction(connection, Messages.AUTHORIZING_USER, Messages.CREDENTIALS_CHECKING, Messages.CREDENTIALS_CHECK_COMPLETE, @@ -108,7 +108,7 @@ namespace XenAdmin.Dialogs { delegateException = ex; } - }); + }, true); using (var dlg = new ActionProgressDialog(loginAction, ProgressBarStyle.Marquee) {ShowTryAgainMessage = false}) dlg.ShowDialog(this); From 59ff422d9d5f4abf7cf1eb1bc1b605c5f23077c9 Mon Sep 17 00:00:00 2001 From: Danilo Del Busso Date: Fri, 28 Apr 2023 15:30:17 +0100 Subject: [PATCH 6/8] Add missing article to new template message Signed-off-by: Danilo Del Busso --- XenModel/Messages.Designer.cs | 2 +- XenModel/Messages.resx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index af8507f81..1328f86d1 100755 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -25791,7 +25791,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to Enter a &name for new template:. + /// Looks up a localized string similar to Enter a &name for the new template:. /// public static string NEW_TEMPLATE_PROMPT { get { diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index 0775342dc..3f3451a5b 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -8989,7 +8989,7 @@ It is strongly recommended that you Cancel and apply the latest version of the p Edit tags... - Enter a &name for new template: + Enter a &name for the new template: New Update Available - {0} From 113a427e6a57b45f366398014b652d53bbeab8da Mon Sep 17 00:00:00 2001 From: Danilo Del Busso Date: Fri, 28 Apr 2023 15:34:02 +0100 Subject: [PATCH 7/8] Collapse type checks in `WlbOptimizePool` Signed-off-by: Danilo Del Busso --- XenAdmin/Controls/Wlb/WlbOptimizePool.cs | 45 +++++++++++------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/XenAdmin/Controls/Wlb/WlbOptimizePool.cs b/XenAdmin/Controls/Wlb/WlbOptimizePool.cs index bcc6749af..5b0671ea1 100644 --- a/XenAdmin/Controls/Wlb/WlbOptimizePool.cs +++ b/XenAdmin/Controls/Wlb/WlbOptimizePool.cs @@ -594,39 +594,36 @@ namespace XenAdmin.Controls.Wlb /// protected void OptRecRetrieveAction_Completed(ActionBase sender) { - if (!(sender is AsyncAction asyncAction) || !action.IsCompleted) + if (!(sender is WlbRetrieveRecommendationsAction asyncAction) || !action.IsCompleted) return; asyncAction.Completed -= OptRecRetrieveAction_Completed; - if (asyncAction is WlbRetrieveRecommendationsAction thisAction) - { - _recommendations = thisAction.Recommendations; - - if (_recommendations != null && IsGoodRecommendation(_recommendations) && _xenObject.Connection == asyncAction.Connection) - { - Program.Invoke(this, delegate() - { - PopulateData(_recommendations); + _recommendations = asyncAction.Recommendations; - // In case optimizePoolListView is empty - if (optimizePoolListView.Items.Count == 0) - { - statusLabel.Text = Messages.WLB_OPT_POOL_NO_RECOMMENDATION; - EnableControls(true, false); - } - else - EnableControls(false, true); - }); - } - else + if (_recommendations != null && IsGoodRecommendation(_recommendations) && _xenObject.Connection == asyncAction.Connection) + { + Program.Invoke(this, delegate () { - Program.Invoke(this, delegate() + PopulateData(_recommendations); + + // In case optimizePoolListView is empty + if (optimizePoolListView.Items.Count == 0) { statusLabel.Text = Messages.WLB_OPT_POOL_NO_RECOMMENDATION; EnableControls(true, false); - }); - } + } + else + EnableControls(false, true); + }); + } + else + { + Program.Invoke(this, delegate () + { + statusLabel.Text = Messages.WLB_OPT_POOL_NO_RECOMMENDATION; + EnableControls(true, false); + }); } } From f16b0fed359bd54918fab484adff726a1558e1bb Mon Sep 17 00:00:00 2001 From: Danilo Del Busso Date: Tue, 2 May 2023 09:00:54 +0100 Subject: [PATCH 8/8] Revert `IsCompleted` checks Signed-off-by: Danilo Del Busso --- XenAdmin/Controls/Wlb/WlbOptimizePool.cs | 2 +- XenAdmin/Dialogs/GraphDetailsDialog.cs | 2 +- XenAdmin/TabPages/PerformancePage.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/XenAdmin/Controls/Wlb/WlbOptimizePool.cs b/XenAdmin/Controls/Wlb/WlbOptimizePool.cs index 5b0671ea1..50b36e6ae 100644 --- a/XenAdmin/Controls/Wlb/WlbOptimizePool.cs +++ b/XenAdmin/Controls/Wlb/WlbOptimizePool.cs @@ -594,7 +594,7 @@ namespace XenAdmin.Controls.Wlb /// protected void OptRecRetrieveAction_Completed(ActionBase sender) { - if (!(sender is WlbRetrieveRecommendationsAction asyncAction) || !action.IsCompleted) + if (!(sender is WlbRetrieveRecommendationsAction asyncAction)) return; asyncAction.Completed -= OptRecRetrieveAction_Completed; diff --git a/XenAdmin/Dialogs/GraphDetailsDialog.cs b/XenAdmin/Dialogs/GraphDetailsDialog.cs index 5118d308e..c215cb051 100644 --- a/XenAdmin/Dialogs/GraphDetailsDialog.cs +++ b/XenAdmin/Dialogs/GraphDetailsDialog.cs @@ -208,7 +208,7 @@ namespace XenAdmin.Dialogs private void getDataSourcesAction_Completed(ActionBase sender) { - if (!(sender is GetDataSourcesAction action) || !action.Succeeded) + if (!(sender is GetDataSourcesAction action)) return; Program.Invoke(this, () => diff --git a/XenAdmin/TabPages/PerformancePage.cs b/XenAdmin/TabPages/PerformancePage.cs index b1cc116bc..c31038afe 100644 --- a/XenAdmin/TabPages/PerformancePage.cs +++ b/XenAdmin/TabPages/PerformancePage.cs @@ -416,7 +416,7 @@ namespace XenAdmin.TabPages private void SaveGraphs(ActionBase sender) { - if (!(sender is GetDataSourcesAction action) || !action.Succeeded) + if (!(sender is GetDataSourcesAction action)) return; Program.Invoke(Program.MainWindow, () =>