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:
Mihaela Stoica 2017-06-30 14:05:52 +01:00
parent e3efff54b0
commit 533bf0ce02
3 changed files with 62 additions and 0 deletions

View File

@ -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&apos;s network backend is different from the master&apos;s.
/// </summary>

View File

@ -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>

View File

@ -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;