-
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.
feat(storage): initial config support for LVM (#1581)
Add support to the storage config for creating LVM volume groups, logical volumes, thin pools and thin logical volumes. Reusing volume groups or logical volumes is out of the scope of this PR. The schema for volume groups is defined according to the [auto_storage](https://github.com/openSUSE/agama/blob/master/doc/auto_storage.md) documentation. ~~~ "storage": { "drives": [ ... ], "volumeGroups": [ ... ] } ~~~
- Loading branch information
Showing
56 changed files
with
2,611 additions
and
1,109 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
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,71 @@ | ||
{ | ||
"storage": { | ||
"drives": [ | ||
{ | ||
"partitions": [ | ||
{ | ||
"alias": "pv1", | ||
"id": "lvm", | ||
"size": { "min": "10 GiB" } | ||
} | ||
] | ||
}, | ||
{ | ||
"partitions": [ | ||
{ | ||
"alias": "pv2", | ||
"id": "lvm", | ||
"size": { "min": "10 GiB" } | ||
} | ||
] | ||
} | ||
], | ||
"volumeGroups": [ | ||
{ | ||
"name": "system", | ||
"physicalVolumes": ["pv1", "pv2"], | ||
"extentSize": "8 MiB", | ||
"logicalVolumes": [ | ||
{ | ||
"name": "root", | ||
"size": { | ||
"min": "10 GiB" | ||
}, | ||
"encryption": { | ||
"luks2": { | ||
"password": "notsecret" | ||
} | ||
}, | ||
"filesystem": { | ||
"type": "btrfs", | ||
"path": "/" | ||
} | ||
}, | ||
{ | ||
"name": "home", | ||
"size": "5 GiB", | ||
"filesystem": { | ||
"type": "xfs", | ||
"path": "/home" | ||
} | ||
}, | ||
{ | ||
"alias": "lvm_thin_pool", | ||
"pool": true, | ||
"name": "pool", | ||
"size": { | ||
"min": "5 GiB" | ||
}, | ||
"stripes": 10, | ||
"stripeSize": "4 KiB" | ||
}, | ||
{ | ||
"name": "data", | ||
"size": "100 GiB", | ||
"usedPool": "lvm_thin_pool" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} |
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,87 @@ | ||
# 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/configs" | ||
require "agama/storage/proposal_settings_reader" | ||
require "agama/storage/volume_templates_builder" | ||
|
||
module Agama | ||
module Storage | ||
# Class for building configs. | ||
class ConfigBuilder | ||
# @todo Replace product_config param by a ProductDefinition. | ||
# | ||
# @param product_config [Agama::Config] | ||
def initialize(product_config) | ||
@product_config = product_config | ||
end | ||
|
||
# Default encryption config from the product definition. | ||
# | ||
# @return [Configs::Encryption] | ||
def default_encryption | ||
Configs::Encryption.new.tap do |config| | ||
config.password = settings.encryption.password | ||
config.method = settings.encryption.method | ||
config.pbkd_function = settings.encryption.pbkd_function | ||
end | ||
end | ||
|
||
# Default format config from the product definition. | ||
# | ||
# @param path [String, nil] | ||
# @return [Configs::Filesystem] | ||
def default_filesystem(path = nil) | ||
Configs::Filesystem.new.tap do |config| | ||
config.type = default_fstype(path) | ||
end | ||
end | ||
|
||
private | ||
|
||
# @return [Agama::Config] | ||
attr_reader :product_config | ||
|
||
# Default filesystem type config from the product definition. | ||
# | ||
# @param path [String, nil] | ||
# @return [Configs::FilesystemType] | ||
def default_fstype(path = nil) | ||
volume = volume_builder.for(path || "") | ||
|
||
Configs::FilesystemType.new.tap do |config| | ||
config.fs_type = volume.fs_type | ||
config.btrfs = volume.btrfs | ||
end | ||
end | ||
|
||
# @return [ProposalSettings] | ||
def settings | ||
@settings ||= ProposalSettingsReader.new(product_config).read | ||
end | ||
|
||
# @return [VolumeTemplatesBuilder] | ||
def volume_builder | ||
@volume_builder ||= VolumeTemplatesBuilder.new_from_config(product_config) | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.