Skip to content

Commit e282c16

Browse files
committed
Include proposal information in the ProposalChanged signal
1 parent fc0613f commit e282c16

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def initialize(backend, logger: nil)
7979
dbus_method(:GetProposal, "out proposal:s") { recover_proposal }
8080
dbus_method(:GetIssues, "out issues:s") { recover_issues }
8181
dbus_signal(:SystemChanged, "system:s")
82-
dbus_signal(:ProposalChanged)
82+
dbus_signal(:ProposalChanged, "proposal:s")
8383
dbus_signal(:IssuesChanged)
8484
dbus_signal(:ProgressChanged, "progress:s")
8585
dbus_signal(:ProgressFinished)
@@ -130,10 +130,7 @@ def configure_product(id)
130130
end
131131

132132
next_progress_step(CONFIGURING_STEP)
133-
backend.configure
134-
self.ProposalChanged
135-
136-
finish_progress
133+
calculate_proposal
137134
end
138135

139136
# Implementation for the API method #Install.
@@ -208,10 +205,7 @@ def configure(serialized_config)
208205
start_progress(1, CONFIGURING_STEP)
209206

210207
config_json = JSON.parse(serialized_config, symbolize_names: true)
211-
backend.configure(config_json)
212-
self.ProposalChanged
213-
214-
finish_progress
208+
calculate_proposal(config_json)
215209
end
216210

217211
# Applies the given serialized config model according to the JSON schema.
@@ -227,10 +221,7 @@ def configure_with_model(serialized_model)
227221
storage_system: proposal.storage_system
228222
).convert
229223
config_json = { storage: Agama::Storage::ConfigConversions::ToJSON.new(config).convert }
230-
backend.configure(config_json)
231-
self.ProposalChanged
232-
233-
finish_progress
224+
calculate_proposal(config_json)
234225
end
235226

236227
# Solves the given serialized config model.
@@ -400,7 +391,16 @@ def configure_with_current
400391
return unless config_json
401392

402393
configure(config_json)
403-
self.ProposalChanged
394+
end
395+
396+
# @see #configure
397+
# @see #configure_with_model
398+
#
399+
# @param config_json [Hash, nil] see Agama::Storage::Manager#configure
400+
def calculate_proposal(config_json = nil)
401+
backend.configure(config_json)
402+
self.ProposalChanged(recover_proposal)
403+
finish_progress
404404
end
405405

406406
# JSON representation of the given devicegraph from StorageManager

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -851,15 +851,17 @@ def parse(string)
851851
before do
852852
allow(proposal).to receive(:storage_json).and_return config_json.to_json
853853
allow(subject).to receive(:ProposalChanged)
854-
allow(backend).to receive(:configure)
855854
end
856855

857856
let(:config_json) do
858857
{
859858
storage: {
860859
drives: [
861860
{
862-
partitions: [{ generate: "defaults" }]
861+
partitions: [
862+
{ search: "*", delete: true },
863+
{ filesystem: { path: "/" }, size: { min: "5 GiB" } }
864+
]
863865
}
864866
]
865867
}
@@ -878,7 +880,11 @@ def parse(string)
878880
expect(device[:name]).to eq "/dev/sda"
879881
expect(system[:availableDrives]).to eq [device[:sid]]
880882
end
881-
expect(subject).to receive(:ProposalChanged)
883+
expect(subject).to receive(:ProposalChanged) do |proposal_str|
884+
proposal = parse(proposal_str)
885+
expect(proposal[:devices]).to be_a Array
886+
expect(proposal[:actions]).to be_a Array
887+
end
882888
expect(subject).to receive(:ProgressChanged).with(/storage configuration/i)
883889
expect(subject).to receive(:ProgressFinished)
884890

0 commit comments

Comments
 (0)