From f64d0210595bd67fda5b08054e48fcaefad6b730 Mon Sep 17 00:00:00 2001 From: Stephen Turner Date: Thu, 15 May 2014 18:47:13 +0100 Subject: [PATCH] CA-135078 Rename "Delete Pool" Renamed "Delete Pool" to "Make into standlone server" Made sure it can never work with a multi-server pool Removed confirmation dialog, as it is not destructive Removed from context menu, as it is not important/common enough --- .../Commands/Controls/ContextMenuBuilder.cs | 1 - XenAdmin/Commands/DeletePoolCommand.cs | 25 ++----------------- XenModel/Actions/Pool/DestroyPoolAction.cs | 20 +++------------ XenModel/Messages.Designer.cs | 17 +++---------- XenModel/Messages.resx | 11 +++----- 5 files changed, 14 insertions(+), 60 deletions(-) diff --git a/XenAdmin/Commands/Controls/ContextMenuBuilder.cs b/XenAdmin/Commands/Controls/ContextMenuBuilder.cs index 54ef67c99..d6d3dffe8 100644 --- a/XenAdmin/Commands/Controls/ContextMenuBuilder.cs +++ b/XenAdmin/Commands/Controls/ContextMenuBuilder.cs @@ -730,7 +730,6 @@ namespace XenAdmin.Commands items.Add(new DisconnectPoolCommand(mainWindow, selection)); items.Add(new PoolReconnectAsCommand(mainWindow, selection)); items.AddSeparator(); - items.Add(new DeletePoolCommand(mainWindow, selection)); items.AddPluginItems(PluginContextMenu.pool, selection); items.AddSeparator(); items.Add(new PoolPropertiesCommand(mainWindow, selection)); diff --git a/XenAdmin/Commands/DeletePoolCommand.cs b/XenAdmin/Commands/DeletePoolCommand.cs index 9b6804f4b..4f6b219b1 100644 --- a/XenAdmin/Commands/DeletePoolCommand.cs +++ b/XenAdmin/Commands/DeletePoolCommand.cs @@ -74,12 +74,9 @@ namespace XenAdmin.Commands return; } - if (ShowConfirmationDialog()) + if (conn.IsConnected) { - if (conn.IsConnected) - { - new DestroyPoolAction(pool).RunAsync(); - } + new DestroyPoolAction(pool).RunAsync(); } } @@ -103,23 +100,5 @@ namespace XenAdmin.Commands return Messages.MAINWINDOW_DELETE_POOL; } } - - protected override string ConfirmationDialogText - { - get - { - SelectedItemCollection selection = GetSelection(); - Pool pool = (Pool)selection[0].PoolAncestor; - return string.Format(Messages.MESSAGEBOX_POOL_DELETE, pool.Name); - } - } - - public override string ContextMenuText - { - get - { - return Messages.MAINWINDOW_DELETE_POOL_CONTEXT_MENU; - } - } } } diff --git a/XenModel/Actions/Pool/DestroyPoolAction.cs b/XenModel/Actions/Pool/DestroyPoolAction.cs index e1f530891..a7e6c4ce9 100644 --- a/XenModel/Actions/Pool/DestroyPoolAction.cs +++ b/XenModel/Actions/Pool/DestroyPoolAction.cs @@ -29,6 +29,8 @@ * SUCH DAMAGE. */ +using System; + namespace XenAdmin.Actions { public class DestroyPoolAction: PureAsyncAction @@ -36,7 +38,6 @@ namespace XenAdmin.Actions public DestroyPoolAction(XenAPI.Pool pool) : base(pool.Connection, string.Format(Messages.DESTROYING_POOL, pool.Name)) { - System.Diagnostics.Trace.Assert(pool != null); Pool = pool; this.Description = Messages.WAITING; @@ -46,21 +47,8 @@ namespace XenAdmin.Actions { this.Description = Messages.POOLCREATE_DESTROYING; - int n = Connection.Cache.HostCount; - string master = Pool.master; - double p = 100.0 / n; // We have n - 1 to eject, and then 1 to rename. - int i = 0; - foreach (XenAPI.Host host in Connection.Cache.Hosts) - { - if (host.opaque_ref != master) - { - int lo = (int)(i * p); - int hi = (int)((i + 1) * p); - RelatedTask = XenAPI.Pool.async_eject(Session, host.opaque_ref); - PollToCompletion(lo, hi); - i++; - } - } + if (Connection.Cache.HostCount != 1) + throw new Exception("Cannot destroy a pool of more than one host"); // We should not have any UI to reach here, and must not be allowed to proceed XenAPI.Pool.set_name_label(Session, Pool.opaque_ref, ""); XenAPI.Pool.set_name_description(Session, Pool.opaque_ref, ""); this.Description = Messages.POOLCREATE_DESTROYED; diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index e1abeafb6..7f826b2ca 100644 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -9425,7 +9425,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to Destroying pool '{0}'. + /// Looks up a localized string similar to Making pool '{0}' into standalone server. /// public static string DESTROYING_POOL { get { @@ -18361,7 +18361,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to &Delete Pool.... + /// Looks up a localized string similar to Mak&e into standalone server. /// public static string MAINWINDOW_DELETE_POOL { get { @@ -18369,15 +18369,6 @@ namespace XenAdmin { } } - /// - /// Looks up a localized string similar to Delete &Pool.... - /// - public static string MAINWINDOW_DELETE_POOL_CONTEXT_MENU { - get { - return ResourceManager.GetString("MAINWINDOW_DELETE_POOL_CONTEXT_MENU", resourceCulture); - } - } - /// /// Looks up a localized string similar to &Delete Tag.... /// @@ -24805,7 +24796,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to Destroyed pool. + /// Looks up a localized string similar to Made pool into standalone server. /// public static string POOLCREATE_DESTROYED { get { @@ -24814,7 +24805,7 @@ namespace XenAdmin { } /// - /// Looks up a localized string similar to Destroying pool. + /// Looks up a localized string similar to Making pool into standalone server. /// public static string POOLCREATE_DESTROYING { get { diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index 57e26ad2c..ad8ded08c 100644 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -3349,7 +3349,7 @@ This will also delete its subfolders. Destroying servers - Destroying pool '{0}' + Making pool '{0}' into standalone server Host destroyed @@ -6404,10 +6404,7 @@ This will permanently delete and reinitialize all local storage on the servers. De&lete... - &Delete Pool... - - - Delete &Pool... + Mak&e into standalone server &Delete Tag... @@ -8567,10 +8564,10 @@ The VM protection policy for this VM does not have automatic archiving configure Creating pool - Destroyed pool + Made pool into standalone server - Destroying pool + Making pool into standalone server Removed from pool