-
Notifications
You must be signed in to change notification settings - Fork 68
Extend storage D-Bus API #1082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
joseivanlopez
merged 6 commits into
agama-project:storage-ui
from
joseivanlopez:extend-storage-dbus2
Mar 8, 2024
Merged
Extend storage D-Bus API #1082
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1ba7c2b
service: Add Device interface
joseivanlopez f94680d
service: Add Partition interface
joseivanlopez d2ce25e
service: Adapt Filesystem interface
joseivanlopez 19f769a
service: Update dependency
joseivanlopez ba93043
service: Use display_name
joseivanlopez aa1e7a3
service: Add LogicalVolume interface
joseivanlopez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
service/lib/agama/dbus/storage/interfaces/device/device.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| # 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" | ||
| require "y2storage/device_description" | ||
|
|
||
| module Agama | ||
| module DBus | ||
| module Storage | ||
| module Interfaces | ||
| module Device | ||
| # Interface for a device. | ||
| # | ||
| # @note This interface is intended to be included by {Agama::DBus::Storage::Device}. | ||
| module Device | ||
| # Whether this interface should be implemented for the given device. | ||
| # | ||
| # @note All devices implement this interface. | ||
| # | ||
| # @param _storage_device [Y2Storage::Device] | ||
| # @return [Boolean] | ||
| def self.apply?(_storage_device) | ||
| true | ||
| end | ||
|
|
||
| DEVICE_INTERFACE = "org.opensuse.Agama.Storage1.Device" | ||
| private_constant :DEVICE_INTERFACE | ||
|
|
||
| # sid of the device. | ||
| # | ||
| # @return [Integer] | ||
| def device_sid | ||
| storage_device.sid | ||
| end | ||
|
|
||
| # Name to represent the device. | ||
| # | ||
| # @return [String] e.g., "/dev/sda". | ||
| def device_name | ||
| storage_device.display_name || "" | ||
| end | ||
|
|
||
| # Description of the device. | ||
| # | ||
| # @return [String] e.g., "EXT4 Partition". | ||
| def device_description | ||
| Y2Storage::DeviceDescription.new(storage_device).to_s | ||
| end | ||
|
|
||
| def self.included(base) | ||
| base.class_eval do | ||
| dbus_interface DEVICE_INTERFACE do | ||
| dbus_reader :device_sid, "u", dbus_name: "SID" | ||
| dbus_reader :device_name, "s", dbus_name: "Name" | ||
| dbus_reader :device_description, "s", dbus_name: "Description" | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
service/lib/agama/dbus/storage/interfaces/device/lvm_lv.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # 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 LVM logical volume. | ||
| # | ||
| # @note This interface is intended to be included by {Agama::DBus::Storage::Device} if | ||
| # needed. | ||
| module LvmLv | ||
| # Whether this interface should be implemented for the given device. | ||
| # | ||
| # @note LVM logical volumes implement this interface. | ||
| # | ||
| # @param storage_device [Y2Storage::Device] | ||
| # @return [Boolean] | ||
| def self.apply?(storage_device) | ||
| storage_device.is?(:lvm_lv) | ||
| end | ||
|
|
||
| LOGICAL_VOLUME_INTERFACE = "org.opensuse.Agama.Storage1.LVM.LogicalVolume" | ||
| private_constant :LOGICAL_VOLUME_INTERFACE | ||
|
|
||
| # LVM volume group hosting the this logical volume. | ||
| # | ||
| # @return [Array<::DBus::ObjectPath>] | ||
| def lvm_lv_vg | ||
| tree.path_for(storage_device.lvm_vg) | ||
| end | ||
|
|
||
| def self.included(base) | ||
| base.class_eval do | ||
| dbus_interface LOGICAL_VOLUME_INTERFACE do | ||
| dbus_reader :lvm_lv_vg, "o", dbus_name: "VolumeGroup" | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
service/lib/agama/dbus/storage/interfaces/device/partition.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 partition. | ||
| # | ||
| # @note This interface is intended to be included by {Agama::DBus::Storage::Device} if | ||
| # needed. | ||
| module Partition | ||
| # Whether this interface should be implemented for the given device. | ||
| # | ||
| # @note Partitions implement this interface. | ||
| # | ||
| # @param storage_device [Y2Storage::Device] | ||
| # @return [Boolean] | ||
| def self.apply?(storage_device) | ||
| storage_device.is?(:partition) | ||
| end | ||
|
|
||
| PARTITION_INTERFACE = "org.opensuse.Agama.Storage1.Partition" | ||
| private_constant :PARTITION_INTERFACE | ||
|
|
||
| # Device hosting the partition table of this partition. | ||
| # | ||
| # @return [Array<::DBus::ObjectPath>] | ||
| def partition_device | ||
| tree.path_for(storage_device.partitionable) | ||
| end | ||
|
|
||
| # Whether it is a (valid) EFI System partition | ||
| # | ||
| # @return [Boolean] | ||
| def partition_efi | ||
| storage_device.efi_system? | ||
| end | ||
|
|
||
| def self.included(base) | ||
| base.class_eval do | ||
| dbus_interface PARTITION_INTERFACE do | ||
| dbus_reader :partition_device, "o", dbus_name: "Device" | ||
| dbus_reader :partition_efi, "b", dbus_name: "EFI" | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.