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 29 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
20 changes: 19 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,8 @@
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/component"

module Agama
module DBus
Expand Down Expand Up @@ -77,14 +79,16 @@ 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 << Interfaces::Component if component?

interfaces.each { |i| singleton_class.include(i) }
end
Expand All @@ -110,6 +114,20 @@ 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.is?(:blk_device) && !storage_device.filesystem.nil?
end

# Whether the storage device is component of other devices.
#
# @return [Boolean]
def component?
storage_device.is?(:blk_device) && storage_device.component_of.any?
end
end
end
end
Expand Down
4 changes: 3 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,6 @@ 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/component"
require "agama/dbus/storage/interfaces/dasd_manager"
89 changes: 89 additions & 0 deletions service/lib/agama/dbus/storage/interfaces/component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# 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 devices that are used as component of other device (e.g., physical volume,
# MD RAID device, etc).
#
# @note This interface is intended to be included by {Device} if needed.
module Component
COMPONENT_INTERFACE = "org.opensuse.Agama.Storage1.Component"
private_constant :COMPONENT_INTERFACE

# Type of component.
#
# @return [String] Possible values:
# "physical_volume"
# "md_device"
# "raid_device"
# "multipath_wire"
# "bcache_device"
# "bcache_cset_device"
# "md_btrfs_device"
joseivanlopez marked this conversation as resolved.
Show resolved Hide resolved
def component_type
types = {
lvm_vg: "physical_volume",
md: "md_device",
dm_raid: "raid_device",
multipath: "multipath_wire",
bcache: "bcache_device",
bcache_cset: "bcache_cset_device",
btrfs: "md_btrfs_device"
joseivanlopez marked this conversation as resolved.
Show resolved Hide resolved
}

device = storage_device.component_of.first

types.find { |k, _v| device.is?(k) }&.last || ""
end

# Name of the devices for which this device is component of.
#
# @return [Array<String>]
def component_device_names
storage_device.component_of.map(&:display_name).compact
end

# Paths of the D-Bus objects representing the devices.
#
# @return [Array<::DBus::ObjectPath>]
def component_devices
storage_device.component_of.map { |p| tree.path_for(p) }
end

def self.included(base)
base.class_eval do
dbus_interface COMPONENT_INTERFACE do
dbus_reader :component_type, "s", dbus_name: "Type"
dbus_reader :component_device_names, "as", dbus_name: "DeviceNames"
dbus_reader :component_devices, "ao", dbus_name: "Devices"
end
end
end
end
end
end
end
end
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
13 changes: 5 additions & 8 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 devices of the MD RAID.
#
# @return [Array<String>]
def md_members
storage_device.plain_devices.map(&:name)
def md_devices
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_devices, "ao", dbus_name: "Devices"
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
Loading
Loading