-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
service: Add LogicalVolume interface
- Loading branch information
1 parent
ba93043
commit aa1e7a3
Showing
4 changed files
with
126 additions
and
0 deletions.
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
66 changes: 66 additions & 0 deletions
66
service/lib/agama/dbus/storage/interfaces/device/lvm_lv.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,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 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
38 changes: 38 additions & 0 deletions
38
service/test/agama/dbus/storage/interfaces/device/lvm_lv_examples.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,38 @@ | ||
# 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_relative "../../../../../test_helper" | ||
|
||
shared_examples "LVM.LogicalVolume interface" do | ||
describe "LVM.LogicalVolume D-Bus interface" do | ||
let(:scenario) { "trivial_lvm.yml" } | ||
|
||
let(:device) { devicegraph.find_by_name("/dev/vg0/lv1") } | ||
|
||
describe "#lvm_lv_vg" do | ||
it "returns the path of the host volume group" do | ||
vg0 = devicegraph.find_by_name("/dev/vg0") | ||
|
||
expect(subject.lvm_lv_vg).to eq(tree.path_for(vg0)) | ||
end | ||
end | ||
end | ||
end |