-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
979615d
commit eb866ce
Showing
5 changed files
with
214 additions
and
28 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
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,94 @@ | ||
# 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 "y2storage/lv_type" | ||
require "y2storage/proposal/agama_device_planner" | ||
|
||
module Y2Storage | ||
module Proposal | ||
# Volume group planner for Agama. | ||
class AgamaVgPlanner < AgamaDevicePlanner | ||
# @param config [Agama::Storage::Configs::VolumeGroup] | ||
# @return [Array<Planned::Device>] | ||
def planned_devices(config) | ||
[planned_vg(config)] | ||
end | ||
|
||
private | ||
|
||
def planned_vg(config) | ||
Y2Storage::Planned::LvmVg.new(volume_group_name: config.name).tap do |planned| | ||
planned.extent_size = config.extent_size | ||
planned.lvs = planned_lvs(config) | ||
end | ||
end | ||
|
||
def planned_lvs(config) | ||
# TODO: Generate issues for thin configs with unknown pool alias. | ||
|
||
normal_lvs = planned_normal_lvs(config) | ||
thin_pool_lvs = planned_thin_pool_lvs(config) | ||
|
||
normal_lvs + thin_pool_lvs | ||
end | ||
|
||
def planned_normal_lvs(config) | ||
configs = config.logical_volumes.reject(&:pool?).reject(&:thin_volume?) | ||
configs.map { |c| planned_lv(c, LvType::NORMAL) } | ||
end | ||
|
||
def planned_thin_pool_lvs(config) | ||
pool_configs = config.logical_volumes.select(&:pool?) | ||
thin_configs = config.logical_volumes.select(&:thin_volume?) | ||
|
||
pool_configs.map { |c| planned_thin_pool_logical_volume(c, thin_configs) } | ||
end | ||
|
||
def planned_thin_pool_logical_volume(config, thin_configs) | ||
thin_configs = thin_configs.select { |c| c.used_pool == config.alias } | ||
|
||
planned_pool = planned_lv(config, LvType::THIN_POOL) | ||
planned_thin_volumes = thin_configs.map { |c| planned_lv(c, LvType::THIN) } | ||
|
||
planned_thin_volumes.each { |v| planned_pool.add_thin_lv(v) } | ||
planned_pool | ||
end | ||
|
||
def planned_lv(config, type) | ||
Planned::LvmLv.new(nil, nil).tap do |planned| | ||
planned.logical_volume_name = config.name | ||
planned.lv_type = type | ||
planned.stripes = config.stripes | ||
planned.stripe_size = config.stripe_size | ||
configure_block_device(planned, config) | ||
configure_size(planned, config.size) | ||
end | ||
end | ||
|
||
def configure_size(planned, config) | ||
# TODO: Generate issue if there is no size config. | ||
return unless config | ||
|
||
super | ||
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