From 0680d9cba0b28706581cace19d6480030d842702 Mon Sep 17 00:00:00 2001 From: Danilo Del Busso Date: Tue, 15 Aug 2023 09:20:03 +0100 Subject: [PATCH] CA-381500: Ensure unlicensed hosts post Nile do not show as such in General Tab Page Signed-off-by: Danilo Del Busso --- .../GeneralTabLicenseStatusStringifier.cs | 12 ++++++------ XenAdmin/TabPages/GeneralTabPage.cs | 13 +++++++------ XenModel/Messages.Designer.cs | 18 +++++++++--------- XenModel/Messages.ja.resx | 3 --- XenModel/Messages.resx | 6 +++--- XenModel/Messages.zh-CN.resx | 3 --- 6 files changed, 25 insertions(+), 30 deletions(-) diff --git a/XenAdmin/TabPages/GeneralTabLicenseStatusStringifier.cs b/XenAdmin/TabPages/GeneralTabLicenseStatusStringifier.cs index 255e6c7fa..d900aa16c 100644 --- a/XenAdmin/TabPages/GeneralTabLicenseStatusStringifier.cs +++ b/XenAdmin/TabPages/GeneralTabLicenseStatusStringifier.cs @@ -47,8 +47,8 @@ namespace XenAdmin.TabPages { get { - if (Status != null && Status.LicensedHost != null && Status.LicenseExpiresIn != null - && !LicenseStatus.IsInfinite(Status.LicenseExpiresIn)) + if (Status?.LicensedHost != null && Status.LicenseExpiresIn != new TimeSpan() + && !LicenseStatus.IsInfinite(Status.LicenseExpiresIn)) { return HelpersGUI.DateTimeToString(Status.LicensedHost.LicenseExpiryUTC().ToLocalTime(), Messages.DATEFORMAT_DMY_LONG, true); @@ -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; } diff --git a/XenAdmin/TabPages/GeneralTabPage.cs b/XenAdmin/TabPages/GeneralTabPage.cs index 548a3afb5..3049e278d 100644 --- a/XenAdmin/TabPages/GeneralTabPage.cs +++ b/XenAdmin/TabPages/GeneralTabPage.cs @@ -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; } diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index 248164ed1..8e425f4be 100755 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -22848,6 +22848,15 @@ namespace XenAdmin { } } + /// + /// Looks up a localized string similar to Expiry status. + /// + public static string LICENSE_EXPIRY_STATUS { + get { + return ResourceManager.GetString("LICENSE_EXPIRY_STATUS", resourceCulture); + } + } + /// /// Looks up a localized string similar to This field is disabled due to license restrictions on the server.. /// @@ -23136,15 +23145,6 @@ namespace XenAdmin { } } - /// - /// Looks up a localized string similar to Status. - /// - public static string LICENSE_STATUS { - get { - return ResourceManager.GetString("LICENSE_STATUS", resourceCulture); - } - } - /// /// Looks up a localized string similar to Trial. /// diff --git a/XenModel/Messages.ja.resx b/XenModel/Messages.ja.resx index 5b65584ca..d986820f7 100755 --- a/XenModel/Messages.ja.resx +++ b/XenModel/Messages.ja.resx @@ -7882,9 +7882,6 @@ SR UUID: {1} 表示... - - 状態 - サポート契約が有効です {0} Virtual Apps and Desktops {0} Cloud 機能が有効です diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index d25392cab..6d9b0c952 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -7942,6 +7942,9 @@ SR UUID: {1} Expires in 1 minute + + Expiry status + This field is disabled due to license restrictions on the server. @@ -8038,9 +8041,6 @@ SR UUID: {1} Standard features only - - Status - Trial diff --git a/XenModel/Messages.zh-CN.resx b/XenModel/Messages.zh-CN.resx index 8f01b5434..de3a31944 100755 --- a/XenModel/Messages.zh-CN.resx +++ b/XenModel/Messages.zh-CN.resx @@ -7878,9 +7878,6 @@ SR UUID: {1} 转至... - - 状态 - 有资格获得支持 {0} Virtual Apps and Desktops {0} Cloud 功能已启用