Skip to content

Commit

Permalink
Report linux distro full name in metadata (#397)
Browse files Browse the repository at this point in the history
* Report linux distro full name in metadata

* bump version
  • Loading branch information
yangpanMS authored Nov 8, 2024
1 parent 04cb9cb commit 93c4114
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.16.7
1.16.8
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public async Task GetHostMetadataReturnsTheExpectedOperatingSystemMetadataContra
object value;
Assert.IsTrue(metadata.TryGetValue("computerName", out value) && value.ToString() == Environment.MachineName);
Assert.IsTrue(metadata.TryGetValue("osFamily", out value) && value.ToString() == "Unix");
Assert.IsTrue(metadata.TryGetValue("osName", out value) && value.ToString() == "Ubuntu");
Assert.IsTrue(metadata.TryGetValue("osName", out value) && value.ToString() == "Ubuntu 20.01 build 1234");
Assert.IsTrue(metadata.TryGetValue("osPlatformArchitecture", out value) && value.ToString() == PlatformSpecifics.GetPlatformArchitectureName(platform, architecture));
Assert.IsTrue(metadata.TryGetValue("osDescription", out value));
Assert.IsTrue(metadata.TryGetValue("osVersion", out value));
Expand Down Expand Up @@ -334,7 +334,7 @@ public async Task GetHostMetadataAsyncExtensionExtensionReturnsTheExpectedMetada
// Host/OS Metadata
Assert.IsTrue(metadata.TryGetValue("computerName", out value) && value.ToString() == Environment.MachineName);
Assert.IsTrue(metadata.TryGetValue("osFamily", out value) && value.ToString() == "Unix");
Assert.IsTrue(metadata.TryGetValue("osName", out value) && value.ToString() == "Ubuntu");
Assert.IsTrue(metadata.TryGetValue("osName", out value) && value.ToString() == "TestUbuntu");
Assert.IsTrue(metadata.TryGetValue("osDescription", out value));
Assert.IsTrue(metadata.TryGetValue("osVersion", out value));
Assert.IsTrue(metadata.TryGetValue("osPlatformArchitecture", out value) && value.ToString() == "linux-x64");
Expand Down Expand Up @@ -386,7 +386,7 @@ public async Task GetHostMetadataExtensionReturnsTheExpectedMetadataContractInfo
object value;
Assert.IsTrue(metadata.TryGetValue("computerName", out value) && value.ToString() == Environment.MachineName);
Assert.IsTrue(metadata.TryGetValue("osFamily", out value) && value.ToString() == "Unix");
Assert.IsTrue(metadata.TryGetValue("osName", out value) && value.ToString() == "Ubuntu");
Assert.IsTrue(metadata.TryGetValue("osName", out value) && value.ToString() == "TestUbuntu");
Assert.IsTrue(metadata.TryGetValue("osDescription", out value));
Assert.IsTrue(metadata.TryGetValue("osVersion", out value));
Assert.IsTrue(metadata.TryGetValue("osPlatformArchitecture", out value) && value.ToString() == "linux-arm64");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace VirtualClient.Metadata
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -220,22 +221,21 @@ public static async Task<IDictionary<string, object>> GetHostMetadataAsync(this
break;
}

string osName = null;
if (systemManagement.Platform == PlatformID.Win32NT)
{
osName = "Windows";
metadata.Add("osName", "Windows");
}
else if (systemManagement.Platform == PlatformID.Unix)
{
LinuxDistributionInfo distro = await systemManagement.GetLinuxDistributionAsync(CancellationToken.None);
osName = distro.LinuxDistribution.ToString();
metadata.Add("osName", distro.OperationSystemFullName);
}

// Operating System Metadata
// -------------------------------------------------
metadata.Add("computerName", Environment.MachineName);
metadata.Add("osFamily", osFamily);
metadata.Add("osName", osName);

metadata.Add("osDescription", Environment.OSVersion.VersionString);
metadata.Add("osVersion", Environment.OSVersion.Version.ToString());
metadata.Add("osPlatformArchitecture", systemManagement.PlatformArchitectureName);
Expand Down

0 comments on commit 93c4114

Please sign in to comment.