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, } 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/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/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 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 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 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") 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"] } }, {