CA-113319: LicenseManager was showing confusing licensing information.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2013-08-09 17:17:24 +01:00
parent accf445584
commit 35226d65dd
4 changed files with 71 additions and 15 deletions

View File

@ -148,7 +148,11 @@ namespace XenAdmin.Dialogs
// for a pool, get the lowest license, i.e. pool.LicenseString
Pool pool = Helpers.GetPool(XenObjectHost.Connection);
return pool != null ? pool.LicenseString : Helpers.GetFriendlyLicenseName(XenObjectHost);
if (pool == null || XenObject is Host)
return Helpers.GetFriendlyLicenseName(XenObjectHost);
return pool.LicenseString;
}
}
@ -156,10 +160,23 @@ namespace XenAdmin.Dialogs
{
get
{
bool licensed = CurrentLicenseState == Dialogs.LicenseStatus.HostState.Licensed;
if (!licenseStatus.Updated)
return false;
bool free = CurrentLicenseState == Dialogs.LicenseStatus.HostState.Free;
bool noIdea = CurrentLicenseState == Dialogs.LicenseStatus.HostState.Unknown;
return !licensed && !free && licenseStatus.Updated && !noIdea;
if (free || noIdea)
return false;
bool licensed = CurrentLicenseState == Dialogs.LicenseStatus.HostState.Licensed;
Pool pool = Helpers.GetPool(XenObjectHost.Connection);
if (licensed)
return Dialogs.LicenseStatus.PoolIsPartiallyLicensed(pool)
|| Dialogs.LicenseStatus.PoolHasMixedLicenses(pool);
return true;
}
}
@ -171,6 +188,17 @@ namespace XenAdmin.Dialogs
{
case Dialogs.LicenseStatus.HostState.PartiallyLicensed:
return Messages.POOL_IS_PARTIALLY_LICENSED;
case Dialogs.LicenseStatus.HostState.Licensed:
{
Pool pool = Helpers.GetPool(XenObjectHost.Connection);
if (Dialogs.LicenseStatus.PoolHasMixedLicenses(pool))
return Messages.POOL_HAS_MIXED_LICENSES;
if (Dialogs.LicenseStatus.PoolIsPartiallyLicensed(pool))
return Messages.POOL_IS_PARTIALLY_LICENSED;
return Messages.UNKNOWN;
}
case Dialogs.LicenseStatus.HostState.Unavailable:
return Messages.LICENSE_EXPIRED_NO_LICENSES_AVAILABLE;
case Dialogs.LicenseStatus.HostState.Expired:

View File

@ -184,31 +184,47 @@ namespace XenAdmin.Dialogs
get { return Helpers.ClearwaterOrGreater(LicencedHost); }
}
private bool PoolIsPartiallyLicensed
internal static bool PoolIsPartiallyLicensed(IXenObject xenObject)
{
get
if (xenObject is Pool)
{
if(XenObject is Pool)
{
if(XenObject.Connection.Cache.Hosts.Length == 1)
return false;
if (xenObject.Connection.Cache.Hosts.Length == 1)
return false;
int freeCount = XenObject.Connection.Cache.Hosts.Count(h => Host.GetEdition(h.edition) == Host.Edition.Free);
return freeCount > 0 && freeCount < XenObject.Connection.Cache.Hosts.Length;
}
return false;
int freeCount = xenObject.Connection.Cache.Hosts.Count(h => Host.GetEdition(h.edition) == Host.Edition.Free);
return freeCount > 0 && freeCount < xenObject.Connection.Cache.Hosts.Length;
}
return false;
}
internal static bool PoolHasMixedLicenses(IXenObject xenObject)
{
var pool = xenObject as Pool;
if (pool != null)
{
if (xenObject.Connection.Cache.Hosts.Length == 1)
return false;
if (xenObject.Connection.Cache.Hosts.Any(h => Host.GetEdition(h.edition) == Host.Edition.Free))
return false;
var licenseGroups = from Host h in xenObject.Connection.Cache.Hosts
let ed = Host.GetEdition(h.edition)
group h by ed;
return licenseGroups.Count() > 1;
}
return false;
}
private HostState CalculateCurrentState()
{
if (ExpiryDate.HasValue && ExpiryDate.Value.Day == 1 && ExpiryDate.Value.Month == 1 && ExpiryDate.Value.Year == 1970)
{
return HostState.Unavailable;
}
if (PoolIsPartiallyLicensed)
if (PoolIsPartiallyLicensed(XenObject))
return HostState.PartiallyLicensed;
if (IsUsingPerSocketGenerationLicenses)

View File

@ -24162,6 +24162,15 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to This pool has hosts with different types of license..
/// </summary>
public static string POOL_HAS_MIXED_LICENSES {
get {
return ResourceManager.GetString("POOL_HAS_MIXED_LICENSES", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to This pool has no shared storage.
/// </summary>

View File

@ -8443,6 +8443,9 @@ The VM protection policy for this VM does not have automatic archiving configure
<data name="POOL_GONE" xml:space="preserve">
<value>Pool has disappeared!</value>
</data>
<data name="POOL_HAS_MIXED_LICENSES" xml:space="preserve">
<value>This pool has hosts with different types of license.</value>
</data>
<data name="POOL_HAS_NO_SHARED_STORAGE" xml:space="preserve">
<value>This pool has no shared storage</value>
</data>