The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7154
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) ===
From 74322dc9e92e0f82ef5bafe12bb28c7c44dd34c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Tue, 7 Apr 2020 21:02:02 -0400 Subject: [PATCH 1/5] shared/osarch: Coding style MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- shared/osarch/release.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shared/osarch/release.go b/shared/osarch/release.go index 22ba8d09b6..c016d06d73 100644 --- a/shared/osarch/release.go +++ b/shared/osarch/release.go @@ -13,6 +13,7 @@ func GetLSBRelease() (map[string]string, error) { if os.IsNotExist(err) { return getLSBRelease("/usr/lib/os-release") } + return osRelease, err } @@ -23,10 +24,12 @@ func getLSBRelease(filename string) (map[string]string, error) { if err != nil { return osRelease, err } + for i, line := range strings.Split(string(data), "\n") { if len(line) == 0 { continue } + if strings.HasPrefix(line, "#") { continue } @@ -35,6 +38,7 @@ func getLSBRelease(filename string) (map[string]string, error) { if len(tokens) != 2 { return osRelease, fmt.Errorf("%s: invalid format on line %d", filename, i+1) } + osRelease[tokens[0]] = strings.Trim(tokens[1], `'"`) } From 5dbc4ac9521a9ba8d9ff93daa5d75f1d4f36dd99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Tue, 7 Apr 2020 21:06:05 -0400 Subject: [PATCH 2/5] shared/osarch: Don't fail on missing os-release MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- shared/osarch/release.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shared/osarch/release.go b/shared/osarch/release.go index c016d06d73..83e300995a 100644 --- a/shared/osarch/release.go +++ b/shared/osarch/release.go @@ -22,6 +22,10 @@ func getLSBRelease(filename string) (map[string]string, error) { data, err := ioutil.ReadFile(filename) if err != nil { + if os.IsNotExist(err) { + return osRelease, nil + } + return osRelease, err } From 03b09db1446c850f8fb5ec50cf546963229c55dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Tue, 7 Apr 2020 21:11:11 -0400 Subject: [PATCH 3/5] shared/api: Add OS information MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #7153 Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- shared/api/server.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shared/api/server.go b/shared/api/server.go index 70f844a049..433b26287a 100644 --- a/shared/api/server.go +++ b/shared/api/server.go @@ -23,6 +23,10 @@ type ServerEnvironment struct { // API extension: lxc_features LXCFeatures map[string]string `json:"lxc_features" yaml:"lxc_features"` + // API extension: api_os + OSName string `json:"os_name" yaml:"os_name"` + OSVersion string `json:"os_version" yaml:"os_version"` + // API extension: projects Project string `json:"project" yaml:"project"` From 474dc14d6f7d201eb07adf1f8af947557ce81cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Tue, 7 Apr 2020 21:11:29 -0400 Subject: [PATCH 4/5] lxd/api: Add OS information MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxd/api_1.0.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lxd/api_1.0.go b/lxd/api_1.0.go index 4d4bbbb6a6..4c8f42f9e7 100644 --- a/lxd/api_1.0.go +++ b/lxd/api_1.0.go @@ -188,6 +188,11 @@ func api10Get(d *Daemon, r *http.Request) response.Response { projectName = project.Default } + osInfo, err := osarch.GetLSBRelease() + if err != nil { + return response.InternalError(err) + } + env := api.ServerEnvironment{ Addresses: addresses, Architectures: architectures, @@ -198,6 +203,8 @@ func api10Get(d *Daemon, r *http.Request) response.Response { Kernel: uname.Sysname, KernelArchitecture: uname.Machine, KernelVersion: uname.Release, + OSName: osInfo["NAME"], + OSVersion: osInfo["VERSION_ID"], Project: projectName, Server: "lxd", ServerPid: os.Getpid(), From d039f97cdcb25d213941fa90717449813b3b642d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Tue, 7 Apr 2020 21:12:32 -0400 Subject: [PATCH 5/5] api: Add api_os MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- doc/api-extensions.md | 4 ++-- shared/version/api.go | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/api-extensions.md b/doc/api-extensions.md index 9274f246b4..57f30068dc 100644 --- a/doc/api-extensions.md +++ b/doc/api-extensions.md @@ -1002,9 +1002,9 @@ This allows multiple ipvlan NIC devices to be added to a container. This adds USB and PCI devices to the output of `/1.0/resources`. ## resources\_cpu\_threads\_numa -This indicates that the numa_node field is now recorded per-thread +This indicates that the numa\_node field is now recorded per-thread rather than per core as some hardware apparently puts threads in different NUMA domains. ## resources\_cpu\_core\_die -Exposes the die_id information on each core. +Exposes the die\_id information on each core. diff --git a/shared/version/api.go b/shared/version/api.go index 04f131cc3a..87e58fd56b 100644 --- a/shared/version/api.go +++ b/shared/version/api.go @@ -204,6 +204,7 @@ var APIExtensions = []string{ "resources_usb_pci", "resources_cpu_threads_numa", "resources_cpu_core_die", + "api_os", } // APIExtensionsCount returns the number of available API extensions.
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel