mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 07:19:18 +01:00
CA-113431: Display a warning when a pool has a mixture of free hosts with license
expiry dates that are more than 30 days apart (not ideal, but safest solution for the case of a mixture of free and free but expiring soon hosts.) Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
parent
35226d65dd
commit
58e9b1c822
@ -163,16 +163,15 @@ namespace XenAdmin.Dialogs
|
||||
if (!licenseStatus.Updated)
|
||||
return false;
|
||||
|
||||
bool free = CurrentLicenseState == Dialogs.LicenseStatus.HostState.Free;
|
||||
bool noIdea = CurrentLicenseState == Dialogs.LicenseStatus.HostState.Unknown;
|
||||
|
||||
if (free || noIdea)
|
||||
if (CurrentLicenseState == Dialogs.LicenseStatus.HostState.Unknown)
|
||||
return false;
|
||||
|
||||
bool licensed = CurrentLicenseState == Dialogs.LicenseStatus.HostState.Licensed;
|
||||
Pool pool = Helpers.GetPool(XenObjectHost.Connection);
|
||||
|
||||
if (licensed)
|
||||
if (CurrentLicenseState == Dialogs.LicenseStatus.HostState.Free)
|
||||
return Dialogs.LicenseStatus.PoolIsMixedFreeAndExpiring(pool);
|
||||
|
||||
if (CurrentLicenseState == Dialogs.LicenseStatus.HostState.Licensed)
|
||||
return Dialogs.LicenseStatus.PoolIsPartiallyLicensed(pool)
|
||||
|| Dialogs.LicenseStatus.PoolHasMixedLicenses(pool);
|
||||
|
||||
@ -186,6 +185,13 @@ namespace XenAdmin.Dialogs
|
||||
{
|
||||
switch (CurrentLicenseState)
|
||||
{
|
||||
case Dialogs.LicenseStatus.HostState.Free:
|
||||
{
|
||||
Pool pool = Helpers.GetPool(XenObjectHost.Connection);
|
||||
if (Dialogs.LicenseStatus.PoolIsMixedFreeAndExpiring(pool))
|
||||
return Messages.POOL_IS_PARTIALLY_LICENSED;
|
||||
return Messages.UNKNOWN;
|
||||
}
|
||||
case Dialogs.LicenseStatus.HostState.PartiallyLicensed:
|
||||
return Messages.POOL_IS_PARTIALLY_LICENSED;
|
||||
case Dialogs.LicenseStatus.HostState.Licensed:
|
||||
|
@ -184,6 +184,33 @@ namespace XenAdmin.Dialogs
|
||||
get { return Helpers.ClearwaterOrGreater(LicencedHost); }
|
||||
}
|
||||
|
||||
internal static bool PoolIsMixedFreeAndExpiring(IXenObject xenObject)
|
||||
{
|
||||
if (xenObject is Pool)
|
||||
{
|
||||
if (xenObject.Connection.Cache.Hosts.Length == 1)
|
||||
return false;
|
||||
|
||||
int freeCount = xenObject.Connection.Cache.Hosts.Count(h => Host.GetEdition(h.edition) == Host.Edition.Free);
|
||||
if (freeCount == 0 || freeCount < xenObject.Connection.Cache.Hosts.Length)
|
||||
return false;
|
||||
|
||||
var expiryGroups = from Host h in xenObject.Connection.Cache.Hosts
|
||||
let exp = h.LicenseExpiryUTC
|
||||
group h by exp
|
||||
into g
|
||||
select new { ExpiryDate = g.Key, Hosts = g };
|
||||
|
||||
if(expiryGroups.Count() > 1)
|
||||
{
|
||||
expiryGroups.OrderBy(g => g.ExpiryDate);
|
||||
if ((expiryGroups.ElementAt(1).ExpiryDate - expiryGroups.ElementAt(0).ExpiryDate).TotalDays > 30)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
internal static bool PoolIsPartiallyLicensed(IXenObject xenObject)
|
||||
{
|
||||
if (xenObject is Pool)
|
||||
|
Loading…
Reference in New Issue
Block a user