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: IssueClasses::Config::ALIAS
kind: IssueClasses::Config::OVERUSED_DEVICE
)
end

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

Expand All @@ -122,7 +122,7 @@ def partitioned_issue
),
config.alias
),
kind: IssueClasses::Config::OVERUSED
kind: IssueClasses::Config::OVERUSED_DEVICE
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion service/lib/agama/storage/config_checkers/boot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: IssueClasses::Config::ALIAS
kind: IssueClasses::Config::NO_SUCH_ALIAS
)
end

Expand Down
14 changes: 6 additions & 8 deletions service/lib/agama/storage/config_checkers/encryption.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ def encryption
config.encryption
end

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

# @return [Issue, nil]
def missing_password_issue
return unless encryption.missing_password?
Expand All @@ -77,7 +72,8 @@ def missing_password_issue
# (e.g., 'luks1', 'random_swap').
_("No passphrase provided (required for using the method '%{crypt_method}')."),
crypt_method: encryption.method.to_human_string
)
),
kind: IssueClasses::Config::NO_ENCRYPTION_PASSPHRASE
)
end

Expand All @@ -92,7 +88,8 @@ def unavailable_method_issue
# (e.g., 'luks1', 'random_swap').
_("Encryption method '%{crypt_method}' is not available in this system."),
crypt_method: method.to_human_string
)
),
kind: IssueClasses::Config::WRONG_ENCRYPTION_METHOD
)
end

Expand All @@ -119,7 +116,8 @@ def wrong_method_issue
# (e.g., 'luks1', 'random_swap').
_("'%{crypt_method}' is not a suitable method to encrypt the device."),
crypt_method: method.to_human_string
)
),
kind: IssueClasses::Config::WRONG_ENCRYPTION_METHOD
)
end
end
Expand Down
13 changes: 6 additions & 7 deletions service/lib/agama/storage/config_checkers/filesystem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,16 @@ def filesystem
config.filesystem
end

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

# @return [Issue, nil]
def missing_filesystem_issue
return if filesystem.reuse?
return if filesystem.type&.fs_type

# TRANSLATORS: %s is replaced by a mount path (e.g., "/home").
error(format(_("Missing file system type for '%s'"), filesystem.path))
error(
format(_("Missing file system type for '%s'"), filesystem.path),
kind: IssueClasses::Config::NO_FILESYSTEM_TYPE
)
end

# @return [Issue, nil]
Expand All @@ -100,7 +98,8 @@ def invalid_filesystem_issue
_("The file system type '%{filesystem}' is not suitable for '%{path}'"),
filesystem: type.to_human_string,
path: path
)
),
kind: IssueClasses::Config::WRONG_FILESYSTEM_TYPE
)
end

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: IssueClasses::Config::REQUIRED_PATHS
kind: IssueClasses::Config::MISSING_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: IssueClasses::Config::ALIAS
kind: IssueClasses::Config::NO_SUCH_ALIAS
)
end
end
Expand Down
21 changes: 12 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: IssueClasses::Config::ALIAS
kind: IssueClasses::Config::NO_SUCH_ALIAS
)
end

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

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

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

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

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

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

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

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

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def wrong_method_issue
# (e.g., 'luks1').
_("'%{method}' is not a suitable method to encrypt the physical volumes."),
method: method.to_human_string
)
),
kind: IssueClasses::Config::WRONG_ENCRYPTION_METHOD
)
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: IssueClasses::Config::SEARCH)
super(message, kind: IssueClasses::Config::SEARCH_NOT_FOUND)
end

# @return [Issue, nil]
Expand Down
11 changes: 7 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,10 @@ def issues
def name_issue
return if config.name && !config.name.empty?

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

# Issues from logical volumes.
Expand Down Expand Up @@ -104,7 +107,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: IssueClasses::Config::ALIAS
kind: IssueClasses::Config::NO_SUCH_ALIAS
)
end

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

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

Expand Down
57 changes: 34 additions & 23 deletions service/lib/agama/storage/issue_classes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,44 +23,55 @@ 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
# It was not possible to accommodate the requested devices
PROPOSAL = :proposal

# Issue classes related to the configuration provided by the user
module Config
# Generic issue with encryption settings
ENCRYPTION = :configEncryption
# A device is used for several incompatible purposes
OVERUSED_DEVICE = :configOverusedDevice

# Generic issue with filesystem settings
FILESYSTEM = :configFilesystem
# A device is used by several volume groups as a target for generating PVs
OVERUSED_PV_TARGET = :configOverusedPvTarget

# Generic issue defining LVM (eg. no volume group name)
LVM = :configLvm
# A device that is part of a reused RAID is chosen to be used with other purpose
MISUSED_MD_MEMBER = :configMisusedMdMember

# Generic issue defining Md RAIDs (eg. no level)
MD_RAID = :configMdRaid
# Reused and new devices are both used as target for generating PVs for the same LV
INCOMPATIBLE_PV_TARGETS = :configIncompatiblePvTargets

# No root filesystem was defined
NO_ROOT = :configNoRoot

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

# A mandatory separate filesystem is missing in the configuration
REQUIRED_PATHS = :configRequiredPaths
# The referenced alias does not exist in the context it was expected
NO_SUCH_ALIAS = :configNoSuchAlias

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

# 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 passphrase is required for the encryption but it was not provided
NO_ENCRYPTION_PASSPHRASE = :configNoEncryptionPassphrase

# A device is used by several volume groups as a target for generating PVs
OVERUSED_PV_TARGET = :configOverusedPvTarget
# The specified encryption method cannot be used
WRONG_ENCRYPTION_METHOD = :configWrongEncryptionMethod

# A filesystem type is required but it was not specified
NO_FILESYSTEM_TYPE = :configNoFilesystemType

# The specified filesystem type is not suitable for that mount path
WRONG_FILESYSTEM_TYPE = :configWrongFilesystemType

# One or several mandatory separate filesystems are missing in the configuration
MISSING_PATHS = :configMissingPaths

# No level was defined for a new MD RAID
NO_RAID_LEVEL = :configNoRaidLevel

# The number of members for a new RAID is not compatible with the chosen level
WRONG_RAID_MEMBERS = :configNoRaidMembers

# A device is part of a RAID and also chosen for an incompatible purpose
OVERUSED_MD_MEMBER = :configOverusedMdMember
# No name was specified for a new LVM volume group
NO_VOLUME_GROUP_NAME = :configNoVolumeGroupName
end
end
end
Expand Down
Loading
Loading