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
6 changes: 3 additions & 3 deletions service/lib/agama/storage/config_checkers/alias.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def overused_alias_issue

error(
format(_("The device with alias '%s' is used by more than one device"), config.alias),
kind: :overused_alias
kind: IssueClasses::Config::ALIAS
)
end

Expand All @@ -98,7 +98,7 @@ def formatted_issue
),
config.alias
),
kind: :formatted_with_user
kind: IssueClasses::Config::OVERUSED
)
end

Expand All @@ -122,7 +122,7 @@ def partitioned_issue
),
config.alias
),
kind: :partitioned_with_user
kind: IssueClasses::Config::OVERUSED
)
end
end
Expand Down
1 change: 1 addition & 0 deletions service/lib/agama/storage/config_checkers/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# find current contact information at www.suse.com.

require "agama/issue"
require "agama/storage/issue_classes"

module Agama
module Storage
Expand Down
4 changes: 2 additions & 2 deletions service/lib/agama/storage/config_checkers/boot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def missing_alias_issue

error(
_("The boot device cannot be automatically selected"),
kind: :no_root
kind: IssueClasses::Config::NO_ROOT
)
end

Expand All @@ -84,7 +84,7 @@ def invalid_alias_issue
# TRANSLATORS: %s is replaced by a device alias (e.g., "boot").
error(
format(_("There is no boot device with alias '%s'"), device_alias),
kind: :no_such_alias
kind: IssueClasses::Config::ALIAS
)
end

Expand Down
2 changes: 1 addition & 1 deletion service/lib/agama/storage/config_checkers/encryption.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def encryption

# @see Base
def error(message)
super(message, kind: :encryption)
super(message, kind: IssueClasses::Config::ENCRYPTION)
end

# @return [Issue, nil]
Expand Down
2 changes: 1 addition & 1 deletion service/lib/agama/storage/config_checkers/filesystem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def filesystem

# @see Base
def error(message)
super(message, kind: :filesystem)
super(message, kind: IssueClasses::Config::FILESYSTEM)
end

# @return [Issue, nil]
Expand Down
2 changes: 1 addition & 1 deletion service/lib/agama/storage/config_checkers/filesystems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def missing_paths_issue
),
missing_paths.join(", ")
),
kind: :required_filesystems
kind: IssueClasses::Config::REQUIRED_PATHS
)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def missing_thin_pool_issue
error(
# TRANSLATORS: %s is the replaced by a device alias (e.g., "pv1").
format(_("There is no LVM thin pool volume with alias '%s'"), config.used_pool),
kind: :no_such_alias
kind: IssueClasses::Config::ALIAS
)
end
end
Expand Down
18 changes: 9 additions & 9 deletions service/lib/agama/storage/config_checkers/md_raid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def missing_device_issue(device_alias)
error(
# TRANSLATORS: %s is the replaced by a device alias (e.g., "md1").
format(_("There is no MD RAID member device with alias '%s'"), device_alias),
kind: :no_such_alias
kind: IssueClasses::Config::ALIAS
)
end

Expand All @@ -107,7 +107,7 @@ def level_issue
return if config.level
return unless config.create?

error(format(_("There is a MD RAID without level")), kind: :md_raid)
error(format(_("There is a MD RAID without level")), kind: IssueClasses::Config::MD_RAID)
end

# Issue if the MD RAID does not contain enough member devices.
Expand All @@ -119,7 +119,7 @@ def devices_size_issue

error(
format(_("At least %s devices are required for %s"), config.min_devices, config.level),
kind: :md_raid
kind: IssueClasses::Config::MD_RAID
)
end

Expand Down Expand Up @@ -174,7 +174,7 @@ def deleted_reused_member_issue(member_config)
member: member_config.found_device.name,
md_raid: config.found_device.name
),
kind: :reused_md_member
kind: IssueClasses::Config::OVERUSED_MD_MEMBER
)
end

Expand All @@ -197,7 +197,7 @@ def resized_reused_member_issue(member_config)
member: member_config.found_device.name,
md_raid: config.found_device.name
),
kind: :reused_md_member
kind: IssueClasses::Config::OVERUSED_MD_MEMBER
)
end

Expand All @@ -220,7 +220,7 @@ def formatted_reused_member_issue(member_config)
member: member_config.found_device.name,
md_raid: config.found_device.name
),
kind: :reused_md_member
kind: IssueClasses::Config::OVERUSED_MD_MEMBER
)
end

Expand All @@ -243,7 +243,7 @@ def partitioned_reused_member_issue(member_config)
member: member_config.found_device.name,
md_raid: config.found_device.name
),
kind: :reused_md_member
kind: IssueClasses::Config::OVERUSED_MD_MEMBER
)
end

Expand All @@ -265,7 +265,7 @@ def target_reused_member_issue(member_config)
member: member_config.found_device.name,
md_raid: config.found_device.name
),
kind: :reused_md_member
kind: IssueClasses::Config::OVERUSED_MD_MEMBER
)
end

Expand All @@ -290,7 +290,7 @@ def parent_reused_member_issue(device)
device: parent_config.found_device.name,
md_raid: config.found_device.name
),
kind: :reused_md_member
kind: IssueClasses::Config::OVERUSED_MD_MEMBER
)
end

Expand Down
2 changes: 1 addition & 1 deletion service/lib/agama/storage/config_checkers/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def search

# @see Base
def error(message)
super(message, kind: :search)
super(message, kind: IssueClasses::Config::SEARCH)
end

# @return [Issue, nil]
Expand Down
8 changes: 4 additions & 4 deletions service/lib/agama/storage/config_checkers/volume_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def issues
def name_issue
return if config.name && !config.name.empty?

error(_("There is a volume group without name"))
error(_("There is a volume group without name"), kind: IssueClasses::Config::LVM)
end

# Issues from logical volumes.
Expand Down Expand Up @@ -104,7 +104,7 @@ def missing_physical_volume_issue(pv_alias)
error(
# TRANSLATORS: %s is the replaced by a device alias (e.g., "pv1").
format(_("There is no LVM physical volume with alias '%s'"), pv_alias),
kind: :no_such_alias
kind: IssueClasses::Config::ALIAS
)
end

Expand Down Expand Up @@ -136,7 +136,7 @@ def incompatible_physical_volumes_devices_issue
),
config.name
),
kind: :incompatible_pv_targets
kind: IssueClasses::Config::LVM
)
end

Expand All @@ -153,7 +153,7 @@ def missing_physical_volumes_device_issue(device_alias)
_("There is no target device for LVM physical volumes with alias '%s'"),
device_alias
),
kind: :no_such_alias
kind: IssueClasses::Config::ALIAS
)
end

Expand Down
2 changes: 1 addition & 1 deletion service/lib/agama/storage/config_checkers/volume_groups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def overused_physical_volumes_devices_issues
_("The device '%s' is used several times as target device for physical volumes"),
device
),
kind: :vg_target_devices
kind: IssueClasses::Config::OVERUSED_PV_TARGET
)
end
end
Expand Down
67 changes: 67 additions & 0 deletions service/lib/agama/storage/issue_classes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# frozen_string_literal: true

# Copyright (c) [2025] 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 Agama
module Storage
# Module to declare all the known issue classes from the storage scope
module IssueClasses
# Generic issue found when calculating the proposal
PROPOSAL = :proposal

# Issue classes related to the configuration provided by the user
module Config
# Generic issue with encryption settings
ENCRYPTION = :configEncryption

# Generic issue with filesystem settings
FILESYSTEM = :configFilesystem

# Generic issue defining LVM (eg. no volume group name)
LVM = :configLvm

# Generic issue defining Md RAIDs (eg. no level)
MD_RAID = :configMdRaid

# No root filesystem was defined
NO_ROOT = :configNoRoot

# Issue with aliases (eg. same alias defined twice or referencing a non-existent alias)
ALIAS = :configAlias

# A mandatory separate filesystem is missing in the configuration
REQUIRED_PATHS = :configRequiredPaths

# The device specified in a 'search' was not found
SEARCH = :configSearch

# Generic issue when a single device is used for several incompatible purposes
# (eg. to be formatted and also to be an LVM physical volume)
OVERUSED = :configOverused

# A device is used by several volume groups as a target for generating PVs
OVERUSED_PV_TARGET = :configOverusedPvTarget

# A device is part of a RAID and also chosen for an incompatible purpose
OVERUSED_MD_MEMBER = :configOverusedMdMember
end
end
end
end
5 changes: 3 additions & 2 deletions service/lib/agama/storage/proposal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
require "agama/storage/config_solver"
require "agama/storage/model_support_checker"
require "agama/storage/proposal_strategies"
require "agama/storage/issue_classes"
require "agama/storage/system"
require "json"
require "yast"
Expand Down Expand Up @@ -302,7 +303,7 @@ def storage_manager
def failed_issue
Issue.new(
_("Cannot calculate a valid storage setup with the current configuration"),
kind: :proposal
kind: IssueClasses::PROPOSAL
)
end

Expand All @@ -312,7 +313,7 @@ def failed_issue
def exception_issue(error)
Issue.new(
_("A problem ocurred while calculating the storage setup"),
kind: :proposal,
kind: IssueClasses::PROPOSAL,
details: error.message
)
end
Expand Down
18 changes: 9 additions & 9 deletions service/test/agama/storage/config_checker_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
it "includes the boot issues" do
issues = subject.issues
expect(issues).to include an_object_having_attributes(
kind: :no_root,
kind: Agama::Storage::IssueClasses::Config::NO_ROOT,
description: "The boot device cannot be automatically selected"
)
end
Expand All @@ -74,7 +74,7 @@
it "includes the drive issues" do
issues = subject.issues
expect(issues).to include an_object_having_attributes(
kind: :search,
kind: Agama::Storage::IssueClasses::Config::SEARCH,
description: "Mandatory device /dev/vda not found"
)
end
Expand All @@ -94,7 +94,7 @@
it "includes the partition issues" do
issues = subject.issues
expect(issues).to include an_object_having_attributes(
kind: :filesystem,
kind: Agama::Storage::IssueClasses::Config::FILESYSTEM,
description: "Missing file system type for '/'"
)
end
Expand All @@ -110,7 +110,7 @@
it "includes the MD RAID issues" do
issues = subject.issues
expect(issues).to include an_object_having_attributes(
kind: :no_such_alias,
kind: Agama::Storage::IssueClasses::Config::ALIAS,
description: /no MD RAID member device with alias 'disk1'/
)
end
Expand All @@ -130,7 +130,7 @@
it "includes the partition issues" do
issues = subject.issues
expect(issues).to include an_object_having_attributes(
kind: :filesystem,
kind: Agama::Storage::IssueClasses::Config::FILESYSTEM,
description: "Missing file system type for '/'"
)
end
Expand Down Expand Up @@ -165,7 +165,7 @@
it "includes the logical volume issues" do
issues = subject.issues
expect(issues).to include an_object_having_attributes(
kind: :filesystem,
kind: Agama::Storage::IssueClasses::Config::FILESYSTEM,
description: "Missing file system type for '/'"
)
end
Expand Down Expand Up @@ -203,15 +203,15 @@
it "includes an issue for the missing mount path" do
issues = subject.issues
expect(issues).to include an_object_having_attributes(
kind: :required_filesystems,
kind: Agama::Storage::IssueClasses::Config::REQUIRED_PATHS,
description: /file system for \/ is/
)
end

it "does not include an issue for the present mount path" do
issues = subject.issues
expect(issues).to_not include an_object_having_attributes(
kind: :required_filesystems,
kind: Agama::Storage::IssueClasses::Config::REQUIRED_PATHS,
description: /file system for swap/
)
end
Expand Down Expand Up @@ -265,7 +265,7 @@
it "includes the expected issues" do
issues = subject.issues
expect(issues).to include an_object_having_attributes(
kind: :vg_target_devices,
kind: Agama::Storage::IssueClasses::Config::OVERUSED_PV_TARGET,
description: /The device 'disk1' is used several times/
)
end
Expand Down
Loading
Loading