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
104 changes: 104 additions & 0 deletions rust/agama-lib/share/storage.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@
"required": ["name"],
"properties": {
"name": { "$ref": "#/$defs/baseName" },
"search": { "$ref": "#/$defs/volumeGroupSearch" },
"extentSize": { "$ref": "#/$defs/sizeValue" },
"physicalVolumes": {
"description": "Devices to use as physical volumes.",
Expand Down Expand Up @@ -328,6 +329,7 @@
"additionalProperties": false,
"properties": {
"name": { "$ref": "#/$defs/baseName" },
"search": { "$ref": "#/$defs/logicalVolumeSearch" },
"size": { "$ref": "#/$defs/size" },
"stripes": { "$ref": "#/$defs/logicalVolumeStripes" },
"stripeSize": { "$ref": "#/$defs/sizeValue" },
Expand Down Expand Up @@ -476,6 +478,57 @@
"minProperties": 1,
"maxProperties": 1
},
"volumeGroupSearch": {
"anyOf": [
{ "$ref": "#/$defs/searchAll" },
{ "$ref": "#/$defs/searchName" },
{ "$ref": "#/$defs/volumeGroupAdvancedSearch" }
]
},
"volumeGroupAdvancedSearch": {
"type": "object",
"additionalProperties": false,
"properties": {
"condition": { "$ref": "#/$defs/volumeGroupSearchCondition" },
"sort": { "$ref": "#/$defs/volumeGroupSearchSort" },
"max": { "$ref": "#/$defs/searchMax" },
"ifNotFound": { "$ref": "#/$defs/searchCreatableActions" }
}
},
"volumeGroupSearchCondition": {
"anyOf": [
{ "$ref": "#/$defs/searchConditionName" },
{ "$ref": "#/$defs/searchConditionSize" }
]
},
"volumeGroupSearchSort": {
"anyOf": [
{ "$ref": "#/$defs/volumeGroupSearchSortCriterion" },
{
"type": "array",
"items": { "$ref": "#/$defs/volumeGroupSearchSortCriterion" }
}
]
},
"volumeGroupSearchSortCriterion": {
"anyOf": [
{ "$ref": "#/$defs/volumeGroupSearchSortCriterionShort" },
{ "$ref": "#/$defs/volumeGroupSearchSortCriterionFull" }
]
},
"volumeGroupSearchSortCriterionShort": {
"enum": ["name", "size"]
},
"volumeGroupSearchSortCriterionFull": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": { "$ref": "#/$defs/searchSortCriterionOrder" },
"size": { "$ref": "#/$defs/searchSortCriterionOrder" }
},
"minProperties": 1,
"maxProperties": 1
},
"partitionSearch": {
"anyOf": [
{ "$ref": "#/$defs/searchAll" },
Expand Down Expand Up @@ -517,6 +570,29 @@
{ "$ref": "#/$defs/searchConditionPartitionNumber" }
]
},
"logicalVolumeSearch": {
"anyOf": [
{ "$ref": "#/$defs/searchAll" },
{ "$ref": "#/$defs/searchName" },
{ "$ref": "#/$defs/logicalVolumeAdvancedSearch" }
]
},
"logicalVolumeAdvancedSearch": {
"type": "object",
"additionalProperties": false,
"properties": {
"condition": { "$ref": "#/$defs/logicalVolumeSearchCondition" },
"sort": { "$ref": "#/$defs/logicalVolumeSearchSort" },
"max": { "$ref": "#/$defs/searchMax" },
"ifNotFound": { "$ref": "#/$defs/searchCreatableActions" }
}
},
"logicalVolumeSearchCondition": {
"anyOf": [
{ "$ref": "#/$defs/searchConditionName" },
{ "$ref": "#/$defs/searchConditionSize" }
]
},
"searchConditionName": {
"type": "object",
"additionalProperties": false,
Expand Down Expand Up @@ -605,6 +681,34 @@
"minProperties": 1,
"maxProperties": 1
},
"logicalVolumeSearchSort": {
"anyOf": [
{ "$ref": "#/$defs/logicalVolumeSearchSortCriterion" },
{
"type": "array",
"items": { "$ref": "#/$defs/logicalVolumeSearchSortCriterion" }
}
]
},
"logicalVolumeSearchSortCriterion": {
"anyOf": [
{ "$ref": "#/$defs/logicalVolumeSearchSortCriterionShort" },
{ "$ref": "#/$defs/logicalVolumeSearchSortCriterionFull" }
]
},
"logicalVolumeSearchSortCriterionShort": {
"enum": ["name", "size", "number"]
},
"logicalVolumeSearchSortCriterionFull": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": { "$ref": "#/$defs/searchSortCriterionOrder" },
"size": { "$ref": "#/$defs/searchSortCriterionOrder" }
},
"minProperties": 1,
"maxProperties": 1
},
"searchMax": {
"description": "Maximum devices to match.",
"type": "integer",
Expand Down
2 changes: 1 addition & 1 deletion service/lib/agama/storage/config_checkers/volume_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def issues
#
# @return [Issue, nil]
def name_issue
return if config.name && !config.name.empty?
return if config.vg_name && !config.vg_name.empty?

error(
_("There is a volume group without name"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

# Copyright (c) [2024] SUSE LLC
# Copyright (c) [2024-2026] SUSE LLC
#
# All Rights Reserved.
#
Expand All @@ -23,6 +23,7 @@
require "agama/storage/config_conversions/from_json_conversions/with_encryption"
require "agama/storage/config_conversions/from_json_conversions/with_filesystem"
require "agama/storage/config_conversions/from_json_conversions/with_size"
require "agama/storage/config_conversions/from_json_conversions/with_search"
require "agama/storage/configs/logical_volume"
require "y2storage/disk_size"

Expand All @@ -37,6 +38,7 @@ class LogicalVolume < Base
include WithEncryption
include WithFilesystem
include WithSize
include WithSearch

# @see Base
# @return [Configs::LogicalVolume]
Expand All @@ -50,15 +52,18 @@ def default_config
# @return [Hash]
def conversions
{
alias: logical_volume_json[:alias],
encryption: convert_encryption,
filesystem: convert_filesystem,
size: convert_size,
name: logical_volume_json[:name],
stripes: logical_volume_json[:stripes],
stripe_size: convert_stripe_size,
pool: logical_volume_json[:pool],
used_pool: logical_volume_json[:usedPool]
alias: logical_volume_json[:alias],
search: convert_search,
encryption: convert_encryption,
filesystem: convert_filesystem,
size: convert_size,
name: logical_volume_json[:name],
stripes: logical_volume_json[:stripes],
stripe_size: convert_stripe_size,
pool: logical_volume_json[:pool],
used_pool: logical_volume_json[:usedPool],
delete: logical_volume_json[:delete],
delete_if_needed: logical_volume_json[:deleteIfNeeded]
}
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

# Copyright (c) [2024-2025] SUSE LLC
# Copyright (c) [2024-2026] SUSE LLC
#
# All Rights Reserved.
#
Expand All @@ -22,6 +22,7 @@
require "agama/storage/config_conversions/from_json_conversions/base"
require "agama/storage/config_conversions/from_json_conversions/encryption"
require "agama/storage/config_conversions/from_json_conversions/logical_volume"
require "agama/storage/config_conversions/from_json_conversions/with_search"
require "agama/storage/configs/volume_group"
require "y2storage/disk_size"

Expand All @@ -33,6 +34,8 @@ module FromJSONConversions
class VolumeGroup < Base
private

include WithSearch

alias_method :volume_group_json, :config_json

# @see Base
Expand All @@ -46,6 +49,7 @@ def default_config
def conversions
{
name: volume_group_json[:name],
search: convert_search,
extent_size: convert_extent_size,
physical_volumes_devices: convert_physical_volumes_devices,
physical_volumes_encryption: convert_physical_volumes_encryption,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

# Copyright (c) [2025] SUSE LLC
# Copyright (c) [2025-2026] SUSE LLC
#
# All Rights Reserved.
#
Expand All @@ -22,6 +22,7 @@
require "agama/storage/config_conversions/from_model_conversions/base"
require "agama/storage/config_conversions/from_model_conversions/with_filesystem"
require "agama/storage/config_conversions/from_model_conversions/with_size"
require "agama/storage/config_conversions/from_model_conversions/with_search"
require "agama/storage/configs/logical_volume"
require "y2storage/disk_size"

Expand All @@ -33,6 +34,7 @@ module FromModelConversions
class LogicalVolume < Base
include WithFilesystem
include WithSize
include WithSearch

private

Expand All @@ -49,6 +51,7 @@ def default_config
def conversions
{
name: logical_volume_model[:lvName],
search: convert_search,
filesystem: convert_filesystem,
size: convert_size,
stripes: logical_volume_model[:stripes],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

# Copyright (c) [2025] SUSE LLC
# Copyright (c) [2025-2026] SUSE LLC
#
# All Rights Reserved.
#
Expand All @@ -22,6 +22,7 @@
require "agama/storage/config_conversions/from_model_conversions/base"
require "agama/storage/config_conversions/from_model_conversions/logical_volume"
require "agama/storage/config_conversions/from_model_conversions/encryption"
require "agama/storage/config_conversions/from_model_conversions/with_search"
require "agama/storage/configs/volume_group"
require "y2storage/disk_size"

Expand All @@ -31,6 +32,8 @@ module ConfigConversions
module FromModelConversions
# Volume group conversion from model according to the JSON schema.
class VolumeGroup < Base
include WithSearch

# @param model_json [Hash]
# @param targets [Array<Configs::Drive, Configs::MdRaid>]
# @param encryption_model [Hash, nil]
Expand Down Expand Up @@ -61,6 +64,7 @@ def default_config
def conversions
{
name: volume_group_model[:vgName],
search: convert_search,
extent_size: convert_extent_size,
physical_volumes_devices: convert_physical_volumes_devices,
physical_volumes_encryption: convert_physical_volumes_encryption,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

# Copyright (c) [2024] SUSE LLC
# Copyright (c) [2024-2026] SUSE LLC
#
# All Rights Reserved.
#
Expand All @@ -23,6 +23,7 @@
require "agama/storage/config_conversions/to_json_conversions/with_encryption"
require "agama/storage/config_conversions/to_json_conversions/with_filesystem"
require "agama/storage/config_conversions/to_json_conversions/with_size"
require "agama/storage/config_conversions/to_json_conversions/with_search"

module Agama
module Storage
Expand All @@ -33,6 +34,8 @@ class LogicalVolume < Base
include WithEncryption
include WithFilesystem
include WithSize
include WithSearch
include WithDelete

# @param config [Configs::LogicalVolume]
def initialize(config)
Expand All @@ -44,8 +47,11 @@ def initialize(config)

# @see Base#conversions
def conversions
return convert_delete if convert_delete?

{
alias: config.alias,
search: convert_search,
encryption: convert_encryption,
filesystem: convert_filesystem,
size: convert_size,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
require "agama/storage/config_conversions/to_json_conversions/with_filesystem"
require "agama/storage/config_conversions/to_json_conversions/with_search"
require "agama/storage/config_conversions/to_json_conversions/with_size"
require "agama/storage/config_conversions/to_json_conversions/with_delete"

module Agama
module Storage
Expand All @@ -35,6 +36,7 @@ class Partition < Base
include WithEncryption
include WithFilesystem
include WithSize
include WithDelete

# @param config [Configs::Partition]
def initialize(config)
Expand All @@ -46,9 +48,7 @@ def initialize(config)

# @see Base#conversions
def conversions
return convert_delete if config.delete?

return convert_delete_if_needed if config.delete_if_needed?
return convert_delete if convert_delete?

{
search: convert_search,
Expand All @@ -59,23 +59,6 @@ def conversions
id: config.id&.to_s
}
end

# @return [Hash]
def convert_delete
{
search: convert_search,
delete: true
}
end

# @return [Hash]
def convert_delete_if_needed
{
search: convert_search,
size: convert_size,
deleteIfNeeded: true
}
end
end
end
end
Expand Down
Loading
Loading