From 0c364dd478e007b07ed1fca92738670f40c91bbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Tue, 20 Feb 2024 12:36:23 +0000 Subject: [PATCH] [service] Improve code for dynamically adding D-Bus interfaces --- service/lib/agama/dbus/storage/device.rb | 61 +------- service/lib/agama/dbus/storage/interfaces.rb | 12 +- .../agama/dbus/storage/interfaces/block.rb | 104 ------------- .../dbus/storage/interfaces/component.rb | 89 ----------- .../storage/interfaces/{raid.rb => device.rb} | 36 ++--- .../dbus/storage/interfaces/device/block.rb | 117 ++++++++++++++ .../storage/interfaces/device/component.rb | 97 ++++++++++++ .../dbus/storage/interfaces/device/drive.rb | 145 ++++++++++++++++++ .../storage/interfaces/device/filesystem.rb | 74 +++++++++ .../dbus/storage/interfaces/device/md.rb | 82 ++++++++++ .../storage/interfaces/device/multipath.rb | 66 ++++++++ .../interfaces/device/partition_table.rb | 76 +++++++++ .../dbus/storage/interfaces/device/raid.rb | 66 ++++++++ .../agama/dbus/storage/interfaces/drive.rb | 126 --------------- .../dbus/storage/interfaces/filesystem.rb | 61 -------- .../lib/agama/dbus/storage/interfaces/md.rb | 69 --------- .../dbus/storage/interfaces/multipath.rb | 53 ------- .../storage/interfaces/partition_table.rb | 61 -------- .../test/agama/dbus/storage/device_test.rb | 22 +-- .../interfaces/{ => device}/block_examples.rb | 4 +- .../{ => device}/component_examples.rb | 2 +- .../interfaces/{ => device}/drive_examples.rb | 4 +- .../{ => device}/filesystem_examples.rb | 2 +- .../interfaces/{ => device}/md_examples.rb | 2 +- .../{ => device}/multipath_examples.rb | 2 +- .../{ => device}/partition_table_examples.rb | 2 +- .../interfaces/{ => device}/raid_examples.rb | 2 +- 27 files changed, 765 insertions(+), 672 deletions(-) delete mode 100644 service/lib/agama/dbus/storage/interfaces/block.rb delete mode 100644 service/lib/agama/dbus/storage/interfaces/component.rb rename service/lib/agama/dbus/storage/interfaces/{raid.rb => device.rb} (52%) create mode 100644 service/lib/agama/dbus/storage/interfaces/device/block.rb create mode 100644 service/lib/agama/dbus/storage/interfaces/device/component.rb create mode 100644 service/lib/agama/dbus/storage/interfaces/device/drive.rb create mode 100644 service/lib/agama/dbus/storage/interfaces/device/filesystem.rb create mode 100644 service/lib/agama/dbus/storage/interfaces/device/md.rb create mode 100644 service/lib/agama/dbus/storage/interfaces/device/multipath.rb create mode 100644 service/lib/agama/dbus/storage/interfaces/device/partition_table.rb create mode 100644 service/lib/agama/dbus/storage/interfaces/device/raid.rb delete mode 100644 service/lib/agama/dbus/storage/interfaces/drive.rb delete mode 100644 service/lib/agama/dbus/storage/interfaces/filesystem.rb delete mode 100644 service/lib/agama/dbus/storage/interfaces/md.rb delete mode 100644 service/lib/agama/dbus/storage/interfaces/multipath.rb delete mode 100644 service/lib/agama/dbus/storage/interfaces/partition_table.rb rename service/test/agama/dbus/storage/interfaces/{ => device}/block_examples.rb (97%) rename service/test/agama/dbus/storage/interfaces/{ => device}/component_examples.rb (97%) rename service/test/agama/dbus/storage/interfaces/{ => device}/drive_examples.rb (98%) rename service/test/agama/dbus/storage/interfaces/{ => device}/filesystem_examples.rb (96%) rename service/test/agama/dbus/storage/interfaces/{ => device}/md_examples.rb (97%) rename service/test/agama/dbus/storage/interfaces/{ => device}/multipath_examples.rb (96%) rename service/test/agama/dbus/storage/interfaces/{ => device}/partition_table_examples.rb (96%) rename service/test/agama/dbus/storage/interfaces/{ => device}/raid_examples.rb (96%) diff --git a/service/lib/agama/dbus/storage/device.rb b/service/lib/agama/dbus/storage/device.rb index d4367c0457..4e1b07a206 100644 --- a/service/lib/agama/dbus/storage/device.rb +++ b/service/lib/agama/dbus/storage/device.rb @@ -21,14 +21,7 @@ require "dbus" require "agama/dbus/base_object" -require "agama/dbus/storage/interfaces/drive" -require "agama/dbus/storage/interfaces/raid" -require "agama/dbus/storage/interfaces/multipath" -require "agama/dbus/storage/interfaces/md" -require "agama/dbus/storage/interfaces/block" -require "agama/dbus/storage/interfaces/partition_table" -require "agama/dbus/storage/interfaces/filesystem" -require "agama/dbus/storage/interfaces/component" +require "agama/dbus/storage/interfaces/device" module Agama module DBus @@ -78,56 +71,14 @@ def storage_device=(value) # @return [DevicesTree] attr_reader :tree - # Adds the required interfaces according to the storage object - def add_interfaces # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity - interfaces = [] - interfaces << Interfaces::Drive if drive? - interfaces << Interfaces::Raid if storage_device.is?(:dm_raid) - interfaces << Interfaces::Md if storage_device.is?(:md) - interfaces << Interfaces::Multipath if storage_device.is?(:multipath) - interfaces << Interfaces::Block if storage_device.is?(:blk_device) - interfaces << Interfaces::PartitionTable if partition_table? - interfaces << Interfaces::Filesystem if filesystem? - interfaces << Interfaces::Component if component? + # Adds the required interfaces according to the storage object. + def add_interfaces + interfaces = Interfaces::Device.constants + .map { |c| Interfaces::Device.const_get(c) } + .select { |c| c.is_a?(Module) && c.respond_to?(:apply?) && c.apply?(storage_device) } interfaces.each { |i| singleton_class.include(i) } end - - # Whether the storage device is a drive - # - # Drive and disk device are very close concepts, but there are subtle differences. For - # example, a MD RAID is never considered as a drive. - # - # TODO: Revisit the defintion of drive. Maybe some MD devices could implement the drive - # interface if hwinfo provides useful information for them. - # - # @return [Boolean] - def drive? - storage_device.is?(:disk, :dm_raid, :multipath, :dasd) && storage_device.is?(:disk_device) - end - - # Whether the storage device has a partition table - # - # @return [Boolean] - def partition_table? - storage_device.is?(:blk_device) && - storage_device.respond_to?(:partition_table?) && - storage_device.partition_table? - end - - # Whether the storage device is formatted. - # - # @return [Boolean] - def filesystem? - storage_device.is?(:blk_device) && !storage_device.filesystem.nil? - end - - # Whether the storage device is component of other devices. - # - # @return [Boolean] - def component? - storage_device.is?(:blk_device) && storage_device.component_of.any? - end end end end diff --git a/service/lib/agama/dbus/storage/interfaces.rb b/service/lib/agama/dbus/storage/interfaces.rb index 7dac58df88..1c7b917c16 100644 --- a/service/lib/agama/dbus/storage/interfaces.rb +++ b/service/lib/agama/dbus/storage/interfaces.rb @@ -22,19 +22,13 @@ module Agama module DBus module Storage - # Module for storage specific D-Bus interfaces + # Module for D-Bus interfaces of storage. module Interfaces end end end end -require "agama/dbus/storage/interfaces/drive" -require "agama/dbus/storage/interfaces/raid" -require "agama/dbus/storage/interfaces/multipath" -require "agama/dbus/storage/interfaces/md" -require "agama/dbus/storage/interfaces/block" -require "agama/dbus/storage/interfaces/partition_table" -require "agama/dbus/storage/interfaces/filesystem" -require "agama/dbus/storage/interfaces/component" require "agama/dbus/storage/interfaces/dasd_manager" +require "agama/dbus/storage/interfaces/device" +require "agama/dbus/storage/interfaces/zfcp_manager" diff --git a/service/lib/agama/dbus/storage/interfaces/block.rb b/service/lib/agama/dbus/storage/interfaces/block.rb deleted file mode 100644 index 84648443f0..0000000000 --- a/service/lib/agama/dbus/storage/interfaces/block.rb +++ /dev/null @@ -1,104 +0,0 @@ -# frozen_string_literal: true - -# Copyright (c) [2023-2024] SUSE LLC -# -# All Rights Reserved. -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of version 2 of the GNU General Public License as published -# by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, contact SUSE LLC. -# -# To contact SUSE LLC about this file by physical or electronic mail, you may -# find current contact information at www.suse.com. - -require "dbus" - -module Agama - module DBus - module Storage - module Interfaces - # Interface for block devices - # - # @note This interface is intended to be included by {Device} if needed. - module Block - BLOCK_INTERFACE = "org.opensuse.Agama.Storage1.Block" - private_constant :BLOCK_INTERFACE - - # Name of the block device - # - # @return [String] e.g., "/dev/sda" - def block_name - storage_device.name - end - - # Whether the block device is currently active - # - # @return [Boolean] - def block_active - storage_device.active? - end - - # Name of the udev by-id links - # - # @return [Array] - def block_udev_ids - storage_device.udev_ids - end - - # Name of the udev by-path links - # - # @return [Array] - def block_udev_paths - storage_device.udev_paths - end - - # Size of the block device in bytes - # - # @return [Integer] - def block_size - storage_device.size.to_i - end - - # Size of the space that could be theoretically reclaimed by shrinking the device. - # - # @return [Integer] - def block_recoverable_size - storage_device.recoverable_size.to_i - end - - # Name of the currently installed systems - # - # @return [Array] - def block_systems - return @systems if @systems - - filesystems = storage_device.descendants.select { |d| d.is?(:filesystem) } - @systems = filesystems.map(&:system_name).compact - end - - def self.included(base) - base.class_eval do - dbus_interface BLOCK_INTERFACE do - dbus_reader :block_name, "s", dbus_name: "Name" - dbus_reader :block_active, "b", dbus_name: "Active" - dbus_reader :block_udev_ids, "as", dbus_name: "UdevIds" - dbus_reader :block_udev_paths, "as", dbus_name: "UdevPaths" - dbus_reader :block_size, "t", dbus_name: "Size" - dbus_reader :block_recoverable_size, "t", dbus_name: "RecoverableSize" - dbus_reader :block_systems, "as", dbus_name: "Systems" - end - end - end - end - end - end - end -end diff --git a/service/lib/agama/dbus/storage/interfaces/component.rb b/service/lib/agama/dbus/storage/interfaces/component.rb deleted file mode 100644 index 9a9a7ba9e4..0000000000 --- a/service/lib/agama/dbus/storage/interfaces/component.rb +++ /dev/null @@ -1,89 +0,0 @@ -# frozen_string_literal: true - -# Copyright (c) [2024] SUSE LLC -# -# All Rights Reserved. -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of version 2 of the GNU General Public License as published -# by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, contact SUSE LLC. -# -# To contact SUSE LLC about this file by physical or electronic mail, you may -# find current contact information at www.suse.com. - -require "dbus" - -module Agama - module DBus - module Storage - module Interfaces - # Interface for devices that are used as component of other device (e.g., physical volume, - # MD RAID device, etc). - # - # @note This interface is intended to be included by {Device} if needed. - module Component - COMPONENT_INTERFACE = "org.opensuse.Agama.Storage1.Component" - private_constant :COMPONENT_INTERFACE - - # Type of component. - # - # @return [String] Possible values: - # "physical_volume" - # "md_device" - # "raid_device" - # "multipath_wire" - # "bcache_device" - # "bcache_cset_device" - # "md_btrfs_device" - def component_type - types = { - lvm_vg: "physical_volume", - md: "md_device", - dm_raid: "raid_device", - multipath: "multipath_wire", - bcache: "bcache_device", - bcache_cset: "bcache_cset_device", - btrfs: "md_btrfs_device" - } - - device = storage_device.component_of.first - - types.find { |k, _v| device.is?(k) }&.last || "" - end - - # Name of the devices for which this device is component of. - # - # @return [Array] - def component_device_names - storage_device.component_of.map(&:display_name).compact - end - - # Paths of the D-Bus objects representing the devices. - # - # @return [Array<::DBus::ObjectPath>] - def component_devices - storage_device.component_of.map { |p| tree.path_for(p) } - end - - def self.included(base) - base.class_eval do - dbus_interface COMPONENT_INTERFACE do - dbus_reader :component_type, "s", dbus_name: "Type" - dbus_reader :component_device_names, "as", dbus_name: "DeviceNames" - dbus_reader :component_devices, "ao", dbus_name: "Devices" - end - end - end - end - end - end - end -end diff --git a/service/lib/agama/dbus/storage/interfaces/raid.rb b/service/lib/agama/dbus/storage/interfaces/device.rb similarity index 52% rename from service/lib/agama/dbus/storage/interfaces/raid.rb rename to service/lib/agama/dbus/storage/interfaces/device.rb index 7a66fb3556..98f09690c2 100644 --- a/service/lib/agama/dbus/storage/interfaces/raid.rb +++ b/service/lib/agama/dbus/storage/interfaces/device.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# Copyright (c) [2023-2024] SUSE LLC +# Copyright (c) [2024] SUSE LLC # # All Rights Reserved. # @@ -19,35 +19,23 @@ # To contact SUSE LLC about this file by physical or electronic mail, you may # find current contact information at www.suse.com. -require "dbus" - module Agama module DBus module Storage module Interfaces - # Interface for DM RAID devices - # - # @note This interface is intended to be included by {Device} if needed. - module Raid - 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. - # - # @return [Array] - def raid_devices - storage_device.parents.map { |p| tree.path_for(p) } - end - - def self.included(base) - base.class_eval do - dbus_interface RAID_INTERFACE do - dbus_reader :raid_devices, "ao", dbus_name: "Devices" - end - end - end + # Module for D-Bus interfaces of a device. + module Device end end end end end + +require "agama/dbus/storage/interfaces/device/block" +require "agama/dbus/storage/interfaces/device/component" +require "agama/dbus/storage/interfaces/device/drive" +require "agama/dbus/storage/interfaces/device/filesystem" +require "agama/dbus/storage/interfaces/device/md" +require "agama/dbus/storage/interfaces/device/multipath" +require "agama/dbus/storage/interfaces/device/partition_table" +require "agama/dbus/storage/interfaces/device/raid" diff --git a/service/lib/agama/dbus/storage/interfaces/device/block.rb b/service/lib/agama/dbus/storage/interfaces/device/block.rb new file mode 100644 index 0000000000..b5c0e00017 --- /dev/null +++ b/service/lib/agama/dbus/storage/interfaces/device/block.rb @@ -0,0 +1,117 @@ +# frozen_string_literal: true + +# Copyright (c) [2023-2024] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require "dbus" + +module Agama + module DBus + module Storage + module Interfaces + module Device + # Interface for block devices. + # + # @note This interface is intended to be included by {Agama::DBus::Storage::Device} if + # needed. + module Block + # Whether this interface should be implemented for the given device. + # + # @note Block devices implement this interface. + # + # @param storage_device [Y2Storage::Device] + # @return [Boolean] + def self.apply?(storage_device) + storage_device.is?(:blk_device) + end + + BLOCK_INTERFACE = "org.opensuse.Agama.Storage1.Block" + private_constant :BLOCK_INTERFACE + + # Name of the block device + # + # @return [String] e.g., "/dev/sda" + def block_name + storage_device.name + end + + # Whether the block device is currently active + # + # @return [Boolean] + def block_active + storage_device.active? + end + + # Name of the udev by-id links + # + # @return [Array] + def block_udev_ids + storage_device.udev_ids + end + + # Name of the udev by-path links + # + # @return [Array] + def block_udev_paths + storage_device.udev_paths + end + + # Size of the block device in bytes + # + # @return [Integer] + def block_size + storage_device.size.to_i + end + + # Size of the space that could be theoretically reclaimed by shrinking the device. + # + # @return [Integer] + def block_recoverable_size + storage_device.recoverable_size.to_i + end + + # Name of the currently installed systems + # + # @return [Array] + def block_systems + return @systems if @systems + + filesystems = storage_device.descendants.select { |d| d.is?(:filesystem) } + @systems = filesystems.map(&:system_name).compact + end + + def self.included(base) + base.class_eval do + dbus_interface BLOCK_INTERFACE do + dbus_reader :block_name, "s", dbus_name: "Name" + dbus_reader :block_active, "b", dbus_name: "Active" + dbus_reader :block_udev_ids, "as", dbus_name: "UdevIds" + dbus_reader :block_udev_paths, "as", dbus_name: "UdevPaths" + dbus_reader :block_size, "t", dbus_name: "Size" + dbus_reader :block_recoverable_size, "t", dbus_name: "RecoverableSize" + dbus_reader :block_systems, "as", dbus_name: "Systems" + end + end + end + end + end + end + end + end +end diff --git a/service/lib/agama/dbus/storage/interfaces/device/component.rb b/service/lib/agama/dbus/storage/interfaces/device/component.rb new file mode 100644 index 0000000000..6f96683b28 --- /dev/null +++ b/service/lib/agama/dbus/storage/interfaces/device/component.rb @@ -0,0 +1,97 @@ +# frozen_string_literal: true + +# Copyright (c) [2024] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require "dbus" + +module Agama + module DBus + module Storage + module Interfaces + module Device + # Interface for devices that are used as component of other device (e.g., physical volume, + # MD RAID device, etc). + # + # @note This interface is intended to be included by {Agama::DBus::Storage::Device} if + # needed. + module Component + # Whether this interface should be implemented for the given device. + # + # @note Components of other devices implement this interface. + # + # @param storage_device [Y2Storage::Device] + # @return [Boolean] + def self.apply?(storage_device) + storage_device.is?(:blk_device) && storage_device.component_of.any? + end + + COMPONENT_INTERFACE = "org.opensuse.Agama.Storage1.Component" + private_constant :COMPONENT_INTERFACE + + # Type of component. + # + # @return ["physical_volume", "md_device", "raid_device", "multipath_wire", + # "bcache_device", "bcache_cset_device", "md_btrfs_device", ""] Empty if type is type + # is unknown. + def component_type + types = { + lvm_vg: "physical_volume", + md: "md_device", + dm_raid: "raid_device", + multipath: "multipath_wire", + bcache: "bcache_device", + bcache_cset: "bcache_cset_device", + btrfs: "md_btrfs_device" + } + + device = storage_device.component_of.first + + types.find { |k, _v| device.is?(k) }&.last || "" + end + + # Name of the devices for which this device is component of. + # + # @return [Array] + def component_device_names + storage_device.component_of.map(&:display_name).compact + end + + # Paths of the D-Bus objects representing the devices. + # + # @return [Array<::DBus::ObjectPath>] + def component_devices + storage_device.component_of.map { |p| tree.path_for(p) } + end + + def self.included(base) + base.class_eval do + dbus_interface COMPONENT_INTERFACE do + dbus_reader :component_type, "s", dbus_name: "Type" + dbus_reader :component_device_names, "as", dbus_name: "DeviceNames" + dbus_reader :component_devices, "ao", dbus_name: "Devices" + end + end + end + end + end + end + end + end +end diff --git a/service/lib/agama/dbus/storage/interfaces/device/drive.rb b/service/lib/agama/dbus/storage/interfaces/device/drive.rb new file mode 100644 index 0000000000..0466ad7984 --- /dev/null +++ b/service/lib/agama/dbus/storage/interfaces/device/drive.rb @@ -0,0 +1,145 @@ +# frozen_string_literal: true + +# Copyright (c) [2023-2024] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require "dbus" + +module Agama + module DBus + module Storage + module Interfaces + module Device + # Interface for drive devices. + # + # @note This interface is intended to be included by {Agama::DBus::Storage::Device} if + # needed. + module Drive + # Whether this interface should be implemented for the given device. + # + # @note Drive devices implement this interface. + # Drive and disk device are very close concepts, but there are subtle differences. For + # example, a MD RAID is never considered as a drive. + # + # TODO: Revisit the defintion of drive. Maybe some MD devices could implement the drive + # interface if hwinfo provides useful information for them. + # + # @param storage_device [Y2Storage::Device] + # @return [Boolean] + def self.apply?(storage_device) + storage_device.is?(:disk, :dm_raid, :multipath, :dasd) && + storage_device.is?(:disk_device) + end + + DRIVE_INTERFACE = "org.opensuse.Agama.Storage1.Drive" + private_constant :DRIVE_INTERFACE + + # Drive type + # + # @return ["disk", "raid", "multipath", "dasd", ""] Empty if type is unknown. + def drive_type + if storage_device.is?(:disk) + "disk" + elsif storage_device.is?(:dm_raid) + "raid" + elsif storage_device.is?(:multipath) + "multipath" + elsif storage_device.is?(:dasd) + "dasd" + else + "" + end + end + + # Vendor name + # + # @return [String] + def drive_vendor + storage_device.vendor || "" + end + + # Model name + # + # @return [String] + def drive_model + storage_device.model || "" + end + + # Bus name + # + # @return [String] + def drive_bus + storage_device.bus || "" + end + + # Bus Id for DASD + # + # @return [String] + def drive_bus_id + return "" unless storage_device.respond_to?(:bus_id) + + storage_device.bus_id + end + + # Kernel drivers used by the device + # + # @return [Array] + def drive_driver + storage_device.driver + end + + # Data transport layer, if any + # + # @return [String] + def drive_transport + return "" unless storage_device.respond_to?(:transport) + + storage_device.transport.to_s + end + + # More info about the device + # + # @return [Hash] + def drive_info + { + "SDCard" => storage_device.sd_card?, + "DellBOSS" => storage_device.boss? + } + end + + def self.included(base) + base.class_eval do + dbus_interface DRIVE_INTERFACE do + dbus_reader :drive_type, "s", dbus_name: "Type" + dbus_reader :drive_vendor, "s", dbus_name: "Vendor" + dbus_reader :drive_model, "s", dbus_name: "Model" + dbus_reader :drive_bus, "s", dbus_name: "Bus" + dbus_reader :drive_bus_id, "s", dbus_name: "BusId" + dbus_reader :drive_driver, "as", dbus_name: "Driver" + dbus_reader :drive_transport, "s", dbus_name: "Transport" + dbus_reader :drive_info, "a{sv}", dbus_name: "Info" + end + end + end + end + end + end + end + end +end diff --git a/service/lib/agama/dbus/storage/interfaces/device/filesystem.rb b/service/lib/agama/dbus/storage/interfaces/device/filesystem.rb new file mode 100644 index 0000000000..36ee17c2ea --- /dev/null +++ b/service/lib/agama/dbus/storage/interfaces/device/filesystem.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true + +# Copyright (c) [2024] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require "dbus" + +module Agama + module DBus + module Storage + module Interfaces + module Device + # Interface for file systems. + # + # @note This interface is intended to be included by {Agama::DBus::Storage::Device} if + # needed. + module Filesystem + # Whether this interface should be implemented for the given device. + # + # @note Formatted devices implement this interface. + # + # @param storage_device [Y2Storage::Device] + # @return [Boolean] + def self.apply?(storage_device) + storage_device.is?(:blk_device) && !storage_device.filesystem.nil? + end + + FILESYSTEM_INTERFACE = "org.opensuse.Agama.Storage1.Filesystem" + private_constant :FILESYSTEM_INTERFACE + + # File system type. + # + # @return [String] e.g., "ext4" + def filesystem_type + storage_device.filesystem.type.to_s + end + + # Whether the filesystem contains the directory layout of an ESP partition. + # + # @return [Boolean] + def filesystem_efi? + storage_device.filesystem.efi? + end + + def self.included(base) + base.class_eval do + dbus_interface FILESYSTEM_INTERFACE do + dbus_reader :filesystem_type, "s", dbus_name: "Type" + dbus_reader :filesystem_efi?, "b", dbus_name: "EFI" + end + end + end + end + end + end + end + end +end diff --git a/service/lib/agama/dbus/storage/interfaces/device/md.rb b/service/lib/agama/dbus/storage/interfaces/device/md.rb new file mode 100644 index 0000000000..6cf144489d --- /dev/null +++ b/service/lib/agama/dbus/storage/interfaces/device/md.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true + +# Copyright (c) [2023-2024] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require "dbus" + +module Agama + module DBus + module Storage + module Interfaces + module Device + # Interface for MD RAID devices. + # + # @note This interface is intended to be included by {Agama::DBus::Storage::Device} if + # needed. + module Md + # Whether this interface should be implemented for the given device. + # + # @note MD RAIDs implement this interface. + # + # @param storage_device [Y2Storage::Device] + # @return [Boolean] + def self.apply?(storage_device) + storage_device.is?(:md) + end + + MD_INTERFACE = "org.opensuse.Agama.Storage1.MD" + private_constant :MD_INTERFACE + + # UUID of the MD RAID + # + # @return [String] + def md_uuid + storage_device.uuid + end + + # RAID level + # + # @return [String] + def md_level + storage_device.md_level.to_s + end + + # Paths of the D-Bus objects representing the devices of the MD RAID. + # + # @return [Array] + def md_devices + storage_device.plain_devices.map { |p| tree.path_for(p) } + end + + def self.included(base) + base.class_eval do + dbus_interface MD_INTERFACE do + dbus_reader :md_uuid, "s", dbus_name: "UUID" + dbus_reader :md_level, "s", dbus_name: "Level" + dbus_reader :md_devices, "ao", dbus_name: "Devices" + end + end + end + end + end + end + end + end +end diff --git a/service/lib/agama/dbus/storage/interfaces/device/multipath.rb b/service/lib/agama/dbus/storage/interfaces/device/multipath.rb new file mode 100644 index 0000000000..3293ed376d --- /dev/null +++ b/service/lib/agama/dbus/storage/interfaces/device/multipath.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true + +# Copyright (c) [2023-2024] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require "dbus" + +module Agama + module DBus + module Storage + module Interfaces + module Device + # Interface for Multipath devices. + # + # @note This interface is intended to be included by {Agama::DBus::Storage::Device} if + # needed. + module Multipath + # Whether this interface should be implemented for the given device. + # + # @note Multipath devices implement this interface. + # + # @param storage_device [Y2Storage::Device] + # @return [Boolean] + def self.apply?(storage_device) + storage_device.is?(:multipath) + end + + MULTIPATH_INTERFACE = "org.opensuse.Agama.Storage1.Multipath" + private_constant :MULTIPATH_INTERFACE + + # Paths of the D-Bus objects representing the multipath wires. + # + # @return [Array] + def multipath_wires + storage_device.parents.map { |p| tree.path_for(p) } + end + + def self.included(base) + base.class_eval do + dbus_interface MULTIPATH_INTERFACE do + dbus_reader :multipath_wires, "ao", dbus_name: "Wires" + end + end + end + end + end + end + end + end +end diff --git a/service/lib/agama/dbus/storage/interfaces/device/partition_table.rb b/service/lib/agama/dbus/storage/interfaces/device/partition_table.rb new file mode 100644 index 0000000000..546ddfd934 --- /dev/null +++ b/service/lib/agama/dbus/storage/interfaces/device/partition_table.rb @@ -0,0 +1,76 @@ +# frozen_string_literal: true + +# Copyright (c) [2023-2024] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require "dbus" + +module Agama + module DBus + module Storage + module Interfaces + module Device + # Interface for devices that contain a partition table. + # + # @note This interface is intended to be included by {Agama::DBus::Storage::Device} if + # needed. + module PartitionTable + # Whether this interface should be implemented for the given device. + # + # @note Devices containing a partition table implement this interface. + # + # @param storage_device [Y2Storage::Device] + # @return [Boolean] + def self.apply?(storage_device) + storage_device.is?(:blk_device) && + storage_device.respond_to?(:partition_table?) && + storage_device.partition_table? + end + + PARTITION_TABLE_INTERFACE = "org.opensuse.Agama.Storage1.PartitionTable" + private_constant :PARTITION_TABLE_INTERFACE + + # Type of the partition table + # + # @return [String] + def partition_table_type + storage_device.partition_table.type.to_s + end + + # Paths of the D-Bus objects representing the partitions. + # + # @return [Array<::DBus::ObjectPath>] + def partition_table_partitions + storage_device.partition_table.partitions.map { |p| tree.path_for(p) } + end + + def self.included(base) + base.class_eval do + dbus_interface PARTITION_TABLE_INTERFACE do + dbus_reader :partition_table_type, "s", dbus_name: "Type" + dbus_reader :partition_table_partitions, "ao", dbus_name: "Partitions" + end + end + end + end + end + end + 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 new file mode 100644 index 0000000000..228e389c4b --- /dev/null +++ b/service/lib/agama/dbus/storage/interfaces/device/raid.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true + +# Copyright (c) [2023-2024] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require "dbus" + +module Agama + module DBus + module Storage + module Interfaces + module Device + # Interface for DM RAID devices. + # + # @note This interface is intended to be included by {Agama::DBus::Storage::Device} if + # needed. + module Raid + # Whether this interface should be implemented for the given device. + # + # @note DM RAIDs implement this interface. + # + # @param storage_device [Y2Storage::Device] + # @return [Boolean] + def self.apply?(storage_device) + storage_device.is?(:dm_raid) + end + + 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. + # + # @return [Array] + def raid_devices + storage_device.parents.map { |p| tree.path_for(p) } + end + + def self.included(base) + base.class_eval do + dbus_interface RAID_INTERFACE do + dbus_reader :raid_devices, "ao", dbus_name: "Devices" + end + end + end + end + end + end + end + end +end diff --git a/service/lib/agama/dbus/storage/interfaces/drive.rb b/service/lib/agama/dbus/storage/interfaces/drive.rb deleted file mode 100644 index 6d87ef33a4..0000000000 --- a/service/lib/agama/dbus/storage/interfaces/drive.rb +++ /dev/null @@ -1,126 +0,0 @@ -# frozen_string_literal: true - -# Copyright (c) [2023] SUSE LLC -# -# All Rights Reserved. -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of version 2 of the GNU General Public License as published -# by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, contact SUSE LLC. -# -# To contact SUSE LLC about this file by physical or electronic mail, you may -# find current contact information at www.suse.com. - -require "dbus" - -module Agama - module DBus - module Storage - module Interfaces - # Interface for drive devices - # - # @note This interface is intended to be included by {Device} if needed. - module Drive - DRIVE_INTERFACE = "org.opensuse.Agama.Storage1.Drive" - private_constant :DRIVE_INTERFACE - - # Drive type - # - # @return ["disk", "raid", "multipath", "dasd"] - def drive_type - if storage_device.is?(:disk) - "disk" - elsif storage_device.is?(:dm_raid) - "raid" - elsif storage_device.is?(:multipath) - "multipath" - elsif storage_device.is?(:dasd) - "dasd" - else - "" - end - end - - # Vendor name - # - # @return [String] - def drive_vendor - storage_device.vendor || "" - end - - # Model name - # - # @return [String] - def drive_model - storage_device.model || "" - end - - # Bus name - # - # @return [String] - def drive_bus - storage_device.bus || "" - end - - # Bus Id for DASD - # - # @return [String] - def drive_bus_id - return "" unless storage_device.respond_to?(:bus_id) - - storage_device.bus_id - end - - # Kernel drivers used by the device - # - # @return [Array] - def drive_driver - storage_device.driver - end - - # Data transport layer, if any - # - # @return [String] - def drive_transport - return "" unless storage_device.respond_to?(:transport) - - storage_device.transport.to_s - end - - # More info about the device - # - # @return [Hash] - def drive_info - { - "SDCard" => storage_device.sd_card?, - "DellBOSS" => storage_device.boss? - } - end - - def self.included(base) - base.class_eval do - dbus_interface DRIVE_INTERFACE do - dbus_reader :drive_type, "s", dbus_name: "Type" - dbus_reader :drive_vendor, "s", dbus_name: "Vendor" - dbus_reader :drive_model, "s", dbus_name: "Model" - dbus_reader :drive_bus, "s", dbus_name: "Bus" - dbus_reader :drive_bus_id, "s", dbus_name: "BusId" - dbus_reader :drive_driver, "as", dbus_name: "Driver" - dbus_reader :drive_transport, "s", dbus_name: "Transport" - dbus_reader :drive_info, "a{sv}", dbus_name: "Info" - end - end - end - end - end - end - end -end diff --git a/service/lib/agama/dbus/storage/interfaces/filesystem.rb b/service/lib/agama/dbus/storage/interfaces/filesystem.rb deleted file mode 100644 index 51e69d0a39..0000000000 --- a/service/lib/agama/dbus/storage/interfaces/filesystem.rb +++ /dev/null @@ -1,61 +0,0 @@ -# frozen_string_literal: true - -# Copyright (c) [2024] SUSE LLC -# -# All Rights Reserved. -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of version 2 of the GNU General Public License as published -# by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, contact SUSE LLC. -# -# To contact SUSE LLC about this file by physical or electronic mail, you may -# find current contact information at www.suse.com. - -require "dbus" - -module Agama - module DBus - module Storage - module Interfaces - # Interface for file systems. - # - # @note This interface is intended to be included by {Device} if needed. - module Filesystem - FILESYSTEM_INTERFACE = "org.opensuse.Agama.Storage1.Filesystem" - private_constant :FILESYSTEM_INTERFACE - - # File system type. - # - # @return [String] e.g., "ext4" - def filesystem_type - storage_device.filesystem.type.to_s - end - - # Whether the file system contains an EFI. - # - # @return [Boolean] - def filesystem_efi? - storage_device.filesystem.efi? - end - - def self.included(base) - base.class_eval do - dbus_interface FILESYSTEM_INTERFACE do - dbus_reader :filesystem_type, "s", dbus_name: "Type" - dbus_reader :filesystem_efi?, "b", dbus_name: "EFI" - end - end - end - end - end - end - end -end diff --git a/service/lib/agama/dbus/storage/interfaces/md.rb b/service/lib/agama/dbus/storage/interfaces/md.rb deleted file mode 100644 index 8bc996c4b2..0000000000 --- a/service/lib/agama/dbus/storage/interfaces/md.rb +++ /dev/null @@ -1,69 +0,0 @@ -# frozen_string_literal: true - -# Copyright (c) [2023-2024] SUSE LLC -# -# All Rights Reserved. -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of version 2 of the GNU General Public License as published -# by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, contact SUSE LLC. -# -# To contact SUSE LLC about this file by physical or electronic mail, you may -# find current contact information at www.suse.com. - -require "dbus" - -module Agama - module DBus - module Storage - module Interfaces - # Interface for MD RAID devices - # - # @note This interface is intended to be included by {Device} if needed. - module Md - MD_INTERFACE = "org.opensuse.Agama.Storage1.MD" - private_constant :MD_INTERFACE - - # UUID of the MD RAID - # - # @return [String] - def md_uuid - storage_device.uuid - end - - # RAID level - # - # @return [String] - def md_level - storage_device.md_level.to_s - end - - # Paths of the D-Bus objects representing the devices of the MD RAID. - # - # @return [Array] - def md_devices - storage_device.plain_devices.map { |p| tree.path_for(p) } - end - - def self.included(base) - base.class_eval do - dbus_interface MD_INTERFACE do - dbus_reader :md_uuid, "s", dbus_name: "UUID" - dbus_reader :md_level, "s", dbus_name: "Level" - dbus_reader :md_devices, "ao", dbus_name: "Devices" - end - end - end - end - end - end - end -end diff --git a/service/lib/agama/dbus/storage/interfaces/multipath.rb b/service/lib/agama/dbus/storage/interfaces/multipath.rb deleted file mode 100644 index 06841520da..0000000000 --- a/service/lib/agama/dbus/storage/interfaces/multipath.rb +++ /dev/null @@ -1,53 +0,0 @@ -# frozen_string_literal: true - -# Copyright (c) [2023-2024] SUSE LLC -# -# All Rights Reserved. -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of version 2 of the GNU General Public License as published -# by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, contact SUSE LLC. -# -# To contact SUSE LLC about this file by physical or electronic mail, you may -# find current contact information at www.suse.com. - -require "dbus" - -module Agama - module DBus - module Storage - module Interfaces - # Interface for Multipath devices - # - # @note This interface is intended to be included by {Device} if needed. - module Multipath - MULTIPATH_INTERFACE = "org.opensuse.Agama.Storage1.Multipath" - private_constant :MULTIPATH_INTERFACE - - # Paths of the D-Bus objects representing the multipath wires. - # - # @return [Array] - def multipath_wires - storage_device.parents.map { |p| tree.path_for(p) } - end - - def self.included(base) - base.class_eval do - dbus_interface MULTIPATH_INTERFACE do - dbus_reader :multipath_wires, "ao", dbus_name: "Wires" - end - end - end - end - end - end - end -end diff --git a/service/lib/agama/dbus/storage/interfaces/partition_table.rb b/service/lib/agama/dbus/storage/interfaces/partition_table.rb deleted file mode 100644 index 635a331984..0000000000 --- a/service/lib/agama/dbus/storage/interfaces/partition_table.rb +++ /dev/null @@ -1,61 +0,0 @@ -# frozen_string_literal: true - -# Copyright (c) [2023-2024] SUSE LLC -# -# All Rights Reserved. -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of version 2 of the GNU General Public License as published -# by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -# more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, contact SUSE LLC. -# -# To contact SUSE LLC about this file by physical or electronic mail, you may -# find current contact information at www.suse.com. - -require "dbus" - -module Agama - module DBus - module Storage - module Interfaces - # Interface for devices that contain a partition table - # - # @note This interface is intended to be included by {Device} if needed. - module PartitionTable - PARTITION_TABLE_INTERFACE = "org.opensuse.Agama.Storage1.PartitionTable" - private_constant :PARTITION_TABLE_INTERFACE - - # Type of the partition table - # - # @return [String] - def partition_table_type - storage_device.partition_table.type.to_s - end - - # Paths of the D-Bus objects representing the partitions. - # - # @return [Array<::DBus::ObjectPath>] - def partition_table_partitions - storage_device.partition_table.partitions.map { |p| tree.path_for(p) } - end - - def self.included(base) - base.class_eval do - dbus_interface PARTITION_TABLE_INTERFACE do - dbus_reader :partition_table_type, "s", dbus_name: "Type" - dbus_reader :partition_table_partitions, "ao", dbus_name: "Partitions" - end - end - end - end - end - end - end -end diff --git a/service/test/agama/dbus/storage/device_test.rb b/service/test/agama/dbus/storage/device_test.rb index 63cf459b0e..649131a83f 100644 --- a/service/test/agama/dbus/storage/device_test.rb +++ b/service/test/agama/dbus/storage/device_test.rb @@ -19,19 +19,19 @@ # To contact SUSE LLC about this file by physical or electronic mail, you may # find current contact information at www.suse.com. -require_relative "../../../test_helper" -require_relative "../../storage/storage_helpers" -require_relative "./interfaces/drive_examples" -require_relative "./interfaces/raid_examples" -require_relative "./interfaces/multipath_examples" -require_relative "./interfaces/block_examples" -require_relative "./interfaces/md_examples" -require_relative "./interfaces/partition_table_examples" -require_relative "./interfaces/filesystem_examples" -require_relative "./interfaces/component_examples" require "agama/dbus/storage/device" require "agama/dbus/storage/devices_tree" require "dbus" +require_relative "../../../test_helper" +require_relative "../../storage/storage_helpers" +require_relative "./interfaces/device/block_examples" +require_relative "./interfaces/device/component_examples" +require_relative "./interfaces/device/drive_examples" +require_relative "./interfaces/device/filesystem_examples" +require_relative "./interfaces/device/md_examples" +require_relative "./interfaces/device/multipath_examples" +require_relative "./interfaces/device/partition_table_examples" +require_relative "./interfaces/device/raid_examples" describe Agama::DBus::Storage::Device do include Agama::RSpec::StorageHelpers @@ -101,7 +101,7 @@ expect(subject).to_not include_dbus_interface("org.opensuse.Agama.Storage1.Drive") end - it "defines the RAID interface" do + it "defines the MD interface" do expect(subject).to include_dbus_interface("org.opensuse.Agama.Storage1.MD") end diff --git a/service/test/agama/dbus/storage/interfaces/block_examples.rb b/service/test/agama/dbus/storage/interfaces/device/block_examples.rb similarity index 97% rename from service/test/agama/dbus/storage/interfaces/block_examples.rb rename to service/test/agama/dbus/storage/interfaces/device/block_examples.rb index 5922038a3f..11590a3390 100644 --- a/service/test/agama/dbus/storage/interfaces/block_examples.rb +++ b/service/test/agama/dbus/storage/interfaces/device/block_examples.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# Copyright (c) [2023] SUSE LLC +# Copyright (c) [2023-2024] SUSE LLC # # All Rights Reserved. # @@ -19,7 +19,7 @@ # To contact SUSE LLC about this file by physical or electronic mail, you may # find current contact information at www.suse.com. -require_relative "../../../../test_helper" +require_relative "../../../../../test_helper" shared_examples "Block interface" do describe "Block D-Bus interface" do diff --git a/service/test/agama/dbus/storage/interfaces/component_examples.rb b/service/test/agama/dbus/storage/interfaces/device/component_examples.rb similarity index 97% rename from service/test/agama/dbus/storage/interfaces/component_examples.rb rename to service/test/agama/dbus/storage/interfaces/device/component_examples.rb index 60b7f4aad1..c7ea69f495 100644 --- a/service/test/agama/dbus/storage/interfaces/component_examples.rb +++ b/service/test/agama/dbus/storage/interfaces/device/component_examples.rb @@ -19,7 +19,7 @@ # To contact SUSE LLC about this file by physical or electronic mail, you may # find current contact information at www.suse.com. -require_relative "../../../../test_helper" +require_relative "../../../../../test_helper" shared_examples "Component interface" do describe "Component D-Bus interface" do diff --git a/service/test/agama/dbus/storage/interfaces/drive_examples.rb b/service/test/agama/dbus/storage/interfaces/device/drive_examples.rb similarity index 98% rename from service/test/agama/dbus/storage/interfaces/drive_examples.rb rename to service/test/agama/dbus/storage/interfaces/device/drive_examples.rb index f27e243012..62595298c4 100644 --- a/service/test/agama/dbus/storage/interfaces/drive_examples.rb +++ b/service/test/agama/dbus/storage/interfaces/device/drive_examples.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# Copyright (c) [2023] SUSE LLC +# Copyright (c) [2023-2024] SUSE LLC # # All Rights Reserved. # @@ -19,7 +19,7 @@ # To contact SUSE LLC about this file by physical or electronic mail, you may # find current contact information at www.suse.com. -require_relative "../../../../test_helper" +require_relative "../../../../../test_helper" require "y2storage/disk_size" shared_examples "Drive interface" do diff --git a/service/test/agama/dbus/storage/interfaces/filesystem_examples.rb b/service/test/agama/dbus/storage/interfaces/device/filesystem_examples.rb similarity index 96% rename from service/test/agama/dbus/storage/interfaces/filesystem_examples.rb rename to service/test/agama/dbus/storage/interfaces/device/filesystem_examples.rb index f2323e662c..c581bd7668 100644 --- a/service/test/agama/dbus/storage/interfaces/filesystem_examples.rb +++ b/service/test/agama/dbus/storage/interfaces/device/filesystem_examples.rb @@ -19,7 +19,7 @@ # To contact SUSE LLC about this file by physical or electronic mail, you may # find current contact information at www.suse.com. -require_relative "../../../../test_helper" +require_relative "../../../../../test_helper" shared_examples "Filesystem interface" do describe "Filesystem D-Bus interface" do diff --git a/service/test/agama/dbus/storage/interfaces/md_examples.rb b/service/test/agama/dbus/storage/interfaces/device/md_examples.rb similarity index 97% rename from service/test/agama/dbus/storage/interfaces/md_examples.rb rename to service/test/agama/dbus/storage/interfaces/device/md_examples.rb index bc04dbc7c4..a8fd1d1711 100644 --- a/service/test/agama/dbus/storage/interfaces/md_examples.rb +++ b/service/test/agama/dbus/storage/interfaces/device/md_examples.rb @@ -19,7 +19,7 @@ # To contact SUSE LLC about this file by physical or electronic mail, you may # find current contact information at www.suse.com. -require_relative "../../../../test_helper" +require_relative "../../../../../test_helper" shared_examples "MD interface" do describe "MD D-Bus interface" do diff --git a/service/test/agama/dbus/storage/interfaces/multipath_examples.rb b/service/test/agama/dbus/storage/interfaces/device/multipath_examples.rb similarity index 96% rename from service/test/agama/dbus/storage/interfaces/multipath_examples.rb rename to service/test/agama/dbus/storage/interfaces/device/multipath_examples.rb index f134a06872..ddf59a7d73 100644 --- a/service/test/agama/dbus/storage/interfaces/multipath_examples.rb +++ b/service/test/agama/dbus/storage/interfaces/device/multipath_examples.rb @@ -19,7 +19,7 @@ # To contact SUSE LLC about this file by physical or electronic mail, you may # find current contact information at www.suse.com. -require_relative "../../../../test_helper" +require_relative "../../../../../test_helper" shared_examples "Multipath interface" do describe "Multipath D-Bus interface" do diff --git a/service/test/agama/dbus/storage/interfaces/partition_table_examples.rb b/service/test/agama/dbus/storage/interfaces/device/partition_table_examples.rb similarity index 96% rename from service/test/agama/dbus/storage/interfaces/partition_table_examples.rb rename to service/test/agama/dbus/storage/interfaces/device/partition_table_examples.rb index a902e3dbda..1af30111ab 100644 --- a/service/test/agama/dbus/storage/interfaces/partition_table_examples.rb +++ b/service/test/agama/dbus/storage/interfaces/device/partition_table_examples.rb @@ -19,7 +19,7 @@ # To contact SUSE LLC about this file by physical or electronic mail, you may # find current contact information at www.suse.com. -require_relative "../../../../test_helper" +require_relative "../../../../../test_helper" shared_examples "PartitionTable interface" do describe "PartitionTable D-Bus interface" do diff --git a/service/test/agama/dbus/storage/interfaces/raid_examples.rb b/service/test/agama/dbus/storage/interfaces/device/raid_examples.rb similarity index 96% rename from service/test/agama/dbus/storage/interfaces/raid_examples.rb rename to service/test/agama/dbus/storage/interfaces/device/raid_examples.rb index 4a30d575d2..7b53df1978 100644 --- a/service/test/agama/dbus/storage/interfaces/raid_examples.rb +++ b/service/test/agama/dbus/storage/interfaces/device/raid_examples.rb @@ -19,7 +19,7 @@ # To contact SUSE LLC about this file by physical or electronic mail, you may # find current contact information at www.suse.com. -require_relative "../../../../test_helper" +require_relative "../../../../../test_helper" shared_examples "RAID interface" do describe "RAID D-Bus interface" do