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 all 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
43 changes: 6 additions & 37 deletions service/lib/agama/dbus/storage/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@

require "dbus"
require "agama/dbus/base_object"
require "agama/dbus/storage/interfaces/drive"
require "agama/dbus/storage/interfaces/raid"
require "agama/dbus/storage/interfaces/multipath"
require "agama/dbus/storage/interfaces/md"
require "agama/dbus/storage/interfaces/block"
require "agama/dbus/storage/interfaces/partition_table"
require "agama/dbus/storage/interfaces/device"

module Agama
module DBus
Expand Down Expand Up @@ -76,40 +71,14 @@ def storage_device=(value)
# @return [DevicesTree]
attr_reader :tree

# Adds the required interfaces according to the storage object
def add_interfaces # rubocop:disable Metrics/CyclomaticComplexity
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?
# Adds the required interfaces according to the storage object.
def add_interfaces
interfaces = Interfaces::Device.constants
.map { |c| Interfaces::Device.const_get(c) }
.select { |c| c.is_a?(Module) && c.respond_to?(:apply?) && c.apply?(storage_device) }

interfaces.each { |i| singleton_class.include(i) }
end

# Whether the storage device is a drive
#
# Drive and disk device are very close concepts, but there are subtle differences. For
# example, a MD RAID is never considered as a drive.
#
# TODO: Revisit the defintion of drive. Maybe some MD devices could implement the drive
# interface if hwinfo provides useful information for them.
#
# @return [Boolean]
def drive?
storage_device.is?(:disk, :dm_raid, :multipath, :dasd) && storage_device.is?(:disk_device)
end

# Whether the storage device has a partition table
#
# @return [Boolean]
def partition_table?
storage_device.is?(:blk_device) &&
storage_device.respond_to?(:partition_table?) &&
storage_device.partition_table?
end
end
end
end
Expand Down
12 changes: 4 additions & 8 deletions 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 All @@ -22,17 +22,13 @@
module Agama
module DBus
module Storage
# Module for storage specific D-Bus interfaces
# Module for D-Bus interfaces of storage.
module Interfaces
end
end
end
end

require "agama/dbus/storage/interfaces/drive"
require "agama/dbus/storage/interfaces/raid"
require "agama/dbus/storage/interfaces/multipath"
require "agama/dbus/storage/interfaces/md"
require "agama/dbus/storage/interfaces/block"
require "agama/dbus/storage/interfaces/partition_table"
require "agama/dbus/storage/interfaces/dasd_manager"
require "agama/dbus/storage/interfaces/device"
require "agama/dbus/storage/interfaces/zfcp_manager"
104 changes: 0 additions & 104 deletions service/lib/agama/dbus/storage/interfaces/block.rb

This file was deleted.

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) [2024] SUSE LLC
#
# All Rights Reserved.
#
Expand All @@ -19,37 +19,23 @@
# 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 DM RAID devices
#
# @note This interface is intended to be included by {Device} if needed.
module Raid
RAID_INTERFACE = "org.opensuse.Agama.Storage1.RAID"
private_constant :RAID_INTERFACE

# Devices used by the DM RAID
#
# TODO: return object paths
#
# @return [Array<String>]
def raid_devices
storage_device.parents.map(&:name)
end

def self.included(base)
base.class_eval do
dbus_interface RAID_INTERFACE do
dbus_reader :raid_devices, "as", dbus_name: "Devices"
end
end
end
# Module for D-Bus interfaces of a device.
module Device
end
end
end
end
end

require "agama/dbus/storage/interfaces/device/block"
require "agama/dbus/storage/interfaces/device/component"
require "agama/dbus/storage/interfaces/device/drive"
require "agama/dbus/storage/interfaces/device/filesystem"
require "agama/dbus/storage/interfaces/device/md"
require "agama/dbus/storage/interfaces/device/multipath"
require "agama/dbus/storage/interfaces/device/partition_table"
require "agama/dbus/storage/interfaces/device/raid"
117 changes: 117 additions & 0 deletions service/lib/agama/dbus/storage/interfaces/device/block.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# frozen_string_literal: true

# Copyright (c) [2023-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
module Device
# Interface for block devices.
#
# @note This interface is intended to be included by {Agama::DBus::Storage::Device} if
# needed.
module Block
# Whether this interface should be implemented for the given device.
#
# @note Block devices implement this interface.
#
# @param storage_device [Y2Storage::Device]
# @return [Boolean]
def self.apply?(storage_device)
storage_device.is?(:blk_device)
end

BLOCK_INTERFACE = "org.opensuse.Agama.Storage1.Block"
private_constant :BLOCK_INTERFACE

# Name of the block device
#
# @return [String] e.g., "/dev/sda"
def block_name
storage_device.name
end

# Whether the block device is currently active
#
# @return [Boolean]
def block_active
storage_device.active?
end

# Name of the udev by-id links
#
# @return [Array<String>]
def block_udev_ids
storage_device.udev_ids
end

# Name of the udev by-path links
#
# @return [Array<String>]
def block_udev_paths
storage_device.udev_paths
end

# Size of the block device in bytes
#
# @return [Integer]
def block_size
storage_device.size.to_i
end

# Size of the space that could be theoretically reclaimed by shrinking the device.
#
# @return [Integer]
def block_recoverable_size
storage_device.recoverable_size.to_i
end

# Name of the currently installed systems
#
# @return [Array<String>]
def block_systems
return @systems if @systems

filesystems = storage_device.descendants.select { |d| d.is?(:filesystem) }
@systems = filesystems.map(&:system_name).compact
end

def self.included(base)
base.class_eval do
dbus_interface BLOCK_INTERFACE do
dbus_reader :block_name, "s", dbus_name: "Name"
dbus_reader :block_active, "b", dbus_name: "Active"
dbus_reader :block_udev_ids, "as", dbus_name: "UdevIds"
dbus_reader :block_udev_paths, "as", dbus_name: "UdevPaths"
dbus_reader :block_size, "t", dbus_name: "Size"
dbus_reader :block_recoverable_size, "t", dbus_name: "RecoverableSize"
dbus_reader :block_systems, "as", dbus_name: "Systems"
end
end
end
end
end
end
end
end
end
Loading
Loading