-
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.
feat: integrate actions with space policy (#1354)
The [new user interface](#1202) made us to see an small improvement for easing the understanding of the kind of complex storage/Proposal page. It basically consist on making more explicit the relation between the space policy and the actions that installer will take on the storage level. To see more, read #1327
- Loading branch information
Showing
40 changed files
with
1,285 additions
and
1,197 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
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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
------------------------------------------------------------------- | ||
Tue Jun 25 15:04:20 UTC 2024 - David Diaz <[email protected]> | ||
|
||
- Add resize actions to storage model (gh#openSUSE/agama#1354). | ||
|
||
------------------------------------------------------------------- | ||
Mon Jun 24 20:35:00 UTC 2024 - Lubos Kocman <[email protected]> | ||
|
||
|
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
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
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
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,80 @@ | ||
# 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. | ||
|
||
module Agama | ||
module Storage | ||
# Represents an action to perform in the storage devices. | ||
class Action | ||
# @param action [Y2Storage::CompoundAction] | ||
# @param system_graph [Y2Storage::Devicegraph] | ||
def initialize(action, system_graph) | ||
@action = action | ||
@system_graph = system_graph | ||
end | ||
|
||
# Affected device | ||
# | ||
# @return [Y2Storage::Device] | ||
def device | ||
action.target_device | ||
end | ||
|
||
# Text describing the action. | ||
# | ||
# @return [String] | ||
def text | ||
action.sentence | ||
end | ||
|
||
# Whether the action affects to a Btrfs subvolume. | ||
# | ||
# @return [Boolean] | ||
def on_btrfs_subvolume? | ||
action.device_is?(:btrfs_subvolume) | ||
end | ||
|
||
# Whether the action deletes the device. | ||
# | ||
# @return [Boolean] | ||
def delete? | ||
action.delete? | ||
end | ||
|
||
# Whether the action resizes the device. | ||
# | ||
# @return [Boolean] | ||
def resize? | ||
return false unless device.exists_in_devicegraph?(system_graph) | ||
return false unless device.respond_to?(:size) | ||
|
||
system_graph.find_device(device.sid).size != device.size | ||
end | ||
|
||
private | ||
|
||
# @return [Y2Storage::CompoundAction] | ||
attr_reader :action | ||
|
||
# @return [Y2Storage::Devicegraph] | ||
attr_reader :system_graph | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
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,85 @@ | ||
# 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 "agama/storage/action" | ||
|
||
module Agama | ||
module Storage | ||
# Generates the list of actions to perform over the storage devices. | ||
class ActionsGenerator | ||
# param system_graph [Y2Storage::Devicegraph] | ||
# param target_graph [Y2Storage::Devicegraph] | ||
def initialize(system_graph, target_graph) | ||
@system_graph = system_graph | ||
@target_graph = target_graph | ||
end | ||
|
||
# All actions properly sorted. | ||
# | ||
# @return [Array<Action>] | ||
def generate | ||
main_actions + subvolume_actions | ||
end | ||
|
||
private | ||
|
||
# @return [Y2Storage::Devicegraph] | ||
attr_reader :system_graph | ||
|
||
# @return [Y2Storage::Devicegraph] | ||
attr_reader :target_graph | ||
|
||
# Sorted main actions (everything except subvolume actions). | ||
# | ||
# @return [Array<Action>] | ||
def main_actions | ||
actions = self.actions.reject(&:on_btrfs_subvolume?) | ||
sort_actions(actions) | ||
end | ||
|
||
# Sorted subvolume actions. | ||
# | ||
# @return [Array<Action>] | ||
def subvolume_actions | ||
actions = self.actions.select(&:on_btrfs_subvolume?) | ||
sort_actions(actions) | ||
end | ||
|
||
# All actions, without sorting. | ||
# | ||
# @return [Array<Action>] | ||
def actions | ||
@actions ||= target_graph.actiongraph.compound_actions.map do |action| | ||
Action.new(action, system_graph) | ||
end | ||
end | ||
|
||
# Sorts actions, placing destructive actions at the end. | ||
# | ||
# @param actions [Array<Action>] | ||
# @return [Array<Action>] | ||
def sort_actions(actions) | ||
delete, other = actions.partition(&:delete?) | ||
delete.concat(other) | ||
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
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
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 |
---|---|---|
@@ -1,3 +1,9 @@ | ||
------------------------------------------------------------------- | ||
Tue Jun 25 15:03:05 UTC 2024 - David Diaz <[email protected]> | ||
|
||
- Add support for retrieving the storage resize actions | ||
(gh#openSUSE/agama#1354). | ||
|
||
------------------------------------------------------------------- | ||
Thu Jun 20 05:25:49 UTC 2024 - Imobach Gonzalez Sosa <[email protected]> | ||
|
||
|
Oops, something went wrong.