CP-10955: XenCenter: use "feature-ts2" to detect Windows RDP feature

1.Add xapi version check in cream since Cream and Creedence have the same platform version
2.Check feature-ts2 to see if turn on RDP feature can use on specific VM PV tool

Signed-off-by: Cheng Zhang <cheng.zhang@citrix.com>
This commit is contained in:
Cheng Zhang 2015-01-27 14:13:50 +08:00
parent 540338f709
commit 2238b0ac1f
3 changed files with 23 additions and 11 deletions

View File

@ -82,6 +82,8 @@ namespace XenAdmin.ConsoleView
private bool RDPEnabled { get { return source != null ? source.RDPEnabled : false; } }
private bool RDPControlEnabled { get { return source != null ? source.RDPControlEnabled : false; } }
public VNCTabView(VNCView parent, VM source, string elevatedUsername, string elevatedPassword)
{
Program.AssertOnEventThread();
@ -766,9 +768,9 @@ namespace XenAdmin.ConsoleView
vncScreen.Unpause();
}
private bool RDPDisabledOnCreamOrGreater(IXenConnection conn)
private bool CanEnableRDPOnCreamOrGreater(IXenConnection conn)
{
return (!RDPEnabled && Helpers.CreamOrGreater(conn));
return (RDPControlEnabled && !RDPEnabled && Helpers.CreamOrGreater(conn));
}
// Make the 'enable RDP' button show something sensible if we can...
@ -798,7 +800,7 @@ namespace XenAdmin.ConsoleView
if (osString != null)
{
if (osString.Contains("Microsoft"))
label = (RDPDisabledOnCreamOrGreater(source.Connection)) ? enableRDP : UseRDP;
label = (CanEnableRDPOnCreamOrGreater(source.Connection)) ? enableRDP : UseRDP;
else
label = UseXVNC;
}
@ -1112,7 +1114,7 @@ namespace XenAdmin.ConsoleView
log.DebugFormat("RDP detected for VM '{0}'", source == null ? "unknown/null" : source.name_label);
this.toggleToXVNCorRDP = RDP;
if (vncScreen.UseVNC)
if (RDPDisabledOnCreamOrGreater(source.Connection))
if (CanEnableRDPOnCreamOrGreater(source.Connection))
this.toggleConsoleButton.Text = enableRDP;
else
this.toggleConsoleButton.Text = UseRDP;
@ -1174,7 +1176,7 @@ namespace XenAdmin.ConsoleView
vncScreen.UseVNC = !vncScreen.UseVNC;
vncScreen.UserWantsToSwitchProtocol = true;
if (RDPDisabledOnCreamOrGreater(source.Connection))
if (CanEnableRDPOnCreamOrGreater(source.Connection))
{
ThreeButtonDialog d = new ThreeButtonDialog(
new ThreeButtonDialog.Details(System.Drawing.SystemIcons.Question, Messages.FORCE_ENABLE_RDP),
@ -1225,7 +1227,7 @@ namespace XenAdmin.ConsoleView
{
bool rdp = (toggleToXVNCorRDP == RDP);
if (rdp)
toggleConsoleButton.Text = vncScreen.UseVNC ? (RDPDisabledOnCreamOrGreater(source.Connection) ? enableRDP : UseRDP) : UseStandardDesktop;
toggleConsoleButton.Text = vncScreen.UseVNC ? (CanEnableRDPOnCreamOrGreater(source.Connection) ? enableRDP : UseRDP) : UseStandardDesktop;
else
toggleConsoleButton.Text = vncScreen.UseSource ? UseXVNC : UseVNC;
scaleCheckBox.Visible = !rdp || vncScreen.UseVNC;

View File

@ -438,17 +438,15 @@ namespace XenAdmin.Core
HostBuildNumber(host) == CUSTOM_BUILD_NUMBER;
}
/// Creedence is ver. 2.0.0
/// Cream platform version is same with Creedence but XAPI version is 2.4
/// <param name="host">May be null, in which case true is returned.</param>
public static bool CreamOrGreater(Host host)
{
if (host == null)
return true;
string platform_version = HostPlatformVersion(host);
return
platform_version != null && productVersionCompare(platform_version, "1.9.90") > 0 ||
HostBuildNumber(host) == CUSTOM_BUILD_NUMBER;
API_Version APIVersion = Helper.GetAPIVersion(host.API_version_major, host.API_version_minor);
return (CreedenceOrGreater(host) && APIVersion >= API_Version.API_2_4) || HostBuildNumber(host) == CUSTOM_BUILD_NUMBER;
}
/// <param name="conn">May be null, in which case true is returned.</param>

View File

@ -443,6 +443,18 @@ namespace XenAPI
}
}
public bool RDPControlEnabled
{
get
{
var metrics = Connection.Resolve(this.guest_metrics);
if (metrics == null)
return false;
return 0 != IntKey(metrics.other, "feature-ts2", 0);
}
}
/// <summary>Returns true if
/// 1) the guest is HVM and
/// 2a) the allow-gpu-passthrough restriction is absent or