Skip to content

Commit

Permalink
Merge pull request #626 from joseivanlopez/allow-lun-scan
Browse files Browse the repository at this point in the history
Extend zFCP D-Bus API
  • Loading branch information
joseivanlopez authored Jun 20, 2023
2 parents 6461acc + e73ed18 commit 1a0f62e
Show file tree
Hide file tree
Showing 13 changed files with 117 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<arg name="result" direction="out" type="u"/>
</method>
<property type="b" name="Active" access="read"/>
<property type="b" name="LUNScan" access="read"/>
<property type="s" name="Channel" access="read"/>
</interface>
</node>
3 changes: 3 additions & 0 deletions doc/dbus/bus/org.opensuse.Agama.Storage1.bus.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node name="/org/opensuse/Agama/Storage1">
<node name="zfcp_controllers" />
<node name="zfcp_disks" />
<interface name="org.freedesktop.DBus.Properties">
<method name="Get">
<arg name="interface_name" direction="in" type="s"/>
Expand Down Expand Up @@ -109,5 +111,6 @@
<interface name="org.opensuse.Agama.Storage1.ZFCP.Manager">
<method name="Probe">
</method>
<property type="b" name="AllowLUNScan" access="read"/>
</interface>
</node>
4 changes: 4 additions & 0 deletions doc/dbus/org.opensuse.Agama.Storage1.ZFCP.Controller.doc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
Whether the controller is active.
-->
<property type="b" name="Active" access="read"/>
<!--
Whether the controller is performing auto LUN scan.
-->
<property type="b" name="LUNScan" access="read"/>
<!--
zFCP channel id (e.g., 0.0.fa00).
-->
Expand Down
4 changes: 4 additions & 0 deletions doc/dbus/org.opensuse.Agama.Storage1.doc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,9 @@
-->
<method name="Probe">
</method>
<!--
Whether the option allow_lun_scan is active.
-->
<property type="b" name="AllowLUNScan" access="read"/>
</interface>
</node>
6 changes: 3 additions & 3 deletions service/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
agama (2.1)
agama (2.1.devel317)
cfa (~> 1.0.2)
cfa_grub2 (~> 2.0.0)
cheetah (~> 1.0.0)
Expand All @@ -26,13 +26,13 @@ GEM
docile (1.4.0)
eventmachine (1.2.7)
fast_gettext (2.2.0)
mini_portile2 (2.8.1)
mini_portile2 (2.8.2)
nokogiri (1.13.10)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
packaging_rake_tasks (1.5.1)
rake
racc (1.6.2)
racc (1.7.1)
rake (13.0.6)
rexml (3.2.5)
rspec (3.11.0)
Expand Down
10 changes: 10 additions & 0 deletions service/lib/agama/dbus/storage/interfaces/zfcp_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ module Interfaces
#
# @note This mixin is expected to be included by {Agama::DBus::Storage::Manager}.
module ZFCPManager
# Whether the option for allowing automatic LUN scan is active
#
# @return [Boolean]
def allow_lun_scan
zfcp_backend.allow_lun_scan?
end

# Registers callbacks to update the collection of zFCP controllers, the disks and
# deprecate the system
def register_zfcp_callbacks
Expand Down Expand Up @@ -71,6 +78,9 @@ def zfcp_backend
def self.included(base)
base.class_eval do
dbus_interface ZFCP_MANAGER_INTERFACE do
# @see #allow_lun_scan
dbus_reader(:allow_lun_scan, "b", dbus_name: "AllowLUNScan")

# Probes the zFCP controllers and disks
dbus_method(:Probe) do
busy_while { zfcp_backend.probe }
Expand Down
10 changes: 10 additions & 0 deletions service/lib/agama/dbus/storage/zfcp_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ def active
controller.active?
end

# Whether the controller is automatically scanning LUNs
#
# @return [Boolean]
def lun_scan
controller.lun_scan?
end

# zFCP channel id
#
# @return [String]
Expand Down Expand Up @@ -132,6 +139,9 @@ def controller=(value)
# @see #active
dbus_reader(:active, "b")

# @see #lun_scan
dbus_reader(:lun_scan, "b", dbus_name: "LUNScan")

# @see #channel
dbus_reader(:channel, "s")

Expand Down
14 changes: 14 additions & 0 deletions service/lib/agama/storage/zfcp/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,16 @@ class Controller
# @return [String]
attr_reader :channel

# @see #active?
#
# @return [Boolean]
attr_writer :active

# @see #lun_scan?
#
# @return [Boolean]
attr_writer :lun_scan

eql_attr :channel, :active?

# Constructor
Expand All @@ -51,6 +58,13 @@ def initialize(channel)
def active?
!!@active
end

# Whether the controller is automatically scanning LUNs
#
# @return [Booelan]
def lun_scan?
!!@lun_scan
end
end
end
end
Expand Down
12 changes: 12 additions & 0 deletions service/lib/agama/storage/zfcp/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ def disks
yast_zfcp.disks.map { |d| disk_from(d) }
end

# Whether the option for allowing automatic LUN scan (allow_lun_scan) is active
#
# Having allow_lun_scan active has some implications:
# * All LUNs are automatically activated when the controller is activated.
# * LUNs cannot be deactivated.
#
# @return [Boolean]
def allow_lun_scan?
yast_zfcp.allow_lun_scan?
end

# Activates the controller with the given channel id
#
# @note: If "allow_lun_scan" is active, then all LUNs are automatically activated.
Expand Down Expand Up @@ -161,6 +172,7 @@ def update_disks
def controller_from(record)
Controller.new(record["sysfs_bus_id"]).tap do |controller|
controller.active = yast_zfcp.activated_controller?(controller.channel)
controller.lun_scan = yast_zfcp.lun_scan_controller?(controller.channel)
end
end

Expand Down
2 changes: 1 addition & 1 deletion service/package/gem2rpm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# yast2 with ArchFilter
Requires: yast2 >= 4.5.20
%ifarch s390 s390x
Requires: yast2-s390 >= 4.6.2
Requires: yast2-s390 >= 4.6.3
%endif
:filelist: "%{_datadir}/dbus-1/agama.conf\n
%dir %{_datadir}/dbus-1/agama-services\n
Expand Down
6 changes: 6 additions & 0 deletions service/package/rubygem-agama.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed Jun 14 15:11:56 UTC 2023 - José Iván López González <jlopez@suse.com>

- Extend zFCP D-Bus API to provide allow_lun_scan info
(gh#openSUSE/agama/626).

-------------------------------------------------------------------
Wed Jun 7 11:13:49 UTC 2023 - José Iván López González <jlopez@suse.com>

Expand Down
22 changes: 22 additions & 0 deletions service/test/agama/dbus/storage/zfcp_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,28 @@
end
end

describe "#lun_scan" do
before do
controller1.lun_scan = lun_scan
end

context "if the controller is automatically scanning LUNs" do
let(:lun_scan) { true }

it "returns true" do
expect(subject.lun_scan).to eq(true)
end
end

context "if the controller is not automatically scanning LUNs" do
let(:lun_scan) { false }

it "returns false" do
expect(subject.lun_scan).to eq(false)
end
end
end

describe "#channel" do
it "returns the channel id of the controller" do
expect(subject.channel).to eq("0.0.fa00")
Expand Down
27 changes: 27 additions & 0 deletions service/test/agama/storage/zfcp/manager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ module Y2S390

before do
allow(yast_zfcp).to receive(:activated_controller?).with("0.0.fa00").and_return(true)
allow(yast_zfcp).to receive(:lun_scan_controller?).with("0.0.fa00").and_return(true)

allow(yast_zfcp).to receive(:activated_controller?).with("0.0.fc00").and_return(false)
allow(yast_zfcp).to receive(:lun_scan_controller?).with("0.0.fc00").and_return(false)
end

it "returns the zFCP controllers" do
Expand All @@ -118,9 +121,11 @@ module Y2S390

controller = controllers.find { |c| c.channel == "0.0.fa00" }
expect(controller.active?).to eq(true)
expect(controller.lun_scan?).to eq(true)

controller = controllers.find { |c| c.channel == "0.0.fc00" }
expect(controller.active?).to eq(false)
expect(controller.lun_scan?).to eq(false)
end
end

Expand Down Expand Up @@ -149,6 +154,28 @@ module Y2S390
end
end

describe "#allow_lun_scan?" do
before do
allow(yast_zfcp).to receive(:allow_lun_scan?).and_return(active)
end

context "if allow_lun_scan is active" do
let(:active) { true }

it "returns true" do
expect(subject.allow_lun_scan?).to eq(true)
end
end

context "if allow_lun_scan is not active" do
let(:active) { false }

it "returns false" do
expect(subject.allow_lun_scan?).to eq(false)
end
end
end

describe "#activate_controller" do
before do
allow(yast_zfcp).to receive(:activate_controller).and_return(output)
Expand Down

0 comments on commit 1a0f62e

Please sign in to comment.