From 1850c81fafa614f541a69c1cc54e8dfc338a0009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Wed, 15 May 2024 13:08:10 +0100 Subject: [PATCH 1/6] service: Export name of multipath wires --- .../lib/agama/dbus/storage/interfaces/device/multipath.rb | 8 +++++--- .../dbus/storage/interfaces/device/multipath_examples.rb | 7 ++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/service/lib/agama/dbus/storage/interfaces/device/multipath.rb b/service/lib/agama/dbus/storage/interfaces/device/multipath.rb index 3293ed376d..40037fcc75 100644 --- a/service/lib/agama/dbus/storage/interfaces/device/multipath.rb +++ b/service/lib/agama/dbus/storage/interfaces/device/multipath.rb @@ -44,17 +44,19 @@ def self.apply?(storage_device) MULTIPATH_INTERFACE = "org.opensuse.Agama.Storage1.Multipath" private_constant :MULTIPATH_INTERFACE - # Paths of the D-Bus objects representing the multipath wires. + # Name of the multipath wires. + # + # @note: The multipath wires are not exported in D-Bus yet. # # @return [Array] def multipath_wires - storage_device.parents.map { |p| tree.path_for(p) } + storage_device.parents.map(&:name) end def self.included(base) base.class_eval do dbus_interface MULTIPATH_INTERFACE do - dbus_reader :multipath_wires, "ao", dbus_name: "Wires" + dbus_reader :multipath_wires, "as", dbus_name: "Wires" end end end diff --git a/service/test/agama/dbus/storage/interfaces/device/multipath_examples.rb b/service/test/agama/dbus/storage/interfaces/device/multipath_examples.rb index ddf59a7d73..c06e779637 100644 --- a/service/test/agama/dbus/storage/interfaces/device/multipath_examples.rb +++ b/service/test/agama/dbus/storage/interfaces/device/multipath_examples.rb @@ -28,12 +28,9 @@ let(:device) { devicegraph.multipaths.first } describe "#multipath_wires" do - it "returns the D-Bus path of the Multipath wires" do - sda = devicegraph.find_by_name("/dev/sda") - sdb = devicegraph.find_by_name("/dev/sdb") - + it "returns the name of the Multipath wires" do expect(subject.multipath_wires) - .to contain_exactly(tree.path_for(sda), tree.path_for(sdb)) + .to contain_exactly("/dev/sda", "/dev/sdb") end end end From ec442d223aa6bbca6f6fcb6507c438bdfab51e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Wed, 15 May 2024 13:08:33 +0100 Subject: [PATCH 2/6] service: Export name of RAID devices --- service/lib/agama/dbus/storage/interfaces/device/raid.rb | 8 +++++--- .../agama/dbus/storage/interfaces/device/raid_examples.rb | 7 ++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/service/lib/agama/dbus/storage/interfaces/device/raid.rb b/service/lib/agama/dbus/storage/interfaces/device/raid.rb index 228e389c4b..ecbf3c62a0 100644 --- a/service/lib/agama/dbus/storage/interfaces/device/raid.rb +++ b/service/lib/agama/dbus/storage/interfaces/device/raid.rb @@ -44,17 +44,19 @@ def self.apply?(storage_device) RAID_INTERFACE = "org.opensuse.Agama.Storage1.RAID" private_constant :RAID_INTERFACE - # Paths of the D-Bus objects representing the devices used by the DM RAID. + # Name of the devices used by the DM RAID. + # + # @note: The devices used by a DM RAID are not exported in D-Bus yet. # # @return [Array] def raid_devices - storage_device.parents.map { |p| tree.path_for(p) } + storage_device.parents.map(&:name) end def self.included(base) base.class_eval do dbus_interface RAID_INTERFACE do - dbus_reader :raid_devices, "ao", dbus_name: "Devices" + dbus_reader :raid_devices, "as", dbus_name: "Devices" end end end diff --git a/service/test/agama/dbus/storage/interfaces/device/raid_examples.rb b/service/test/agama/dbus/storage/interfaces/device/raid_examples.rb index 7b53df1978..751e73ad4a 100644 --- a/service/test/agama/dbus/storage/interfaces/device/raid_examples.rb +++ b/service/test/agama/dbus/storage/interfaces/device/raid_examples.rb @@ -28,12 +28,9 @@ let(:device) { devicegraph.dm_raids.first } describe "#raid_devices" do - it "returns the D-Bus path of the RAID devices" do - sdb = devicegraph.find_by_name("/dev/sdb") - sdc = devicegraph.find_by_name("/dev/sdc") - + it "returns the name of the RAID devices" do expect(subject.raid_devices) - .to contain_exactly(tree.path_for(sdb), tree.path_for(sdc)) + .to contain_exactly("/dev/sdb", "/dev/sdc") end end end From 9f0faa1324cadf5ed5a374f1569036232d6306b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Wed, 15 May 2024 13:09:15 +0100 Subject: [PATCH 3/6] rust: Adapt to changes in D-Bus API --- rust/agama-lib/src/storage/model.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/agama-lib/src/storage/model.rs b/rust/agama-lib/src/storage/model.rs index 4154490686..ce524d81cc 100644 --- a/rust/agama-lib/src/storage/model.rs +++ b/rust/agama-lib/src/storage/model.rs @@ -611,7 +611,7 @@ pub struct Md { #[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] #[serde(rename_all = "camelCase")] pub struct Multipath { - pub wires: Vec, + pub wires: Vec, } #[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] @@ -653,5 +653,5 @@ impl TryFrom> for UnusedSlot { #[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] #[serde(rename_all = "camelCase")] pub struct Raid { - pub devices: Vec, + pub devices: Vec, } From 2b601e3477ffe8b94728b460b768f70405c4da53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Wed, 15 May 2024 13:18:51 +0100 Subject: [PATCH 4/6] web: Fix multipath wires and RAID devices --- web/src/client/storage.js | 33 ++++++++++++++++++---------- web/src/client/storage.test.js | 40 +++++++++++++++++++++++++++++----- 2 files changed, 56 insertions(+), 17 deletions(-) diff --git a/web/src/client/storage.js b/web/src/client/storage.js index 820c2d861e..e357bced01 100644 --- a/web/src/client/storage.js +++ b/web/src/client/storage.js @@ -228,6 +228,22 @@ class DevicesManager { */ async getDevices() { const buildDevice = (jsonDevice, jsonDevices) => { + /** @type {() => StorageDevice} */ + const buildDefaultDevice = () => { + return { + sid: 0, + name: "", + description: "", + isDrive: false, + type: "" + }; + }; + + /** @type {(names: string[]) => StorageDevice[]} */ + const buildCollectionFromNames = (names) => { + return names.map(name => ({ ...buildDefaultDevice(), name })); + }; + /** @type {(sids: String[], jsonDevices: object[]) => StorageDevice[]} */ const buildCollection = (sids, jsonDevices) => { if (sids === null || sids === undefined) return []; @@ -251,12 +267,12 @@ class DevicesManager { /** @type {(device: StorageDevice, info: object) => void} */ const addRaidInfo = (device, info) => { - device.devices = buildCollection(info.devices, jsonDevices); + device.devices = buildCollectionFromNames(info.devices); }; /** @type {(device: StorageDevice, info: object) => void} */ const addMultipathInfo = (device, info) => { - device.wires = buildCollection(info.wires, jsonDevices); + device.wires = buildCollectionFromNames(info.wires); }; /** @type {(device: StorageDevice, info: object) => void} */ @@ -264,7 +280,7 @@ class DevicesManager { device.type = "md"; device.level = info.level; device.uuid = info.uuid; - addRaidInfo(device, info); + device.devices = buildCollection(info.devices, jsonDevices); }; /** @type {(device: StorageDevice, info: object) => void} */ @@ -282,7 +298,7 @@ class DevicesManager { }; /** @type {(device: StorageDevice, info: object) => void} */ - const addLvInfo = (device, info) => { + const addLvInfo = (device, _info) => { device.type = "lvmLv"; }; @@ -317,14 +333,7 @@ class DevicesManager { }; }; - /** @type {StorageDevice} */ - const device = { - sid: 0, - name: "", - description: "", - isDrive: false, - type: "" - }; + const device = buildDefaultDevice(); /** @type {(jsonProperty: String, info: function) => void} */ const process = (jsonProperty, method) => { diff --git a/web/src/client/storage.test.js b/web/src/client/storage.test.js index 512e0c844d..d8f4f7cf67 100644 --- a/web/src/client/storage.test.js +++ b/web/src/client/storage.test.js @@ -421,9 +421,39 @@ sdf1.component = { md0.devices = [sda1, sda2]; -raid.devices = [sdb, sdc]; - -multipath.wires = [sdd, sde]; +raid.devices = [ + { + sid: 0, + name: "/dev/sdb", + description: "", + isDrive: false, + type: "" + }, + { + sid: 0, + name: "/dev/sdc", + description: "", + isDrive: false, + type: "" + } +]; + +multipath.wires = [ + { + sid: 0, + name: "/dev/sdd", + description: "", + isDrive: false, + type: "" + }, + { + sid: 0, + name: "/dev/sde", + description: "", + isDrive: false, + type: "" + } +]; lvmVg.logicalVolumes = [lvmLv1]; lvmVg.physicalVolumes = [sdf1]; @@ -905,7 +935,7 @@ const contexts = { } }, raid: { - devices: [62, 63] + devices: ["/dev/sdb", "/dev/sdc"] } }, { @@ -938,7 +968,7 @@ const contexts = { } }, multipath: { - wires: [64, 65] + wires: ["/dev/sdd", "/dev/sde"] } }, { From a90adc0215afe704bc0eabbb75eb3b86359bfdf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Wed, 15 May 2024 13:52:27 +0100 Subject: [PATCH 5/6] service: Fix test --- service/test/agama/software/manager_test.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/service/test/agama/software/manager_test.rb b/service/test/agama/software/manager_test.rb index d338bc880f..5ea3a9bb6d 100644 --- a/service/test/agama/software/manager_test.rb +++ b/service/test/agama/software/manager_test.rb @@ -230,10 +230,9 @@ describe "#products" do it "returns the list of known products" do products = subject.products - expect(products.size).to eq(4) + expect(products.size).to eq(3) expect(products).to all(be_a(Agama::Software::Product)) expect(products).to contain_exactly( - an_object_having_attributes(id: "ALP-Dolomite"), an_object_having_attributes(id: "Tumbleweed"), an_object_having_attributes(id: "MicroOS"), an_object_having_attributes(id: "MicroOS-Desktop") From 4c1808ae3023d65753acbd49accaa814d35a10c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Wed, 15 May 2024 13:55:11 +0100 Subject: [PATCH 6/6] service: Changelog --- service/package/rubygem-agama-yast.changes | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/service/package/rubygem-agama-yast.changes b/service/package/rubygem-agama-yast.changes index adf9f9709d..ea1ca93e08 100644 --- a/service/package/rubygem-agama-yast.changes +++ b/service/package/rubygem-agama-yast.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Wed May 15 12:52:42 UTC 2024 - José Iván López González + +- Export the device name of the Multipath wires and RAID devices + instead of their D-Bus path (gh#openSUSE/agama#1212). + ------------------------------------------------------------------- Mon May 6 05:13:11 UTC 2024 - Imobach Gonzalez Sosa