Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find space section #1028

Merged
merged 39 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
fd4d7d2
[service] Export space actions on D-Bus
joseivanlopez Feb 7, 2024
0028356
[web] Add space actions to storage client
joseivanlopez Feb 7, 2024
63da546
[web] Add section for the space policy
joseivanlopez Feb 8, 2024
fd42444
[web] Improvements for storage client
joseivanlopez Feb 9, 2024
421ff9d
[web] Add space actions table
joseivanlopez Feb 14, 2024
1435add
[service] Add Filesystem D-Bus interface
joseivanlopez Feb 14, 2024
09c5be7
[web] Read file system properties
joseivanlopez Feb 14, 2024
bd2e005
[web] Show file system properties
joseivanlopez Feb 14, 2024
bae57b1
[web] Several improvements
joseivanlopez Feb 15, 2024
30d9d15
[web] CSS styles for tree table
joseivanlopez Feb 15, 2024
c9def51
[web] Adapt existing tests
joseivanlopez Feb 15, 2024
456d719
Merge remote-tracking branch 'origin/master' into space-policy-ui
dgdavid Feb 15, 2024
0203531
[web] Drop space-policy-utils.jsx file
dgdavid Feb 15, 2024
43cd45f
[service] Fix test
joseivanlopez Feb 15, 2024
0a0e05f
[service] Use D-Bus path instead of device name
joseivanlopez Feb 15, 2024
19245ee
[web] Adjust space policies descriptions
dgdavid Feb 16, 2024
8d432fb
[web] Adds a core/OptionPicker component
dgdavid Feb 16, 2024
c0b3fa1
[web] Improvements in the table of space actions
joseivanlopez Feb 16, 2024
c60afd2
[web] Minor improvements in space policy section
joseivanlopez Feb 16, 2024
8c7612c
[service] Add Component D-Bus interface
joseivanlopez Feb 16, 2024
41d2966
[web] Adapt storage client to changes in D-Bus API
joseivanlopez Feb 16, 2024
8e51494
[web] Add tests for ProposalSpacePolicySection
dgdavid Feb 18, 2024
fc908ac
[web] Reduce text
joseivanlopez Feb 19, 2024
89d4130
[web] Add properties to storage objects
joseivanlopez Feb 19, 2024
f1616eb
[web] Get #isDrive and #upartitionedSize from object
joseivanlopez Feb 19, 2024
43fff64
[web] Use better names for attributes and methods
joseivanlopez Feb 19, 2024
7e354a9
[web] Cspell
joseivanlopez Feb 19, 2024
7841cb4
[service] Typo
joseivanlopez Feb 19, 2024
d73aeb7
[web] Increase margin of sections
joseivanlopez Feb 19, 2024
9485f35
[web] Allow checking if a value is an object
dgdavid Feb 20, 2024
8e247ff
[web] Add method to reset localStorage in tests
dgdavid Feb 20, 2024
411664b
[service] Improve code for dynamically adding D-Bus interfaces
joseivanlopez Feb 20, 2024
cd387a6
[web] Add notes for translators
joseivanlopez Feb 20, 2024
819cdac
[web] More precise EFI description
joseivanlopez Feb 20, 2024
9fb9204
[web] Add missing documentation
joseivanlopez Feb 20, 2024
0cf99ca
[web] Add comment for explaining corner case
joseivanlopez Feb 20, 2024
e037e56
[web] Properly indent cspell
joseivanlopez Feb 20, 2024
2cb1298
[service] Changelog
joseivanlopez Feb 20, 2024
43e470c
[web] Changelog
joseivanlopez Feb 20, 2024
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
11 changes: 10 additions & 1 deletion service/lib/agama/dbus/storage/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
require "agama/dbus/storage/interfaces/md"
require "agama/dbus/storage/interfaces/block"
require "agama/dbus/storage/interfaces/partition_table"
require "agama/dbus/storage/interfaces/filesystem"

module Agama
module DBus
Expand Down Expand Up @@ -77,14 +78,15 @@ def storage_device=(value)
attr_reader :tree

# Adds the required interfaces according to the storage object
def add_interfaces # rubocop:disable Metrics/CyclomaticComplexity
def add_interfaces # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
joseivanlopez marked this conversation as resolved.
Show resolved Hide resolved
interfaces = []
interfaces << Interfaces::Drive if drive?
interfaces << Interfaces::Raid if storage_device.is?(:dm_raid)
interfaces << Interfaces::Md if storage_device.is?(:md)
interfaces << Interfaces::Multipath if storage_device.is?(:multipath)
interfaces << Interfaces::Block if storage_device.is?(:blk_device)
interfaces << Interfaces::PartitionTable if partition_table?
interfaces << Interfaces::Filesystem if filesystem?

interfaces.each { |i| singleton_class.include(i) }
end
Expand All @@ -110,6 +112,13 @@ def partition_table?
storage_device.respond_to?(:partition_table?) &&
storage_device.partition_table?
end

# Whether the storage device is formatted.
#
# @return [Boolean]
def filesystem?
!storage_device.filesystem.nil?
end
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion service/lib/agama/dbus/storage/interfaces.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

# Copyright (c) [2023] SUSE LLC
# Copyright (c) [2023-2024] SUSE LLC
#
# All Rights Reserved.
#
Expand Down Expand Up @@ -35,4 +35,5 @@ module Interfaces
require "agama/dbus/storage/interfaces/md"
require "agama/dbus/storage/interfaces/block"
require "agama/dbus/storage/interfaces/partition_table"
require "agama/dbus/storage/interfaces/filesystem"
require "agama/dbus/storage/interfaces/dasd_manager"
61 changes: 61 additions & 0 deletions service/lib/agama/dbus/storage/interfaces/filesystem.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# frozen_string_literal: true

# Copyright (c) [2024] 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.

require "dbus"

module Agama
module DBus
module Storage
module Interfaces
# Interface for file systems.
#
# @note This interface is intended to be included by {Device} if needed.
module Filesystem
FILESYSTEM_INTERFACE = "org.opensuse.Agama.Storage1.Filesystem"
private_constant :FILESYSTEM_INTERFACE

# File system type.
#
# @return [String] e.g., "ext4"
def filesystem_type
storage_device.filesystem.type.to_s
end

# Whether the file system contains an EFI.
joseivanlopez marked this conversation as resolved.
Show resolved Hide resolved
#
# @return [Boolean]
def filesystem_efi?
storage_device.filesystem.efi?
end

def self.included(base)
base.class_eval do
dbus_interface FILESYSTEM_INTERFACE do
dbus_reader :filesystem_type, "s", dbus_name: "Type"
dbus_reader :filesystem_efi?, "b", dbus_name: "EFI"
end
end
end
end
end
end
end
end
11 changes: 4 additions & 7 deletions service/lib/agama/dbus/storage/interfaces/md.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

# Copyright (c) [2023] SUSE LLC
# Copyright (c) [2023-2024] SUSE LLC
#
# All Rights Reserved.
#
Expand Down Expand Up @@ -46,22 +46,19 @@ def md_level
storage_device.md_level.to_s
end

# Member devices of the MD RAID
#
# TODO: return object paths once all possible members (e.g., partitions) are exported
# on D-Bus.
# Paths of the D-Bus objects representing the member devices of the MD RAID.
#
# @return [Array<String>]
def md_members
storage_device.plain_devices.map(&:name)
storage_device.plain_devices.map { |p| tree.path_for(p) }
end

def self.included(base)
base.class_eval do
dbus_interface MD_INTERFACE do
dbus_reader :md_uuid, "s", dbus_name: "UUID"
dbus_reader :md_level, "s", dbus_name: "Level"
dbus_reader :md_members, "as", dbus_name: "Members"
dbus_reader :md_members, "ao", dbus_name: "Members"
end
end
end
Expand Down
10 changes: 4 additions & 6 deletions service/lib/agama/dbus/storage/interfaces/multipath.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

# Copyright (c) [2023] SUSE LLC
# Copyright (c) [2023-2024] SUSE LLC
#
# All Rights Reserved.
#
Expand Down Expand Up @@ -32,19 +32,17 @@ module Multipath
MULTIPATH_INTERFACE = "org.opensuse.Agama.Storage1.Multipath"
private_constant :MULTIPATH_INTERFACE

# Multipath wires
#
# TODO: return object paths
# Paths of the D-Bus objects representing the multipath wires.
#
# @return [Array<String>]
def multipath_wires
storage_device.parents.map(&:name)
storage_device.parents.map { |p| tree.path_for(p) }
end

def self.included(base)
base.class_eval do
dbus_interface MULTIPATH_INTERFACE do
dbus_reader :multipath_wires, "as", dbus_name: "Wires"
dbus_reader :multipath_wires, "ao", dbus_name: "Wires"
end
end
end
Expand Down
10 changes: 4 additions & 6 deletions service/lib/agama/dbus/storage/interfaces/raid.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

# Copyright (c) [2023] SUSE LLC
# Copyright (c) [2023-2024] SUSE LLC
#
# All Rights Reserved.
#
Expand Down Expand Up @@ -32,19 +32,17 @@ module Raid
RAID_INTERFACE = "org.opensuse.Agama.Storage1.RAID"
private_constant :RAID_INTERFACE

# Devices used by the DM RAID
#
# TODO: return object paths
# Paths of the D-Bus objects representing the devices used by the DM RAID.
#
# @return [Array<String>]
def raid_devices
storage_device.parents.map(&:name)
storage_device.parents.map { |p| tree.path_for(p) }
end

def self.included(base)
base.class_eval do
dbus_interface RAID_INTERFACE do
dbus_reader :raid_devices, "as", dbus_name: "Devices"
dbus_reader :raid_devices, "ao", dbus_name: "Devices"
end
end
end
Expand Down
11 changes: 10 additions & 1 deletion service/lib/agama/dbus/storage/proposal.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

# Copyright (c) [2022-2023] SUSE LLC
# Copyright (c) [2022-2024] SUSE LLC
#
# All Rights Reserved.
#
Expand Down Expand Up @@ -58,6 +58,8 @@ def initialize(backend, logger)

dbus_reader :space_policy, "s"

dbus_reader :space_actions, "aa{sv}"

dbus_reader :volumes, "aa{sv}"

dbus_reader :actions, "aa{sv}"
Expand Down Expand Up @@ -109,6 +111,13 @@ def space_policy
dbus_settings.fetch("SpacePolicy", "")
end

# Space actions
#
# @return [Array<Hash>]
def space_actions
dbus_settings.fetch("SpaceActions", [])
end

# Volumes used to calculate the storage proposal
#
# @return [Array<Hash>]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

# Copyright (c) [2023] SUSE LLC
# Copyright (c) [2023-2024] SUSE LLC
#
# All Rights Reserved.
#
Expand Down Expand Up @@ -130,9 +130,11 @@ def space_policy_conversion(target, value)
end

# @param target [Agama::Storage::ProposalSettings]
# @param value [Hash]
# @param value [Array<Hash>]
def space_actions_conversion(target, value)
target.space.actions = value
target.space.actions = value.each_with_object({}) do |v, result|
result[v["Device"]] = v["Action"].to_sym
end
end

# @param target [Agama::Storage::ProposalSettings]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

# Copyright (c) [2023] SUSE LLC
# Copyright (c) [2023-2024] SUSE LLC
#
# All Rights Reserved.
#
Expand Down Expand Up @@ -35,7 +35,7 @@ def initialize(settings)
# Performs the conversion to D-Bus format.
#
# @return [Hash]
def convert # rubocop:disable Metrics/AbcSize
def convert
{
"BootDevice" => settings.boot_device.to_s,
"LVM" => settings.lvm.enabled?,
Expand All @@ -44,7 +44,7 @@ def convert # rubocop:disable Metrics/AbcSize
"EncryptionMethod" => settings.encryption.method.id.to_s,
"EncryptionPBKDFunction" => settings.encryption.pbkd_function&.value || "",
"SpacePolicy" => settings.space.policy.to_s,
"SpaceActions" => settings.space.actions,
"SpaceActions" => space_actions_conversion,
"Volumes" => settings.volumes.map { |v| VolumeConversion.to_dbus(v) }
}
end
Expand All @@ -53,6 +53,13 @@ def convert # rubocop:disable Metrics/AbcSize

# @return [Agama::Storage::ProposalSettings]
attr_reader :settings

# @return [Array<Hash>]
def space_actions_conversion
settings.space.actions.each_with_object([]) do |(device, action), actions|
actions << { "Device" => device, "Action" => action.to_s }
end
end
end
end
end
Expand Down
7 changes: 3 additions & 4 deletions service/lib/agama/storage/proposal.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

# Copyright (c) [2022-2023] SUSE LLC
# Copyright (c) [2022-2024] SUSE LLC
#
# All Rights Reserved.
#
Expand Down Expand Up @@ -85,10 +85,9 @@ def settings
proposal.settings,
config: config
).tap do |settings|
# FIXME: The conversion from Y2Storage cannot infer the space policy. Copying space
# settings from the original settings.
# The conversion from Y2Storage cannot infer the space policy. Copying space policy from
# the original settings.
settings.space.policy = original_settings.space.policy
settings.space.actions = original_settings.space.actions
# FIXME: The conversion from Y2Storage cannot reliably infer the system VG devices in all
# cases. Copying system VG devices from the original settings.
settings.lvm.system_vg_devices = original_settings.lvm.system_vg_devices
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

# Copyright (c) [2023] SUSE LLC
# Copyright (c) [2023-2024] SUSE LLC
#
# All Rights Reserved.
#
Expand Down Expand Up @@ -82,9 +82,10 @@ def encryption_conversion(target)
target.encryption.pbkd_function = settings.encryption_pbkdf
end

# @note The space policy cannot be inferred from Y2Storage settings.
# @param target [Agama::Storage::ProposalSettings]
def space_settings_conversion(target)
# FIXME: No way to infer space settings from Y2Storage.
target.space.actions = settings.space_settings.actions
end

# @param target [Agama::Storage::ProposalSettings]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def find_max_size_fallback(mount_path)

# All block devices affected by the space policy.
#
# This includes the partitions from the root device, the candidate devices and from the
# This includes the partitions from the boot device, the candidate devices and from the
# devices directly assigned to a volume as target device. If a device is not partitioned,
# then the device itself is included.
#
Expand Down
3 changes: 3 additions & 0 deletions service/test/agama/dbus/storage/device_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
require_relative "./interfaces/block_examples"
require_relative "./interfaces/md_examples"
require_relative "./interfaces/partition_table_examples"
require_relative "./interfaces/filesystem_examples"
require "agama/dbus/storage/device"
require "agama/dbus/storage/devices_tree"
require "dbus"
Expand Down Expand Up @@ -142,6 +143,8 @@

include_examples "PartitionTable interface"

include_examples "Filesystem interface"

describe "#storage_device=" do
before do
allow(subject).to receive(:dbus_properties_changed)
Expand Down
2 changes: 1 addition & 1 deletion service/test/agama/dbus/storage/devices_tree_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
context "if an exported D-Bus object does not represent any of the current devices" do
let(:dbus_objects) { [dbus_object1] }
let(:dbus_object1) { Agama::DBus::Storage::Device.new(sdd, subject.path_for(sdd), subject) }
let(:sdd) { instance_double(Y2Storage::Disk, sid: 1, is?: false) }
let(:sdd) { instance_double(Y2Storage::Disk, sid: 1, is?: false, filesystem: false) }

it "unexports the D-Bus object" do
expect(service).to unexport_object("#{root_path}/1")
Expand Down
Loading
Loading