CA-381500: Ensure unlicensed hosts post Nile do not show as such in General Tab Page

Signed-off-by: Danilo Del Busso <danilo.delbusso@cloud.com>
This commit is contained in:
Danilo Del Busso 2023-08-15 09:20:03 +01:00
parent bee2388225
commit 0680d9cba0
No known key found for this signature in database
6 changed files with 25 additions and 30 deletions

View File

@ -47,7 +47,7 @@ namespace XenAdmin.TabPages
{
get
{
if (Status != null && Status.LicensedHost != null && Status.LicenseExpiresIn != null
if (Status?.LicensedHost != null && Status.LicenseExpiresIn != new TimeSpan()
&& !LicenseStatus.IsInfinite(Status.LicenseExpiresIn))
{
return HelpersGUI.DateTimeToString(Status.LicensedHost.LicenseExpiryUTC().ToLocalTime(),
@ -74,20 +74,20 @@ namespace XenAdmin.TabPages
return Messages.LICENSE_UNLICENSED;
if (Status.CurrentState == LicenseStatus.HostState.Free)
return Messages.LICENSE_UNLICENSED;
return Helpers.NileOrGreater(Status.LicensedHost) ? Messages.GENERAL_UNKNOWN : Messages.LICENSE_UNLICENSED;
TimeSpan s = Status.LicenseExpiresExactlyIn;
if (s.TotalMinutes < 2)
return Messages.LICENSE_EXPIRES_ONE_MIN;
if (s.TotalHours < 2)
return String.Format(Messages.LICENSE_EXPIRES_MINUTES, Math.Floor(s.TotalMinutes));
return string.Format(Messages.LICENSE_EXPIRES_MINUTES, Math.Floor(s.TotalMinutes));
if (s.TotalDays < 2)
return String.Format(Messages.LICENSE_EXPIRES_HOURS, Math.Floor(s.TotalHours));
return string.Format(Messages.LICENSE_EXPIRES_HOURS, Math.Floor(s.TotalHours));
if (s.TotalDays < 30)
return String.Format(Messages.LICENSE_EXPIRES_DAYS, s.Days);
return string.Format(Messages.LICENSE_EXPIRES_DAYS, s.Days);
return Messages.LICENSE_LICENSED;
}

View File

@ -112,11 +112,11 @@ namespace XenAdmin.TabPages
pdSectionLicense.UpdateEntryValueWithKey(FriendlyName("host.license_params-expiry"),
ss.ExpiryDate, ss.ShowExpiryDate);
pdSectionLicense.UpdateEntryValueWithKey(Messages.LICENSE_STATUS, ss.ExpiryStatus, true);
pdSectionLicense.UpdateEntryValueWithKey(Messages.LICENSE_EXPIRY_STATUS, ss.ExpiryStatus, true);
if (xenObject is Pool p)
{
var additionalString = PoolAdditionalLicenseString();
var additionalString = PoolAdditionalLicenseString(p);
pdSectionGeneral.UpdateEntryValueWithKey(
Messages.POOL_LICENSE,
additionalString != string.Empty
@ -1101,7 +1101,7 @@ namespace XenAdmin.TabPages
if (licenseStatus != null)
{
var ss = new GeneralTabLicenseStatusStringifier(licenseStatus);
s.AddEntry(Messages.LICENSE_STATUS,
s.AddEntry(Messages.LICENSE_EXPIRY_STATUS,
licenseStatus.Updated ? ss.ExpiryStatus : Messages.GENERAL_LICENSE_QUERYING, editItem);
if (ss.ShowExpiryDate)
@ -1498,7 +1498,7 @@ namespace XenAdmin.TabPages
if (xenObject is Pool p)
{
var additionalString = PoolAdditionalLicenseString();
var additionalString = PoolAdditionalLicenseString(p);
s.AddEntry(Messages.POOL_LICENSE,
additionalString != string.Empty
? string.Format(Messages.MAINWINDOW_CONTEXT_REASON, Helpers.GetFriendlyLicenseName(p), additionalString)
@ -1580,7 +1580,7 @@ namespace XenAdmin.TabPages
s.AddEntry(FriendlyName("host.uuid"), xenObject.Get("uuid") as string);
}
private string PoolAdditionalLicenseString()
private string PoolAdditionalLicenseString(IXenObject pool)
{
if (licenseStatus == null)
return string.Empty;
@ -1590,7 +1590,8 @@ namespace XenAdmin.TabPages
case LicenseStatus.HostState.Expired:
return Messages.LICENSE_EXPIRED;
case LicenseStatus.HostState.Free:
return Messages.LICENSE_UNLICENSED;
// We don't show "Unlicensed" when the pool is in Trial edition
return Helpers.NileOrGreater(pool?.Connection) ? string.Empty : Messages.LICENSE_UNLICENSED;
default:
return string.Empty;
}

View File

@ -22848,6 +22848,15 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to Expiry status.
/// </summary>
public static string LICENSE_EXPIRY_STATUS {
get {
return ResourceManager.GetString("LICENSE_EXPIRY_STATUS", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to This field is disabled due to license restrictions on the server..
/// </summary>
@ -23136,15 +23145,6 @@ namespace XenAdmin {
}
}
/// <summary>
/// Looks up a localized string similar to Status.
/// </summary>
public static string LICENSE_STATUS {
get {
return ResourceManager.GetString("LICENSE_STATUS", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Trial.
/// </summary>

View File

@ -7882,9 +7882,6 @@ SR UUID: {1}</value>
<data name="LICENSE_SERVER_WEB_CONSOLE_GOTO" xml:space="preserve">
<value>表示...</value>
</data>
<data name="LICENSE_STATUS" xml:space="preserve">
<value>状態</value>
</data>
<data name="LICENSE_SUPPORT_AND_DESKTOP_CLOUD_FEATURES_ENABLED" xml:space="preserve">
<value>サポート契約が有効です
{0} Virtual Apps and Desktops {0} Cloud 機能が有効です</value>

View File

@ -7942,6 +7942,9 @@ SR UUID: {1}</value>
<data name="LICENSE_EXPIRES_ONE_MIN" xml:space="preserve">
<value>Expires in 1 minute</value>
</data>
<data name="LICENSE_EXPIRY_STATUS" xml:space="preserve">
<value>Expiry status</value>
</data>
<data name="LICENSE_FIELD_DISABLED" xml:space="preserve">
<value>This field is disabled due to license restrictions on the server.</value>
</data>
@ -8038,9 +8041,6 @@ SR UUID: {1}</value>
<data name="LICENSE_STANDARD_FEATURES_ENABLED" xml:space="preserve">
<value>Standard features only</value>
</data>
<data name="LICENSE_STATUS" xml:space="preserve">
<value>Status</value>
</data>
<data name="LICENSE_TRIAL" xml:space="preserve">
<value>Trial</value>
</data>

View File

@ -7878,9 +7878,6 @@ SR UUID: {1}</value>
<data name="LICENSE_SERVER_WEB_CONSOLE_GOTO" xml:space="preserve">
<value>转至...</value>
</data>
<data name="LICENSE_STATUS" xml:space="preserve">
<value>状态</value>
</data>
<data name="LICENSE_SUPPORT_AND_DESKTOP_CLOUD_FEATURES_ENABLED" xml:space="preserve">
<value>有资格获得支持
{0} Virtual Apps and Desktops {0} Cloud 功能已启用</value>