-
Notifications
You must be signed in to change notification settings - Fork 43
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
Extend storage D-Bus API #1071
Merged
joseivanlopez
merged 8 commits into
agama-project:storage-ui
from
joseivanlopez:extend-storage-dbus
Mar 6, 2024
Merged
Extend storage D-Bus API #1071
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4372623
service: Export device sid in the proposal actions
joseivanlopez ca34978
service: Export unused slots
joseivanlopez 02a93e9
service: Export more info about block devices
joseivanlopez 26fb99d
service: Export LVM devices
joseivanlopez 36ff75a
service: Avoid updating D-Bus nodes of devices tree
joseivanlopez fa1ace3
service: Export staging devices
joseivanlopez d43bb46
service: Fix rubocop config
joseivanlopez 8128fd7
service: Fix typo
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 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 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 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 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 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 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 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
90 changes: 90 additions & 0 deletions
90
service/lib/agama/dbus/storage/interfaces/device/lvm_vg.rb
This file contains 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,90 @@ | ||
# 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 a LVM Volume Group. | ||
# | ||
# @note This interface is intended to be included by {Agama::DBus::Storage::Device} if | ||
# needed. | ||
module LvmVg | ||
# Whether this interface should be implemented for the given device. | ||
# | ||
# @note LVM Volume Groups implement this interface. | ||
# | ||
# @param storage_device [Y2Storage::Device] | ||
# @return [Boolean] | ||
def self.apply?(storage_device) | ||
storage_device.is?(:lvm_vg) | ||
end | ||
|
||
VOLUME_GROUP_INTERFACE = "org.opensuse.Agama.Storage1.LVM.VolumeGroup" | ||
private_constant :VOLUME_GROUP_INTERFACE | ||
|
||
# Name of the volume group | ||
# | ||
# @return [String] e.g., "/dev/mapper/vg0" | ||
def lvm_vg_name | ||
storage_device.name | ||
end | ||
|
||
# Size of the volume group in bytes | ||
# | ||
# @return [Integer] | ||
def lvm_vg_size | ||
storage_device.size.to_i | ||
end | ||
|
||
# D-Bus paths of the objects representing the physical volumes. | ||
# | ||
# @return [Array<String>] | ||
def lvm_vg_pvs | ||
storage_device.lvm_pvs.map { |p| tree.path_for(p.plain_blk_device) } | ||
end | ||
|
||
# D-Bus paths of the objects representing the logical volumes. | ||
# | ||
# @return [Array<String>] | ||
def lvm_vg_lvs | ||
storage_device.lvm_lvs.map { |l| tree.path_for(l) } | ||
end | ||
|
||
def self.included(base) | ||
base.class_eval do | ||
dbus_interface VOLUME_GROUP_INTERFACE do | ||
dbus_reader :lvm_vg_name, "s", dbus_name: "Name" | ||
dbus_reader :lvm_vg_size, "t", dbus_name: "Size" | ||
dbus_reader :lvm_vg_pvs, "ao", dbus_name: "PhysicalVolumes" | ||
dbus_reader :lvm_vg_lvs, "ao", dbus_name: "LogicalVolumes" | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains 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 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 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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this explanation a bit too technical and a bit too close to the Y2Storage world? In fact, I would say that using the sid simply makes sense here and does not need that explanation about memory.
Just something saying this is the internal storage identifier and clarifying it's unique per device should be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is. But I would prefer to keep it as a warning. I see myself trying to use
storage_device
again for something, which is quite unsafe.