Skip to content

Commit

Permalink
WIP: some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joseivanlopez committed Jul 26, 2023
1 parent 2f41a60 commit 035f4f0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.

require "agama/dbus/storage/volume_conversion"

module Agama
module DBus
module Storage
Expand All @@ -38,7 +40,7 @@ def convert # rubocop:disable Metrics/AbcSize
"BootDevice" => settings.boot_device.to_s,
"LVM" => settings.lvm.enabled,
"SystemVGDevices" => settings.lvm.system_vg_devices,
"EncryptionPassword" => settings.encryption.password,
"EncryptionPassword" => settings.encryption.password.to_s,
"EncryptionMethod" => settings.encryption.method.id.to_s,
"EncryptionPBKDFunction" => settings.encryption.pbkd_function&.value || "",
"SpacePolicy" => settings.space.policy.to_s,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def convert
"MountOptions" => volume.mount_options,
"TargetDevice" => volume.device.to_s,
"TargetVG" => volume.separate_vg_name.to_s,
"FsType" => volume.fs_type&.to_human_string,
"FsType" => volume.fs_type&.to_human_string || "",
"MinSize" => volume.min_size&.to_i,
"MaxSize" => volume.max_size&.to_i,
"AutoSize" => volume.auto_size?,
Expand Down
2 changes: 1 addition & 1 deletion service/lib/agama/storage/proposal_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ProposalSettings
# Device name of the disk that will be used for booting the system and also to allocate all
# the partitions, except those that have been explicitly assigned to other disk(s).
#
# @return [String]
# @return [String, nil]
attr_accessor :boot_device

# Set of volumes to create
Expand Down
14 changes: 12 additions & 2 deletions service/lib/agama/storage/volume.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 "forwardable"
require "y2storage/disk_size"
require "agama/storage/btrfs_settings"
require "agama/storage/volume_outline"

Expand All @@ -44,7 +45,7 @@ class Volume

# Filesystem for the volume
#
# @return [Y2Storage::Filesystems::Type]
# @return [Y2Storage::Filesystems::Type, nil]
attr_accessor :fs_type

# Btrfs-related options
Expand All @@ -57,8 +58,14 @@ class Volume
# @return [Array<String>]
attr_accessor :mount_options

# These two would be used to locate the volume in a separate disk
# Used to locate the volume in a separate disk
#
# @return [String, nil]
attr_accessor :device

# Used to locate the volume in a separate VG
#
# @return [String, nil]
attr_accessor :separate_vg_name

# Min size for the volume
Expand Down Expand Up @@ -86,6 +93,9 @@ class Volume
def initialize(mount_path)
@mount_path = mount_path
@mount_options = []
@auto_size = false
@min_size = Y2Storage::DiskSize.zero
@max_size = Y2Storage::DiskSize.zero
@btrfs = BtrfsSettings.new
@outline = VolumeOutline.new
end
Expand Down
8 changes: 7 additions & 1 deletion service/lib/agama/storage/volume_outline.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 "pathname"
require "y2storage/disk_size"

module Agama
module Storage
Expand Down Expand Up @@ -51,6 +52,7 @@ class VolumeOutline
# @return [Y2Storage::DiskSize]
attr_accessor :base_max_size

# @return [Boolean]
attr_accessor :adjust_by_ram
alias_method :adjust_by_ram?, :adjust_by_ram

Expand All @@ -77,6 +79,9 @@ class VolumeOutline
attr_accessor :snapshots_percentage

def initialize
@required = false
@adjust_by_ram = false
@snapshots_configurable = true
@filesystems = []
@base_min_size = Y2Storage::DiskSize.zero
@base_max_size = Y2Storage::DiskSize.unlimited
Expand All @@ -97,8 +102,9 @@ def size_relevant_volumes
# @return [Boolean]
def snapshots_affect_sizes?
return true if snapshots_size && !snapshots_size.zero?
return false unless snapshots_percentage

snapshots_percentage && !snapshots_percentage.zero?
!snapshots_percentage.zero?
end

# Whether it makes sense to have automatic size limits for the volume
Expand Down

0 comments on commit 035f4f0

Please sign in to comment.