Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion rust/agama-lib/share/storage.model.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,15 @@
"reuse": { "type": "boolean" },
"default": { "type": "boolean" },
"type": { "$ref": "#/$defs/filesystemType" },
"snapshots": { "type": "boolean" },
"label": { "type": "string" }
}
},
"filesystemType": {
"enum": [
"bcachefs",
"btrfs",
"btrfsImmutable",
"btrfsSnapshots",
"exfat",
"ext2",
"ext3",
Expand Down
7 changes: 0 additions & 7 deletions rust/agama-lib/src/storage/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,6 @@ pub struct VolumeOutline {
fs_types: Vec<String>,
support_auto_size: bool,
adjust_by_ram: bool,
snapshots_configurable: bool,
snapshots_affect_sizes: bool,
size_relevant_volumes: Vec<String>,
}
Expand All @@ -414,7 +413,6 @@ impl TryFrom<zbus::zvariant::Value<'_>> for VolumeOutline {
fs_types: get_property(&mvalue, "FsTypes")?,
support_auto_size: get_property(&mvalue, "SupportAutoSize")?,
adjust_by_ram: get_property(&mvalue, "AdjustByRam")?,
snapshots_configurable: get_property(&mvalue, "SnapshotsConfigurable")?,
snapshots_affect_sizes: get_property(&mvalue, "SnapshotsAffectSizes")?,
size_relevant_volumes: get_property(&mvalue, "SizeRelevantVolumes")?,
};
Expand All @@ -435,8 +433,6 @@ pub struct Volume {
min_size: Option<DeviceSize>,
max_size: Option<DeviceSize>,
auto_size: bool,
snapshots: bool,
transactional: Option<bool>,
outline: Option<VolumeOutline>,
}

Expand All @@ -448,7 +444,6 @@ impl From<Volume> for zbus::zvariant::Value<'_> {
("Target", val.target.into()),
("FsType", Value::new(val.fs_type)),
("AutoSize", Value::new(val.auto_size)),
("Snapshots", Value::new(val.snapshots)),
]);
if let Some(dev) = val.target_device {
result.insert("TargetDevice", Value::new(dev));
Expand Down Expand Up @@ -487,8 +482,6 @@ impl TryFrom<HashMap<String, OwnedValue>> for Volume {
min_size: get_optional_property(&volume_hash, "MinSize")?,
max_size: get_optional_property(&volume_hash, "MaxSize")?,
auto_size: get_property(&volume_hash, "AutoSize")?,
snapshots: get_property(&volume_hash, "Snapshots")?,
transactional: get_optional_property(&volume_hash, "Transactional")?,
outline: get_optional_property(&volume_hash, "Outline")?,
};

Expand Down
6 changes: 6 additions & 0 deletions rust/package/agama.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Fri Jan 30 16:27:35 UTC 2026 - Ancor Gonzalez Sosa <ancor@suse.com>

- Update schemas for storage model and volume templates (related to
jsc#PED-14307).

-------------------------------------------------------------------
Fri Jan 30 11:00:08 UTC 2026 - Knut Anderssen <kanderssen@suse.com>

Expand Down
2 changes: 2 additions & 0 deletions rust/share/device.storage.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@
"enum": [
"bcachefs",
"btrfs",
"btrfsSnapshots",
"btrfsImmutable",
"exfat",
"ext2",
"ext3",
Expand Down
3 changes: 0 additions & 3 deletions rust/share/system.storage.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@
"autoSize": { "type": "boolean" },
"minSize": { "type": "integer" },
"maxSize": { "type": "integer" },
"snapshots": { "type": "boolean" },
"transactional": { "type": "boolean" },
"outline": { "$ref": "#/$defs/volumeOutline" }
}
},
Expand All @@ -89,7 +87,6 @@
"items": { "$ref": "device.storage.schema.json#/$defs/filesystemType" }
},
"adjustByRam": { "type": "boolean" },
"snapshotsConfigurable": { "type": "boolean" },
"snapshotsAffectSizes": { "type": "boolean" },
"sizeRelevantVolumes": {
"type": "array",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,16 @@ def convert_type
value = filesystem_model[:type]
return unless value

value = "btrfs" if value.start_with?("btrfs")
Y2Storage::Filesystems::Type.find(value.to_sym)
end

# @return [Configs::Btrfs, nil]
def convert_btrfs
return unless filesystem_model[:type] == "btrfs"
type = filesystem_model[:type]
return unless type&.start_with?("btrfs")

Configs::Btrfs.new.tap { |c| c.snapshots = filesystem_model[:snapshots] }
Configs::Btrfs.new.tap { |c| c.snapshots = type != "btrfs" }
end
end
end
Expand Down
9 changes: 7 additions & 2 deletions service/lib/agama/storage/config_conversions/to_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,26 @@ module ConfigConversions
# Config conversion to model according to the JSON schema.
class ToModel
# @param config [Storage::Config]
def initialize(config)
# @param product_config [Agama::Config, nil] Agama config
def initialize(config, product_config = nil)
@config = config
@product_config = product_config
end

# Performs the conversion to config model according to the JSON schema.
#
# @return [Hash]
def convert
ToModelConversions::Config.new(config).convert
ToModelConversions::Config.new(config, product_config).convert
end

private

# @return [Storage::Config]
attr_reader :config

# @return [Agama::Config, nil]
attr_reader :product_config
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,18 @@ module ToModelConversions
# Config conversion to model according to the JSON schema.
class Config < Base
# @param config [Storage::Config]
def initialize(config)
# @param product_config [Agama::Config, nil]
def initialize(config, product_config)
super()
@config = config
@product_config = product_config
end

private

# @return [Agama::Config, nil]
attr_reader :product_config

# @see Base#conversions
def conversions
{
Expand All @@ -66,17 +71,33 @@ def convert_encryption

# @return [Array<Hash>]
def convert_drives
config.valid_drives.map { |d| ToModelConversions::Drive.new(d).convert }
config.valid_drives.map do |drive|
ToModelConversions::Drive.new(drive, volumes).convert
end
end

# @return [Array<Hash>]
def convert_md_raids
config.valid_md_raids.map { |r| ToModelConversions::MdRaid.new(r).convert }
config.valid_md_raids.map do |raid|
ToModelConversions::MdRaid.new(raid, volumes).convert
end
end

# @return [Array<Hash>]
def convert_volume_groups
config.volume_groups.map { |v| ToModelConversions::VolumeGroup.new(v, config).convert }
config.volume_groups.map do |vol|
ToModelConversions::VolumeGroup.new(vol, config, volumes).convert
end
end

# @return [VolumeTemplatesBuilder]
def volumes
@volumes ||=
if product_config
VolumeTemplatesBuilder.new_from_config(product_config)
else
VolumeTemplatesBuilder.new([])
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,18 @@ class Drive < Base
include WithSpacePolicy

# @param config [Configs::Drive]
def initialize(config)
# @param volumes [VolumeTemplatesBuilder]
def initialize(config, volumes)
super()
@config = config
@volumes = volumes
end

private

# @return [VolumeTemplatesBuilder]
attr_reader :volumes

# @see Base#conversions
def conversions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,25 @@ module ToModelConversions
# Drive conversion to model according to the JSON schema.
class Filesystem < Base
# @param config [Configs::Filesystem]
def initialize(config)
# @param volumes [VolumeTemplatesBuilder]
def initialize(config, volumes)
super()
@config = config
@volumes = volumes
end

private

# @return [VolumeTemplatesBuilder]
attr_reader :volumes

# @see Base#conversions
def conversions
{
reuse: config.reuse?,
default: convert_default,
type: convert_type,
snapshots: convert_snapshots,
label: config.label
reuse: config.reuse?,
default: convert_default,
type: convert_type,
label: config.label
}
end

Expand All @@ -57,14 +61,27 @@ def convert_default
def convert_type
return unless config.type&.fs_type

if config.type.fs_type.is?(:btrfs)
return "btrfsImmutable" if immutable?
return "btrfsSnapshots" if snapshots?
end

config.type.fs_type.to_s
end

# @return [Boolean, nil]
def convert_snapshots
return unless config.type&.fs_type&.is?(:btrfs)
# @return [Boolean]
def snapshots?
!!config.type.btrfs&.snapshots?
end

# @return [Boolean]
def immutable?
return false unless config.path

volume = volumes.for(config.path)
return false unless volume

config.type.btrfs&.snapshots?
!!volume.btrfs&.read_only?
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,18 @@ class LogicalVolume < Base
include WithSize

# @param config [Configs::LogicalVolume]
def initialize(config)
# @param volumes [VolumeTemplatesBuilder]
def initialize(config, volumes)
super()
@config = config
@volumes = volumes
end

private

# @return [VolumeTemplatesBuilder]
attr_reader :volumes

# @see Base#conversions
def conversions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,18 @@ class MdRaid < Base
include WithSpacePolicy

# @param config [Configs::MdRaid]
def initialize(config)
# @param volumes [VolumeTemplatesBuilder]
def initialize(config, volumes)
super()
@config = config
@volumes = volumes
end

private

# @return [VolumeTemplatesBuilder]
attr_reader :volumes

# @see Base#conversions
def conversions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@ class Partition < Base
include WithSize

# @param config [Configs::Partition]
def initialize(config)
def initialize(config, volumes)
super()
@config = config
@volumes = volumes
end

private

# @return [VolumeTemplatesBuilder]
attr_reader :volumes

# @see Base#conversions
def conversions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,22 @@ class VolumeGroup < Base

# @param config [Configs::VolumeGroup]
# @param storage_config [Storage::Config]
def initialize(config, storage_config)
# @param volumes [VolumeTemplatesBuilder]
def initialize(config, storage_config, volumes)
super()
@config = config
@storage_config = storage_config
@volumes = volumes
end

private

# @return [Storage::Config]
attr_reader :storage_config

# @return [VolumeTemplatesBuilder]
attr_reader :volumes

# @see Base#conversions
def conversions
{
Expand All @@ -65,7 +70,7 @@ def convert_target_devices
# @return [Array<Hash>]
def convert_logical_volumes
config.logical_volumes.map do |logical_volume|
ToModelConversions::LogicalVolume.new(logical_volume).convert
ToModelConversions::LogicalVolume.new(logical_volume, volumes).convert
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def convert_filesystem
filesystem = config.filesystem
return unless filesystem

ToModelConversions::Filesystem.new(filesystem).convert
ToModelConversions::Filesystem.new(filesystem, volumes).convert
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module WithPartitions
def convert_partitions
config.partitions
.reject(&:skipped?)
.map { |p| ToModelConversions::Partition.new(p).convert }
.map { |p| ToModelConversions::Partition.new(p, volumes).convert }
.compact
end
end
Expand Down
Loading
Loading