diff --git a/service/lib/agama/dbus/storage/proposal.rb b/service/lib/agama/dbus/storage/proposal.rb index fe1df2f179..c40f2543da 100644 --- a/service/lib/agama/dbus/storage/proposal.rb +++ b/service/lib/agama/dbus/storage/proposal.rb @@ -58,6 +58,8 @@ def initialize(backend, logger) dbus_reader :space_policy, "s" + dbus_reader :space_actions, "aa{ss}" + dbus_reader :volumes, "aa{sv}" dbus_reader :actions, "aa{sv}" @@ -109,6 +111,13 @@ def space_policy dbus_settings.fetch("SpacePolicy", "") end + # Space actions + # + # @return [Array String>] + def space_actions + dbus_settings.fetch("SpaceActions", []) + end + # Volumes used to calculate the storage proposal # # @return [Array] diff --git a/service/lib/agama/dbus/storage/proposal_settings_conversion/from_dbus.rb b/service/lib/agama/dbus/storage/proposal_settings_conversion/from_dbus.rb index 4e7d7b1356..2c3ce6fe2c 100644 --- a/service/lib/agama/dbus/storage/proposal_settings_conversion/from_dbus.rb +++ b/service/lib/agama/dbus/storage/proposal_settings_conversion/from_dbus.rb @@ -130,9 +130,11 @@ def space_policy_conversion(target, value) end # @param target [Agama::Storage::ProposalSettings] - # @param value [Hash] + # @param value [Array String>>] def space_actions_conversion(target, value) - target.space.actions = value + target.space.actions = value.each_with_object({}) do |v, result| + result[v["device"]] = v["action"].to_sym + end end # @param target [Agama::Storage::ProposalSettings] diff --git a/service/lib/agama/dbus/storage/proposal_settings_conversion/to_dbus.rb b/service/lib/agama/dbus/storage/proposal_settings_conversion/to_dbus.rb index 8d641f0b1b..d894481382 100644 --- a/service/lib/agama/dbus/storage/proposal_settings_conversion/to_dbus.rb +++ b/service/lib/agama/dbus/storage/proposal_settings_conversion/to_dbus.rb @@ -44,7 +44,7 @@ def convert # rubocop:disable Metrics/AbcSize "EncryptionMethod" => settings.encryption.method.id.to_s, "EncryptionPBKDFunction" => settings.encryption.pbkd_function&.value || "", "SpacePolicy" => settings.space.policy.to_s, - "SpaceActions" => settings.space.actions, + "SpaceActions" => space_actions_conversion(), "Volumes" => settings.volumes.map { |v| VolumeConversion.to_dbus(v) } } end @@ -53,6 +53,13 @@ def convert # rubocop:disable Metrics/AbcSize # @return [Agama::Storage::ProposalSettings] attr_reader :settings + + # @return [Array String>>] + def space_actions_conversion + settings.space.actions.each_with_object([]) do |(device, action), actions| + actions << { "device" => device, "action" => action.to_s } + end + end end end end diff --git a/service/lib/agama/storage/proposal.rb b/service/lib/agama/storage/proposal.rb index 7232bc71a6..272ca03b34 100644 --- a/service/lib/agama/storage/proposal.rb +++ b/service/lib/agama/storage/proposal.rb @@ -86,9 +86,8 @@ def settings config: config ).tap do |settings| # FIXME: The conversion from Y2Storage cannot infer the space policy. Copying space - # settings from the original settings. + # policy from the original settings. settings.space.policy = original_settings.space.policy - settings.space.actions = original_settings.space.actions # FIXME: The conversion from Y2Storage cannot reliably infer the system VG devices in all # cases. Copying system VG devices from the original settings. settings.lvm.system_vg_devices = original_settings.lvm.system_vg_devices diff --git a/service/lib/agama/storage/proposal_settings_conversion/from_y2storage.rb b/service/lib/agama/storage/proposal_settings_conversion/from_y2storage.rb index db13a73bc8..a89f0484bc 100644 --- a/service/lib/agama/storage/proposal_settings_conversion/from_y2storage.rb +++ b/service/lib/agama/storage/proposal_settings_conversion/from_y2storage.rb @@ -84,7 +84,8 @@ def encryption_conversion(target) # @param target [Agama::Storage::ProposalSettings] def space_settings_conversion(target) - # FIXME: No way to infer space settings from Y2Storage. + # NOTE: the space policy cannot be inferred from Y2Storage settings. + target.space.actions = settings.space_settings.actions end # @param target [Agama::Storage::ProposalSettings] diff --git a/service/lib/agama/storage/proposal_settings_conversion/to_y2storage.rb b/service/lib/agama/storage/proposal_settings_conversion/to_y2storage.rb index e583db872b..e7ca55e481 100644 --- a/service/lib/agama/storage/proposal_settings_conversion/to_y2storage.rb +++ b/service/lib/agama/storage/proposal_settings_conversion/to_y2storage.rb @@ -162,7 +162,7 @@ def find_max_size_fallback(mount_path) # All block devices affected by the space policy. # - # This includes the partitions from the root device, the candidate devices and from the + # This includes the partitions from the boot device, the candidate devices and from the # devices directly assigned to a volume as target device. If a device is not partitioned, # then the device itself is included. # diff --git a/web/src/client/storage.js b/web/src/client/storage.js index ba74801644..d710a09465 100644 --- a/web/src/client/storage.js +++ b/web/src/client/storage.js @@ -241,10 +241,15 @@ class ProposalManager { * @property {string} encryptionMethod * @property {boolean} lvm * @property {string} spacePolicy + * @property {SpaceAction[]} spaceActions * @property {string[]} systemVGDevices * @property {Volume[]} volumes * @property {StorageDevice[]} installationDevices * + * @typedef {object} SpaceAction + * @property {string} device + * @property {string} action + * * @typedef {object} Volume * @property {string} mountPath * @property {string} fsType @@ -365,6 +370,7 @@ class ProposalManager { bootDevice: proxy.BootDevice, lvm: proxy.LVM, spacePolicy: proxy.SpacePolicy, + spaceActions: proxy.SpaceActions, systemVGDevices: proxy.SystemVGDevices, encryptionPassword: proxy.EncryptionPassword, encryptionMethod: proxy.EncryptionMethod, @@ -388,7 +394,18 @@ class ProposalManager { * @param {ProposalSettings} settings * @returns {Promise} 0 on success, 1 on failure */ - async calculate({ bootDevice, encryptionPassword, encryptionMethod, lvm, spacePolicy, systemVGDevices, volumes }) { + async calculate(settings) { + const { + bootDevice, + encryptionPassword, + encryptionMethod, + lvm, + spacePolicy, + spaceActions, + systemVGDevices, + volumes + } = settings; + const dbusVolume = (volume) => { return removeUndefinedCockpitProperties({ MountPath: { t: "s", v: volume.mountPath }, @@ -401,18 +418,19 @@ class ProposalManager { }); }; - const settings = removeUndefinedCockpitProperties({ + const dbusSettings = removeUndefinedCockpitProperties({ BootDevice: { t: "s", v: bootDevice }, EncryptionPassword: { t: "s", v: encryptionPassword }, EncryptionMethod: { t: "s", v: encryptionMethod }, LVM: { t: "b", v: lvm }, SpacePolicy: { t: "s", v: spacePolicy }, + SpaceActions: { t: "aa{ss}", v: spaceActions }, SystemVGDevices: { t: "as", v: systemVGDevices }, Volumes: { t: "aa{sv}", v: volumes?.map(dbusVolume) } }); const proxy = await this.proxies.proposalCalculator; - return proxy.Calculate(settings); + return proxy.Calculate(dbusSettings); } /**