Skip to content

Commit

Permalink
Find space section (#1028)
Browse files Browse the repository at this point in the history
## Problem

The page for configuring storage allows to select the policy for making
free space: delete, resize or keep partitions. Those policies affect to
all the partitions of the disks used for the installation. But there is
no way to select the custom policy in which the user has to choose what
to do with each partition (delete, keep or allow to resize).

https://trello.com/c/9AhV6aOb/3406-13-agama-ui-for-custom-making-space

## Solution

Add a new section to configure the space policy and the actions for the
custom policy. The UI solution is based on the mockups for the new
storage UI, see
https://github.com/openSUSE/agama/blob/master/doc/storage_ui.md.

## Testing

* Added new unit tests.
* Tested manually.

## Screenshots

![localhost_8080_
(27)](https://github.com/openSUSE/agama/assets/1112304/61802838-57d8-4c6e-a29a-ffb24ecf046a)
  • Loading branch information
joseivanlopez authored Feb 20, 2024
2 parents 0a2e7b6 + 43e470c commit 21950bb
Show file tree
Hide file tree
Showing 60 changed files with 2,642 additions and 1,187 deletions.
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

0 comments on commit 21950bb

Please sign in to comment.