Skip to content

Commit fc0613f

Browse files
committed
Include system information in the SystemChanged signal
1 parent d0ebbaf commit fc0613f

File tree

2 files changed

+107
-4
lines changed

2 files changed

+107
-4
lines changed

service/lib/agama/dbus/storage/manager.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def initialize(backend, logger: nil)
7878
dbus_method(:SolveConfigModel, "in model:s, out result:s") { |m| solve_config_model(m) }
7979
dbus_method(:GetProposal, "out proposal:s") { recover_proposal }
8080
dbus_method(:GetIssues, "out issues:s") { recover_issues }
81-
dbus_signal(:SystemChanged)
81+
dbus_signal(:SystemChanged, "system:s")
8282
dbus_signal(:ProposalChanged)
8383
dbus_signal(:IssuesChanged)
8484
dbus_signal(:ProgressChanged, "progress:s")
@@ -93,7 +93,7 @@ def activate
9393

9494
next_progress_step(PROBING_STEP)
9595
backend.probe
96-
self.SystemChanged
96+
emit_system_changed
9797

9898
next_progress_step(CONFIGURING_STEP)
9999
configure_with_current
@@ -108,7 +108,7 @@ def probe
108108

109109
next_progress_step(PROBING_STEP)
110110
backend.probe
111-
self.SystemChanged
111+
emit_system_changed
112112

113113
next_progress_step(CONFIGURING_STEP)
114114
configure_with_current
@@ -126,7 +126,7 @@ def configure_product(id)
126126
next_progress_step(PROBING_STEP)
127127
if !backend.probed?
128128
backend.probe
129-
self.SystemChanged
129+
emit_system_changed
130130
end
131131

132132
next_progress_step(CONFIGURING_STEP)
@@ -510,6 +510,11 @@ def volume_templates
510510
end
511511
end
512512

513+
# Emits the SystemChanged signal
514+
def emit_system_changed
515+
self.SystemChanged(recover_system)
516+
end
517+
513518
def add_s390_interfaces
514519
require "agama/dbus/storage/interfaces/dasd_manager"
515520
require "agama/dbus/storage/interfaces/zfcp_manager"

service/test/agama/dbus/storage/manager_test.rb

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,104 @@ def parse(string)
789789
end
790790
end
791791

792+
describe "#probe" do
793+
before do
794+
allow(subject).to receive(:SystemChanged)
795+
allow(subject).to receive(:ProgressChanged)
796+
allow(subject).to receive(:ProgressFinished)
797+
798+
allow(backend).to receive(:activated?).and_return activated
799+
allow(backend).to receive(:probe)
800+
end
801+
802+
let(:activated) { true }
803+
804+
it "triggers a new probing" do
805+
expect(backend).to receive(:probe)
806+
subject.probe
807+
end
808+
809+
context "when storage devices are already activated" do
810+
it "does not activate devices" do
811+
expect(backend).to_not receive(:activate)
812+
subject.probe
813+
end
814+
end
815+
816+
context "when storage devices are not yet activated" do
817+
let(:activated) { false }
818+
819+
it "activates the devices" do
820+
expect(backend).to receive(:activate)
821+
subject.probe
822+
end
823+
end
824+
825+
context "when no storage configuration has been set" do
826+
it "does not calculate a new proposal" do
827+
expect(backend).to_not receive(:configure)
828+
subject.probe
829+
end
830+
831+
it "does not emit a ProposalChanged signal" do
832+
expect(subject).to_not receive(:ProposalChanged)
833+
subject.probe
834+
end
835+
836+
it "emits signals for SystemChanged, ProgressChanged and ProgressFinished" do
837+
expect(subject).to receive(:SystemChanged) do |system_str|
838+
system = parse(system_str)
839+
device = system[:devices].first
840+
expect(device[:name]).to eq "/dev/sda"
841+
expect(system[:availableDrives]).to eq [device[:sid]]
842+
end
843+
expect(subject).to receive(:ProgressChanged).with(/storage configuration/i)
844+
expect(subject).to receive(:ProgressFinished)
845+
846+
subject.probe
847+
end
848+
end
849+
850+
context "when a storage configuration was previously set" do
851+
before do
852+
allow(proposal).to receive(:storage_json).and_return config_json.to_json
853+
allow(subject).to receive(:ProposalChanged)
854+
allow(backend).to receive(:configure)
855+
end
856+
857+
let(:config_json) do
858+
{
859+
storage: {
860+
drives: [
861+
{
862+
partitions: [{ generate: "defaults" }]
863+
}
864+
]
865+
}
866+
}
867+
end
868+
869+
it "re-calculates the proposal" do
870+
expect(backend).to receive(:configure).with(config_json)
871+
subject.probe
872+
end
873+
874+
it "emits signals for ProposalChanged, SystemChanged, ProgressChanged and ProgressFinished" do
875+
expect(subject).to receive(:SystemChanged) do |system_str|
876+
system = parse(system_str)
877+
device = system[:devices].first
878+
expect(device[:name]).to eq "/dev/sda"
879+
expect(system[:availableDrives]).to eq [device[:sid]]
880+
end
881+
expect(subject).to receive(:ProposalChanged)
882+
expect(subject).to receive(:ProgressChanged).with(/storage configuration/i)
883+
expect(subject).to receive(:ProgressFinished)
884+
885+
subject.probe
886+
end
887+
end
888+
end
889+
792890
describe "#recover_issues" do
793891
context "if no proposal has been calculated" do
794892
it "returns an empty array" do

0 commit comments

Comments
 (0)