mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-23 20:36:33 +01:00
CP-23197: Implement the Update homogeneity Pool Join rule in XenCenter
Signed-off-by: Mihaela Stoica <mihaela.stoica@citrix.com>
This commit is contained in:
parent
e3efff54b0
commit
533bf0ce02
18
XenModel/Messages.Designer.cs
generated
18
XenModel/Messages.Designer.cs
generated
@ -23465,6 +23465,24 @@ namespace XenAdmin {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to This server has different updates from the master.
|
||||
/// </summary>
|
||||
public static string NEWPOOL_DIFFERENT_HOMOGENEOUS_UPDATES_FROM_MASTER {
|
||||
get {
|
||||
return ResourceManager.GetString("NEWPOOL_DIFFERENT_HOMOGENEOUS_UPDATES_FROM_MASTER", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to This server has different updates from servers already in the pool.
|
||||
/// </summary>
|
||||
public static string NEWPOOL_DIFFERENT_HOMOGENEOUS_UPDATES_FROM_POOL {
|
||||
get {
|
||||
return ResourceManager.GetString("NEWPOOL_DIFFERENT_HOMOGENEOUS_UPDATES_FROM_POOL", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to This server's network backend is different from the master's.
|
||||
/// </summary>
|
||||
|
@ -8002,6 +8002,12 @@ You should only proceed if you have verified that these settings are correct.</v
|
||||
<data name="NEWNETWORK_VNAME" xml:space="preserve">
|
||||
<value>New Private Network</value>
|
||||
</data>
|
||||
<data name="NEWPOOL_DIFFERENT_HOMOGENEOUS_UPDATES_FROM_MASTER" xml:space="preserve">
|
||||
<value>This server has different updates from the master</value>
|
||||
</data>
|
||||
<data name="NEWPOOL_DIFFERENT_HOMOGENEOUS_UPDATES_FROM_POOL" xml:space="preserve">
|
||||
<value>This server has different updates from servers already in the pool</value>
|
||||
</data>
|
||||
<data name="NEWPOOL_DIFFERENT_NETWORK_BACKENDS" xml:space="preserve">
|
||||
<value>This server's network backend is different from the master's</value>
|
||||
</data>
|
||||
|
@ -60,6 +60,8 @@ namespace XenAdmin.Core
|
||||
UnlicensedHostLicensedMaster,
|
||||
LicenseMismatch,
|
||||
DifferentServerVersion,
|
||||
DifferentHomogeneousUpdatesFromMaster,
|
||||
DifferentHomogeneousUpdatesFromPool,
|
||||
DifferentCPUs,
|
||||
DifferentNetworkBackends,
|
||||
MasterHasHA,
|
||||
@ -117,6 +119,9 @@ namespace XenAdmin.Core
|
||||
if (DifferentServerVersion(slaveHost, masterHost))
|
||||
return Reason.DifferentServerVersion;
|
||||
|
||||
if (DifferentHomogeneousUpdates(slaveHost, masterHost))
|
||||
return masterHost.Connection.Cache.Hosts.Length > 1 ? Reason.DifferentHomogeneousUpdatesFromPool : Reason.DifferentHomogeneousUpdatesFromMaster;
|
||||
|
||||
if (FreeHostPaidMaster(slaveHost, masterHost, allowLicenseUpgrade))
|
||||
return Reason.UnlicensedHostLicensedMaster;
|
||||
|
||||
@ -190,6 +195,10 @@ namespace XenAdmin.Core
|
||||
return Messages.NEWPOOL_LICENSEMISMATCH;
|
||||
case Reason.DifferentServerVersion:
|
||||
return Messages.NEWPOOL_DIFF_SERVER;
|
||||
case Reason.DifferentHomogeneousUpdatesFromMaster:
|
||||
return Messages.NEWPOOL_DIFFERENT_HOMOGENEOUS_UPDATES_FROM_MASTER;
|
||||
case Reason.DifferentHomogeneousUpdatesFromPool:
|
||||
return Messages.NEWPOOL_DIFFERENT_HOMOGENEOUS_UPDATES_FROM_POOL;
|
||||
case Reason.DifferentCPUs:
|
||||
return Messages.NEWPOOL_DIFF_HARDWARE;
|
||||
case Reason.DifferentNetworkBackends:
|
||||
@ -388,6 +397,35 @@ namespace XenAdmin.Core
|
||||
slave.ProductBrand != master.ProductBrand;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check whether all updates that request homogeneity are in fact homogeneous
|
||||
/// across the proposed pool. This is used in CanJoinPool and prevents the pool from being created
|
||||
/// </summary>
|
||||
private static bool DifferentHomogeneousUpdates(Host slave, Host master)
|
||||
{
|
||||
if (slave == null || master == null)
|
||||
return false;
|
||||
|
||||
List<Host> allHosts = new List<Host>(master.Connection.Cache.Hosts);
|
||||
allHosts.Add(slave);
|
||||
|
||||
// Make a list of updates that should be homogeneous
|
||||
var homogeneousUpdates = new List<Pool_update>();
|
||||
foreach (var host in allHosts)
|
||||
{
|
||||
homogeneousUpdates.AddRange(host.AppliedUpdates().Where(update => update.enforce_homogeneity));
|
||||
}
|
||||
|
||||
foreach (var update in homogeneousUpdates)
|
||||
{
|
||||
if (allHosts.Any(host => !host.AppliedUpdates().Exists(u => u.uuid == update.uuid)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool SameLinuxPack(Host slave, Host master)
|
||||
{
|
||||
return slave.LinuxPackPresent == master.LinuxPackPresent;
|
||||
|
Loading…
Reference in New Issue
Block a user