mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-29 02:18:07 +01:00
Merge pull request #1815 from MihaelaStoica/master
CA-268975: Do not allow multiple hosts to join the pool if the new po…
This commit is contained in:
commit
2c2d5bf164
@ -72,7 +72,7 @@ namespace XenAdmin.Commands
|
||||
Dictionary<SelectedItem, string> reasons = new Dictionary<SelectedItem, string>();
|
||||
foreach (Host host in _hosts)
|
||||
{
|
||||
PoolJoinRules.Reason reason = PoolJoinRules.CanJoinPool(host.Connection, _pool.Connection, true, true, true);
|
||||
PoolJoinRules.Reason reason = PoolJoinRules.CanJoinPool(host.Connection, _pool.Connection, true, true, true, _hosts.Count);
|
||||
if (reason != PoolJoinRules.Reason.Allowed)
|
||||
reasons[new SelectedItem(host)] = PoolJoinRules.ReasonMessage(reason);
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ namespace XenAdmin.Commands
|
||||
{
|
||||
foreach (Host draggedHost in draggedHosts)
|
||||
{
|
||||
PoolJoinRules.Reason reason = PoolJoinRules.CanJoinPool(draggedHost.Connection, targetPool.Connection, true, true, true);
|
||||
PoolJoinRules.Reason reason = PoolJoinRules.CanJoinPool(draggedHost.Connection, targetPool.Connection, true, true, true, draggedHosts.Count);
|
||||
if (reason != PoolJoinRules.Reason.Allowed)
|
||||
{
|
||||
string reasonString = PoolJoinRules.ReasonMessage(reason);
|
||||
|
1
XenAdmin/Dialogs/NewPoolDialog.Designer.cs
generated
1
XenAdmin/Dialogs/NewPoolDialog.Designer.cs
generated
@ -160,6 +160,7 @@
|
||||
this.customTreeViewServers.ShowDescription = true;
|
||||
this.customTreeViewServers.ShowImages = false;
|
||||
this.customTreeViewServers.ShowRootLines = true;
|
||||
this.customTreeViewServers.ItemCheckChanged += new System.EventHandler<System.EventArgs>(this.customTreeViewServers_ItemCheckChanged);
|
||||
//
|
||||
// flowLayoutPanelServerListButtons
|
||||
//
|
||||
|
@ -73,7 +73,7 @@ namespace XenAdmin.Dialogs
|
||||
selectSlaves(hosts);
|
||||
}
|
||||
|
||||
private enum InvalidReasons { NONE, EMPTY_POOL_NAME, NO_MASTER };
|
||||
private enum InvalidReasons { NONE, EMPTY_POOL_NAME, NO_MASTER, MAX_POOL_SIZE_EXCEEDED };
|
||||
private InvalidReasons validToClose
|
||||
{
|
||||
get
|
||||
@ -87,6 +87,14 @@ namespace XenAdmin.Dialogs
|
||||
if (comboBoxServers.Items.Count <= 0)
|
||||
return InvalidReasons.NO_MASTER;
|
||||
|
||||
Host master = getMaster();
|
||||
if (master != null)
|
||||
{
|
||||
List<Host> slaves = getSlaves();
|
||||
if (PoolJoinRules.WillExceedPoolMaxSize(master.Connection, slaves.Count))
|
||||
return InvalidReasons.MAX_POOL_SIZE_EXCEEDED;
|
||||
}
|
||||
|
||||
return InvalidReasons.NONE;
|
||||
}
|
||||
}
|
||||
@ -118,6 +126,10 @@ namespace XenAdmin.Dialogs
|
||||
buttonCreate.Enabled = false;
|
||||
toolTipContainerCreate.SetToolTip(Messages.POOL_NAME_EMPTY);
|
||||
break;
|
||||
case InvalidReasons.MAX_POOL_SIZE_EXCEEDED:
|
||||
buttonCreate.Enabled = false;
|
||||
toolTipContainerCreate.SetToolTip(Messages.NEWPOOL_WILL_EXCEED_POOL_MAX_SIZE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -402,5 +414,10 @@ namespace XenAdmin.Dialogs
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void customTreeViewServers_ItemCheckChanged(object sender, EventArgs e)
|
||||
{
|
||||
updateButtons();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
9
XenModel/Messages.Designer.cs
generated
9
XenModel/Messages.Designer.cs
generated
@ -23735,6 +23735,15 @@ namespace XenAdmin {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The pool will exceed the maximum number of servers allowed by your license.
|
||||
/// </summary>
|
||||
public static string NEWPOOL_WILL_EXCEED_POOL_MAX_SIZE {
|
||||
get {
|
||||
return ResourceManager.GetString("NEWPOOL_WILL_EXCEED_POOL_MAX_SIZE", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to NFS SR [{0}].
|
||||
/// </summary>
|
||||
|
@ -8101,6 +8101,9 @@ You should only proceed if you have verified that these settings are correct.</v
|
||||
<data name="NEWPOOL_UNLICENSED_HOST_LICENSED_MASTER" xml:space="preserve">
|
||||
<value>You cannot add an unlicensed server to a licensed pool</value>
|
||||
</data>
|
||||
<data name="NEWPOOL_WILL_EXCEED_POOL_MAX_SIZE" xml:space="preserve">
|
||||
<value>The pool will exceed the maximum number of servers allowed by your license</value>
|
||||
</data>
|
||||
<data name="NEWSR_ACTION" xml:space="preserve">
|
||||
<value>NFS SR [{0}]</value>
|
||||
</data>
|
||||
|
@ -60,6 +60,7 @@ namespace XenAdmin.Core
|
||||
UnlicensedHostLicensedMaster,
|
||||
LicenseMismatch,
|
||||
MasterPoolMaxNumberHostReached,
|
||||
WillExceedPoolMaxSize,
|
||||
DifferentServerVersion,
|
||||
DifferentHomogeneousUpdatesFromMaster,
|
||||
DifferentHomogeneousUpdatesFromPool,
|
||||
@ -86,7 +87,7 @@ namespace XenAdmin.Core
|
||||
/// <param name="allowLicenseUpgrade">Whether we can upgrade a free host to a v6 license of the pool it's joining</param>
|
||||
/// <param name="allowCpuLevelling">Whether we can apply CPU levelling to the slave before it joins the pool</param>
|
||||
/// <returns>The reason why the server can't join the pool, or Reason.Allowed if it's OK</returns>
|
||||
public static Reason CanJoinPool(IXenConnection slaveConnection, IXenConnection masterConnection, bool allowLicenseUpgrade, bool allowCpuLevelling, bool allowSlaveAdConfig)
|
||||
public static Reason CanJoinPool(IXenConnection slaveConnection, IXenConnection masterConnection, bool allowLicenseUpgrade, bool allowCpuLevelling, bool allowSlaveAdConfig, int poolSizeIncrement = 1)
|
||||
{
|
||||
if (!Helpers.IsConnected(slaveConnection)) // also implies slaveConnection != null
|
||||
return Reason.NotConnected;
|
||||
@ -134,6 +135,9 @@ namespace XenAdmin.Core
|
||||
|
||||
if (MasterPoolMaxNumberHostReached(masterConnection))
|
||||
return Reason.MasterPoolMaxNumberHostReached;
|
||||
|
||||
if (WillExceedPoolMaxSize(masterConnection, poolSizeIncrement))
|
||||
return Reason.WillExceedPoolMaxSize;
|
||||
|
||||
if (!SameLinuxPack(slaveHost, masterHost))
|
||||
return Reason.NotSameLinuxPack;
|
||||
@ -199,6 +203,8 @@ namespace XenAdmin.Core
|
||||
return Messages.NEWPOOL_LICENSEMISMATCH;
|
||||
case Reason.MasterPoolMaxNumberHostReached:
|
||||
return Messages.NEWPOOL_MAX_NUMBER_HOST_REACHED;
|
||||
case Reason.WillExceedPoolMaxSize:
|
||||
return Messages.NEWPOOL_WILL_EXCEED_POOL_MAX_SIZE;
|
||||
case Reason.DifferentServerVersion:
|
||||
return Messages.NEWPOOL_DIFF_SERVER;
|
||||
case Reason.DifferentHomogeneousUpdatesFromMaster:
|
||||
@ -472,6 +478,11 @@ namespace XenAdmin.Core
|
||||
return Helpers.FeatureForbidden(connection, Host.RestrictPoolSize) && connection.Cache.HostCount > 2;
|
||||
}
|
||||
|
||||
public static bool WillExceedPoolMaxSize(IXenConnection connection, int poolSizeIncrement)
|
||||
{
|
||||
return Helpers.FeatureForbidden(connection, Host.RestrictPoolSize) && connection.Cache.HostCount + poolSizeIncrement > 3;
|
||||
}
|
||||
|
||||
private static bool HaEnabled(IXenConnection connection)
|
||||
{
|
||||
Pool pool = Helpers.GetPoolOfOne(connection);
|
||||
|
Loading…
Reference in New Issue
Block a user