mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 15:29:26 +01:00
CP-38895: Check version annotations when using API fields or methods.
Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
parent
151841ce5e
commit
b2dc968ab1
@ -130,7 +130,7 @@ namespace XenAdmin.Commands
|
||||
|
||||
protected override bool CanRunCore(SelectedItemCollection selection)
|
||||
{
|
||||
return selection.Count == 1 && selection[0].XenObject is Host host && Helpers.Post82X(host);
|
||||
return selection.Count == 1 && selection[0].XenObject is Host host && Helpers.Post82X(host) && Helpers.XapiEqualOrGreater_1_290_0(host);
|
||||
}
|
||||
|
||||
public override string ContextMenuText => MenuText;
|
||||
|
@ -101,7 +101,9 @@ namespace XenAdmin.Commands
|
||||
return false;
|
||||
|
||||
var conn = selection.GetConnectionOfAllItems();
|
||||
if (conn == null || !Helpers.Post82X(conn) || conn.Cache.Hosts.Any(Host.RestrictCertificateVerification))
|
||||
if (conn == null || !Helpers.Post82X(conn) ||
|
||||
!Helpers.XapiEqualOrGreater_1_290_0(conn) ||
|
||||
conn.Cache.Hosts.Any(Host.RestrictCertificateVerification))
|
||||
return false;
|
||||
|
||||
var pool = Helpers.GetPoolOfOne(conn);
|
||||
|
@ -83,7 +83,7 @@ namespace XenAdmin.Dialogs
|
||||
|
||||
// Get the list of roles off the server and arrange them into rank
|
||||
var serverRoles = connection.Cache.Roles
|
||||
.Where(r => (!Helpers.Post82X(connection) || !r.is_internal) && r.subroles.Count > 0)
|
||||
.Where(r => (!Helpers.Post82X(connection) || !Helpers.XapiEqualOrGreater_22_5_0(connection) || !r.is_internal) && r.subroles.Count > 0)
|
||||
.OrderBy(r => r).Reverse().ToList();
|
||||
_subjectsPerRole = new Dictionary<Role, List<Subject>>();
|
||||
|
||||
|
@ -1775,7 +1775,7 @@ namespace XenAdmin
|
||||
s.Connection != null && Helpers.StockholmOrGreater(s.Connection) &&
|
||||
!s.Connection.Cache.Hosts.Any(Host.RestrictPoolSecretRotation));
|
||||
toolStripMenuItemEnableTls.Available = SelectionManager.Selection.Any(s =>
|
||||
s.Connection != null && Helpers.Post82X(s.Connection) &&
|
||||
s.Connection != null && Helpers.Post82X(s.Connection) && Helpers.XapiEqualOrGreater_1_290_0(s.Connection) &&
|
||||
!s.Connection.Cache.Hosts.Any(Host.RestrictCertificateVerification) &&
|
||||
s.Connection.Cache.Pools.Any(p => !p.tls_verification_enabled));
|
||||
}
|
||||
|
@ -1098,7 +1098,7 @@ namespace XenAdmin.TabPages
|
||||
|
||||
var thumbprint = string.Format(Messages.CERTIFICATE_THUMBPRINT_VALUE, certificate.fingerprint);
|
||||
|
||||
if (!Helpers.Post82X(host) || certificate.type == certificate_type.host)
|
||||
if (!Helpers.Post82X(host) || !Helpers.XapiEqualOrGreater_1_290_0(host) || certificate.type == certificate_type.host)
|
||||
pdSectionCertificate.AddEntry(GetCertificateType(certificate.type), $"{validity}\n{thumbprint}",
|
||||
new CommandToolStripMenuItem(new InstallCertificateCommand(Program.MainWindow, host), true),
|
||||
new CommandToolStripMenuItem(new ResetCertificateCommand(Program.MainWindow, host), true));
|
||||
@ -1169,15 +1169,17 @@ namespace XenAdmin.TabPages
|
||||
s.AddEntry(FriendlyName("host.enabled"), Messages.YES, item);
|
||||
}
|
||||
|
||||
if (Helpers.Post82X(host))
|
||||
if (Helpers.Post82X(host) && Helpers.XapiEqualOrGreater_1_290_0(host))
|
||||
{
|
||||
var pool = Helpers.GetPoolOfOne(xenObject.Connection);
|
||||
|
||||
if (pool.tls_verification_enabled && host.tls_verification_enabled)
|
||||
if (pool.tls_verification_enabled &&
|
||||
(!Helpers.XapiEqualOrGreater_1_313_0(host) || host.tls_verification_enabled))
|
||||
{
|
||||
s.AddEntry(Messages.CERTIFICATE_VERIFICATION_KEY, Messages.ENABLED);
|
||||
}
|
||||
else if (pool.tls_verification_enabled && isStandAloneHost)
|
||||
else if (pool.tls_verification_enabled && Helpers.XapiEqualOrGreater_1_313_0(host) &&
|
||||
!host.tls_verification_enabled && isStandAloneHost)
|
||||
{
|
||||
s.AddEntry(Messages.CERTIFICATE_VERIFICATION_KEY,
|
||||
Messages.CERTIFICATE_VERIFICATION_HOST_DISABLED_STANDALONE,
|
||||
@ -1313,12 +1315,13 @@ namespace XenAdmin.TabPages
|
||||
: Helpers.GetFriendlyLicenseName(p));
|
||||
s.AddEntry(Messages.NUMBER_OF_SOCKETS, p.CpuSockets().ToString());
|
||||
|
||||
if (Helpers.Post82X(p.Connection))
|
||||
if (Helpers.Post82X(p.Connection) && Helpers.XapiEqualOrGreater_1_290_0(p.Connection))
|
||||
{
|
||||
if (p.tls_verification_enabled)
|
||||
{
|
||||
var disabledHosts = p.Connection.Cache.Hosts.Where(h => !h.tls_verification_enabled).ToList();
|
||||
if (disabledHosts.Count > 0)
|
||||
|
||||
if (Helpers.XapiEqualOrGreater_1_313_0(p.Connection) && disabledHosts.Count > 0)
|
||||
{
|
||||
var sb = new StringBuilder(Messages.CERTIFICATE_VERIFICATION_HOST_DISABLED_IN_POOL);
|
||||
foreach (var h in disabledHosts)
|
||||
|
@ -64,7 +64,7 @@ namespace XenAdmin.Actions
|
||||
protected override void Run()
|
||||
{
|
||||
var serverRoles = Connection.Cache.Roles
|
||||
.Where(r => (!Helpers.Post82X(Connection) || !r.is_internal) && r.subroles.Count > 0)
|
||||
.Where(r => (!Helpers.Post82X(Connection) || !Helpers.XapiEqualOrGreater_22_5_0(Connection) || !r.is_internal) && r.subroles.Count > 0)
|
||||
.ToList();
|
||||
|
||||
var toAdd = serverRoles.Where(role => _newRoles.Contains(role) &&
|
||||
|
@ -91,8 +91,7 @@ namespace XenAdmin.Core
|
||||
return host.PlatformVersion();
|
||||
}
|
||||
|
||||
private delegate string HostToStr(Host host);
|
||||
private static string FromHostOrCoordinator(Host host, HostToStr fn)
|
||||
private static string FromHostOrCoordinator(Host host, Func<Host, string> fn)
|
||||
{
|
||||
if (host == null)
|
||||
return null;
|
||||
@ -276,6 +275,8 @@ namespace XenAdmin.Core
|
||||
return false;
|
||||
}
|
||||
|
||||
#region Versions
|
||||
|
||||
/// <param name="conn">May be null, in which case true is returned.</param>
|
||||
public static bool DundeeOrGreater(IXenConnection conn)
|
||||
{
|
||||
@ -476,7 +477,7 @@ namespace XenAdmin.Core
|
||||
/// <param name="conn">May be null, in which case true is returned.</param>
|
||||
public static bool Post82X(IXenConnection conn)
|
||||
{
|
||||
return conn == null || Post82X(Helpers.GetCoordinator(conn));
|
||||
return conn == null || Post82X(GetCoordinator(conn));
|
||||
}
|
||||
|
||||
/// <param name="host">May be null, in which case true is returned.</param>
|
||||
@ -508,6 +509,36 @@ namespace XenAdmin.Core
|
||||
return platformVersion != null && productVersionCompare(platformVersion, "3.2.1") >= 0;
|
||||
}
|
||||
|
||||
public static bool XapiEqualOrGreater_1_290_0(IXenConnection conn)
|
||||
{
|
||||
var coordinator = GetCoordinator(conn);
|
||||
return coordinator == null || productVersionCompare(coordinator.GetXapiVersion(), "1.290.0") >= 0;
|
||||
}
|
||||
|
||||
public static bool XapiEqualOrGreater_1_290_0(Host host)
|
||||
{
|
||||
return host == null || productVersionCompare(host.GetXapiVersion(), "1.290.0") >= 0;
|
||||
}
|
||||
|
||||
public static bool XapiEqualOrGreater_1_313_0(IXenConnection conn)
|
||||
{
|
||||
var coordinator = GetCoordinator(conn);
|
||||
return coordinator == null || productVersionCompare(coordinator.GetXapiVersion(), "1.313.0") >= 0;
|
||||
}
|
||||
|
||||
public static bool XapiEqualOrGreater_1_313_0(Host host)
|
||||
{
|
||||
return host == null || productVersionCompare(host.GetXapiVersion(), "1.313.0") >= 0;
|
||||
}
|
||||
|
||||
public static bool XapiEqualOrGreater_22_5_0(IXenConnection conn)
|
||||
{
|
||||
var coordinator = GetCoordinator(conn);
|
||||
return coordinator == null || productVersionCompare(coordinator.GetXapiVersion(), "22.5.0") >= 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// CP-3435: Disable Check for Updates in Common Criteria Certification project
|
||||
public static bool CommonCriteriaCertificationRelease
|
||||
{
|
||||
|
@ -642,6 +642,11 @@ namespace XenAPI
|
||||
return Get(software_version, "platform_version");
|
||||
}
|
||||
|
||||
public string GetXapiVersion()
|
||||
{
|
||||
return Get(software_version, "xapi");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For legacy build numbers only (used to be integers + one char at the end)
|
||||
/// From Falcon, this property is not used.
|
||||
@ -760,11 +765,6 @@ namespace XenAPI
|
||||
return updates;
|
||||
}
|
||||
|
||||
public string XAPI_version()
|
||||
{
|
||||
return Get(software_version, "xapi");
|
||||
}
|
||||
|
||||
public bool LinuxPackPresent()
|
||||
{
|
||||
return software_version.ContainsKey("xs:linux");
|
||||
|
Loading…
Reference in New Issue
Block a user