Improve how server OS and Platform are displayed (#2264)

* Also fixed versioning issues with how isPolybaseEnabled and isXTPSupported properties are accessed.
This commit is contained in:
Cory Rivera
2023-10-06 13:24:22 -07:00
committed by GitHub
parent be8e3f4fe3
commit dacddd250c
6 changed files with 44 additions and 73 deletions

View File

@@ -111,18 +111,11 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
public static bool IsXTPSupportedOnServer(SMO.Server server) public static bool IsXTPSupportedOnServer(SMO.Server server)
{ {
if(server.DatabaseEngineEdition == DatabaseEngineEdition.SqlOnDemand) if (server.DatabaseEngineEdition == DatabaseEngineEdition.SqlOnDemand)
{ {
return false; return false;
} }
bool isXTPSupported = false; return server.IsSupportedProperty(nameof(server.IsXTPSupported)) && server.IsXTPSupported;
if (server.ConnectionContext.ExecuteScalar("SELECT SERVERPROPERTY('IsXTPSupported')") != DBNull.Value)
{
isXTPSupported = server.IsXTPSupported;
}
return isXTPSupported;
} }
public static bool IsPolybasedInstalledOnServer(SMO.Server server) public static bool IsPolybasedInstalledOnServer(SMO.Server server)

View File

@@ -1199,7 +1199,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
this.processors = server.Processors; this.processors = server.Processors;
this.isClustered = server.IsClustered; this.isClustered = server.IsClustered;
this.isHadrEnabled = server.IsHadrEnabled; this.isHadrEnabled = server.IsHadrEnabled;
this.isPolyBaseInstalled = server.IsPolyBaseInstalled;
this.product = server.Product; this.product = server.Product;
this.rootDirectory = server.RootDirectory; this.rootDirectory = server.RootDirectory;
@@ -1212,19 +1211,25 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
this.reservedStorageSizeMB = server.ReservedStorageSizeMB; this.reservedStorageSizeMB = server.ReservedStorageSizeMB;
this.storageSpaceUsageInMB = server.UsedStorageSizeMB; this.storageSpaceUsageInMB = server.UsedStorageSizeMB;
} }
if (server.VersionMajor < 14 || server.HostPlatform == null)
{
this.platform = server.Platform;
this.operatingSystem = "Microsoft Windows NT " +
Convert.ToString(server.OSVersion, System.Globalization.CultureInfo.InvariantCulture);
}
else else
{ {
this.isXTPSupported = server.IsXTPSupported;
}
if (server.VersionMajor >= 14)
{
this.operatingSystem = server.HostDistribution;
this.platform = server.HostPlatform; this.platform = server.HostPlatform;
this.operatingSystem = $"{server.HostDistribution} ({server.HostRelease})";
} }
if (server.VersionMajor >= 13) if (server.VersionMajor >= 13)
{ {
this.isPolyBaseInstalled = server.IsPolyBaseInstalled; this.isPolyBaseInstalled = server.IsPolyBaseInstalled;
} }
if (Utils.IsXTPSupportedOnServer(server))
{
this.isXTPSupported = server.IsXTPSupported;
}
} }
private void LoadMemoryProperties() private void LoadMemoryProperties()

View File

@@ -48,6 +48,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
Name = prototype.Name, Name = prototype.Name,
Language = prototype.Language, Language = prototype.Language,
MemoryInMB = prototype.MemoryInMB, MemoryInMB = prototype.MemoryInMB,
OperatingSystem = prototype.OperatingSystem,
Platform = prototype.Platform,
Processors = prototype.Processors, Processors = prototype.Processors,
IsClustered = prototype.IsClustered, IsClustered = prototype.IsClustered,
IsHadrEnabled = prototype.IsHadrEnabled, IsHadrEnabled = prototype.IsHadrEnabled,
@@ -90,11 +92,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
serverObjInfo.ReservedStorageSizeMB = sMI.ReservedStorageSizeMB; serverObjInfo.ReservedStorageSizeMB = sMI.ReservedStorageSizeMB;
serverObjInfo.StorageSpaceUsageInMB = sMI.StorageSpaceUsageInMB; serverObjInfo.StorageSpaceUsageInMB = sMI.StorageSpaceUsageInMB;
} }
if (prototype is ServerPrototype140 s140)
{
serverObjInfo.OperatingSystem = s140.OperatingSystem;
serverObjInfo.Platform = s140.Platform;
}
if (prototype is ServerPrototype130 s130) if (prototype is ServerPrototype130 s130)
{ {
serverObjInfo.IsPolyBaseInstalled = s130.IsPolyBaseInstalled; serverObjInfo.IsPolyBaseInstalled = s130.IsPolyBaseInstalled;
@@ -169,11 +166,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
{ {
prototype = new ServerPrototypeMI(server, connection); prototype = new ServerPrototypeMI(server, connection);
} }
else if (server.VersionMajor >= 14) else if (server.VersionMajor >= 13)
{
prototype = new ServerPrototype140(server, connection);
}
else if (server.VersionMajor == 13)
{ {
prototype = new ServerPrototype130(server, connection); prototype = new ServerPrototype130(server, connection);
} }

View File

@@ -53,6 +53,19 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
} }
} }
public string OperatingSystem
{
get
{
return this.currentState.OperatingSystem;
}
set
{
this.currentState.OperatingSystem = value;
}
}
public string Version public string Version
{ {
get get
@@ -77,6 +90,18 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
} }
} }
public string Platform
{
get
{
return this.currentState.Platform;
}
set
{
this.currentState.Platform = value;
}
}
public int MemoryInMB public int MemoryInMB
{ {
get get
@@ -924,6 +949,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
this.Name = serverInfo.Name ?? string.Empty; this.Name = serverInfo.Name ?? string.Empty;
this.Language = serverInfo.Language; this.Language = serverInfo.Language;
this.MemoryInMB = serverInfo.MemoryInMB; this.MemoryInMB = serverInfo.MemoryInMB;
this.OperatingSystem = serverInfo.OperatingSystem;
this.Platform = serverInfo.Platform;
this.Version = serverInfo.Version; this.Version = serverInfo.Version;
this.Processors = serverInfo.Processors; this.Processors = serverInfo.Processors;
this.Version = serverInfo.Version; this.Version = serverInfo.Version;

View File

@@ -1,47 +0,0 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;
namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
{
internal class ServerPrototype140 : ServerPrototype130
{
public ServerPrototype140(Server server, ServerConnection connection) : base(server, connection) { }
public string OperatingSystem
{
get
{
return this.currentState.OperatingSystem;
}
set
{
this.currentState.OperatingSystem = value;
}
}
public string Platform
{
get
{
return this.currentState.Platform;
}
set
{
this.currentState.Platform = value;
}
}
public override void ApplyInfoToPrototype(ServerInfo serverInfo)
{
base.ApplyInfoToPrototype(serverInfo);
this.OperatingSystem = serverInfo.OperatingSystem;
this.Platform = serverInfo.Platform;
}
}
}

View File

@@ -11,7 +11,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectManagement
/// <summary> /// <summary>
/// Prototype for representing a manage instance server. /// Prototype for representing a manage instance server.
/// </summary> /// </summary>
internal class ServerPrototypeMI : ServerPrototype140 internal class ServerPrototypeMI : ServerPrototype130
{ {
public ServerPrototypeMI(Server server, ServerConnection connection) : base(server, connection) { } public ServerPrototypeMI(Server server, ServerConnection connection) : base(server, connection) { }