The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/6719
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 be3da115820bb356d83112e08b4eb8f24653d7ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Wed, 15 Jan 2020 11:54:55 -0500 Subject: [PATCH 1/4] doc/api-extension: Fix formatting 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api-extensions.md b/doc/api-extensions.md index f8daa82a8a..50d512f9c2 100644 --- a/doc/api-extensions.md +++ b/doc/api-extensions.md @@ -890,6 +890,6 @@ Add virtual machine support. ## image\_profiles Allows a list of profiles to be applied to an image when launching a new container. -## clustering_architecture +## clustering\_architecture This adds a new `architecture` attribute to cluster members which indicates a cluster member's architecture. From e3246860285d86de99cc8e62d857dd5cc3dd4a28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Wed, 15 Jan 2020 11:57:31 -0500 Subject: [PATCH 2/4] api: Add resources_disk_id extension 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 | 3 +++ shared/version/api.go | 1 + 2 files changed, 4 insertions(+) diff --git a/doc/api-extensions.md b/doc/api-extensions.md index 50d512f9c2..4e005e9800 100644 --- a/doc/api-extensions.md +++ b/doc/api-extensions.md @@ -893,3 +893,6 @@ Allows a list of profiles to be applied to an image when launching a new contain ## clustering\_architecture This adds a new `architecture` attribute to cluster members which indicates a cluster member's architecture. + +## resources\_disk\_id +Add a new device_id field in the disk entries on the resources API. diff --git a/shared/version/api.go b/shared/version/api.go index ca419947db..c75636edeb 100644 --- a/shared/version/api.go +++ b/shared/version/api.go @@ -181,6 +181,7 @@ var APIExtensions = []string{ "virtual-machines", "image_profiles", "clustering_architecture", + "resources_disk_id", } // APIExtensionsCount returns the number of available API extensions. From 2de3edd00c9f95fd91320c4fc3ed7f1efbeff395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Wed, 15 Jan 2020 11:57:57 -0500 Subject: [PATCH 3/4] shared/api: Add device_id to resources 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/api/resource.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/shared/api/resource.go b/shared/api/resource.go index f2a9619d15..c3d3c0ff9d 100644 --- a/shared/api/resource.go +++ b/shared/api/resource.go @@ -233,6 +233,9 @@ type ResourcesStorageDisk struct { RPM uint64 `json:"rpm" yaml:"rpm"` Serial string `json:"serial,omitempty" yaml:"serial,omitempty"` + // API extension: resources_disk_id + DeviceID string `json:"device_id" yaml:"device_id"` + Partitions []ResourcesStorageDiskPartition `json:"partitions" yaml:"partitions"` } From 26234f6ebd9149c7c9fedc084659d53606c16df0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Wed, 15 Jan 2020 11:58:03 -0500 Subject: [PATCH 4/4] lxd/resources: Add device_id 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/resources/storage.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lxd/resources/storage.go b/lxd/resources/storage.go index ee0a00162c..5bd4dc36ed 100644 --- a/lxd/resources/storage.go +++ b/lxd/resources/storage.go @@ -16,6 +16,7 @@ import ( ) var devDiskByPath = "/dev/disk/by-path" +var devDiskByID = "/dev/disk/by-id" var runUdevData = "/run/udev/data" var sysClassBlock = "/sys/class/block" @@ -285,6 +286,28 @@ func GetStorage() (*api.ResourcesStorage, error) { } } + // Try to find the udev device id + if sysfsExists(devDiskByID) { + links, err := ioutil.ReadDir(devDiskByID) + if err != nil { + return nil, errors.Wrapf(err, "Failed to list the links in \"%s\"", devDiskByID) + } + + for _, link := range links { + linkName := link.Name() + linkPath := filepath.Join(devDiskByID, linkName) + + linkTarget, err := filepath.EvalSymlinks(linkPath) + if err != nil { + return nil, errors.Wrapf(err, "Failed to track down \"%s\"", linkPath) + } + + if linkTarget == filepath.Join("/dev", entryName) { + disk.DeviceID = linkName + } + } + } + // Pull direct disk information err = storageAddDriveInfo(filepath.Join("/dev", entryName), &disk) if err != nil {
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel