From 08bc5168e8e74a74920eae6d2cbd061d889a3f91 Mon Sep 17 00:00:00 2001 From: Ancor Gonzalez Sosa Date: Wed, 24 Jul 2024 13:58:19 +0200 Subject: [PATCH 1/3] Move logic for easier reuse from Agama --- src/lib/y2storage/proposal.rb | 1 + .../proposal/autoinst_devices_planner.rb | 23 ++------- .../proposal/planned_devices_handler.rb | 47 +++++++++++++++++++ 3 files changed, 51 insertions(+), 20 deletions(-) create mode 100644 src/lib/y2storage/proposal/planned_devices_handler.rb diff --git a/src/lib/y2storage/proposal.rb b/src/lib/y2storage/proposal.rb index 77884f0faa..6be7230926 100644 --- a/src/lib/y2storage/proposal.rb +++ b/src/lib/y2storage/proposal.rb @@ -43,3 +43,4 @@ module Proposal require "y2storage/proposal/space_maker" require "y2storage/proposal/partition_table_creator" require "y2storage/proposal/settings_generator" +require "y2storage/proposal/planned_devices_handler" diff --git a/src/lib/y2storage/proposal/autoinst_devices_planner.rb b/src/lib/y2storage/proposal/autoinst_devices_planner.rb index 1eda39a994..19d5c3d35f 100644 --- a/src/lib/y2storage/proposal/autoinst_devices_planner.rb +++ b/src/lib/y2storage/proposal/autoinst_devices_planner.rb @@ -27,6 +27,7 @@ require "y2storage/proposal/autoinst_nfs_planner" require "y2storage/proposal/autoinst_btrfs_planner" require "y2storage/proposal/autoinst_tmpfs_planner" +require "y2storage/proposal/planned_devices_handler" require "y2storage/planned" module Y2Storage @@ -41,6 +42,7 @@ module Proposal # class AutoinstDevicesPlanner include Yast::Logger + include PlannedDevicesHandler # Constructor # @@ -62,7 +64,7 @@ def planned_devices(drives_map) end collection = Planned::DevicesCollection.new(devices) - remove_shadowed_subvols(collection.mountable_devices) + remove_shadowed_subvols(collection) add_bcache_issues(collection) collection end @@ -170,25 +172,6 @@ def planned_for_tmpfs(drive) planner.planned_devices(drive) end - # Removes shadowed subvolumes from each planned device that can be mounted - # - # @param planned_devices [Array] - def remove_shadowed_subvols(planned_devices) - planned_devices.each do |device| - # Some planned devices could be mountable but not formattable (e.g., {Planned::Nfs}). - # Those devices might shadow some subvolumes but they do not have any subvolume to - # be shadowed. - next unless device.respond_to?(:shadowed_subvolumes) - - device.shadowed_subvolumes(planned_devices).each do |subvol| - # TODO: this should be reported to the user when the shadowed - # subvolumes was specified in the profile. - log.info "Subvolume #{subvol} would be shadowed. Removing it." - device.subvolumes.delete(subvol) - end - end - end - # Adds a bcache issue if needed # # @param collection [Planned::DevicesCollection] Planned devices diff --git a/src/lib/y2storage/proposal/planned_devices_handler.rb b/src/lib/y2storage/proposal/planned_devices_handler.rb new file mode 100644 index 0000000000..f772151a1b --- /dev/null +++ b/src/lib/y2storage/proposal/planned_devices_handler.rb @@ -0,0 +1,47 @@ +# 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 Y2Storage + module Proposal + # Mixin with methods to handle planned device collections + module PlannedDevicesHandler + include Yast::Logger + + # Removes shadowed subvolumes from each planned device that can be mounted + # + # Note this does not alter the collection itself, but it modifies the attributes of + # some of the elements in the collection + # + # @param planned_devices [Planned::DevicesCollection] + def remove_shadowed_subvols(planned_devices) + planned_devices.mountable_devices.each do |device| + # Some planned devices could be mountable but not formattable (e.g., {Planned::Nfs}). + # Those devices might shadow some subvolumes but they do not have any subvolume to + # be shadowed. + next unless device.respond_to?(:shadowed_subvolumes) + + device.shadowed_subvolumes(planned_devices.mountable_devices).each do |subvol| + log.info "Subvolume #{subvol} would be shadowed. Removing it." + device.subvolumes.delete(subvol) + end + end + end + end + end +end From 80189f274c63f5c8e710b507ea69ff581fa678c9 Mon Sep 17 00:00:00 2001 From: Ancor Gonzalez Sosa Date: Tue, 13 Aug 2024 10:53:38 +0200 Subject: [PATCH 2/3] SpaceMaker do not reset forced_ptable_type --- src/lib/y2storage/proposal/space_maker.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/lib/y2storage/proposal/space_maker.rb b/src/lib/y2storage/proposal/space_maker.rb index 0fd8c11b1b..ff6a8fd773 100644 --- a/src/lib/y2storage/proposal/space_maker.rb +++ b/src/lib/y2storage/proposal/space_maker.rb @@ -284,10 +284,6 @@ def resize_and_delete(planned_partitions, lvm_helper, disk_name: nil) end def force_ptables(planned_partitions) - Y2Storage::Partitionable.all(new_graph).each do |dev| - dev.forced_ptable_type = nil - end - forced = planned_partitions.select { |part| part.disk && part.ptable_type } forced.each do |part| disk = new_graph.find_by_name(part.disk) From 6630f78a73bc3da4488ac061fd01d376b22d518f Mon Sep 17 00:00:00 2001 From: Ancor Gonzalez Sosa Date: Wed, 21 Aug 2024 14:05:03 +0200 Subject: [PATCH 3/3] Version and changelog --- package/yast2-storage-ng.changes | 7 +++++++ package/yast2-storage-ng.spec | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/package/yast2-storage-ng.changes b/package/yast2-storage-ng.changes index 8d5859ac14..a256da68eb 100644 --- a/package/yast2-storage-ng.changes +++ b/package/yast2-storage-ng.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Wed Aug 21 12:03:30 UTC 2024 - Ancor Gonzalez Sosa + +- Tiny internal code reorganization to ease Agama development at + gh#openSUSE/agama#1448. +- 5.0.16 + ------------------------------------------------------------------- Fri Jun 14 12:41:07 UTC 2024 - Ancor Gonzalez Sosa diff --git a/package/yast2-storage-ng.spec b/package/yast2-storage-ng.spec index 61ab3cc1ad..d55800b175 100644 --- a/package/yast2-storage-ng.spec +++ b/package/yast2-storage-ng.spec @@ -16,7 +16,7 @@ # Name: yast2-storage-ng -Version: 5.0.15 +Version: 5.0.16 Release: 0 Summary: YaST2 - Storage Configuration License: GPL-2.0-only OR GPL-3.0-only