Class: DInstaller::Storage::Proposal
- Inherits:
-
Object
- Object
- DInstaller::Storage::Proposal
- Defined in:
- lib/dinstaller/storage/proposal.rb
Overview
Backend class to calculate a storage proposal
Defined Under Namespace
Classes: NoProposalError
Instance Method Summary collapse
-
#actions ⇒ Storage::Actions
Storage actions manager.
- #add_on_change_listener(&block) ⇒ Object
-
#available_devices ⇒ Array<Y2Storage::Device>
Available devices for installation.
-
#calculate(settings = {}) ⇒ Boolean
Calculates a new proposal.
-
#candidate_devices ⇒ Array<String>
Name of devices where to perform the installation.
- #changed! ⇒ Object
-
#device_label(device) ⇒ String
Label that should be used to represent the given disk in the UI.
-
#initialize(logger, config) ⇒ Proposal
constructor
Constructor.
-
#lvm? ⇒ Boolean
Whether the proposal should create LVM devices.
Constructor Details
#initialize(logger, config) ⇒ Proposal
Constructor
37 38 39 40 41 |
# File 'lib/dinstaller/storage/proposal.rb', line 37 def initialize(logger, config) @logger = logger @config = config @listeners = [] end |
Instance Method Details
#actions ⇒ Storage::Actions
Storage actions manager
124 125 126 127 |
# File 'lib/dinstaller/storage/proposal.rb', line 124 def actions # FIXME: this class could receive the storage manager instance @actions ||= Actions.new(logger) end |
#add_on_change_listener(&block) ⇒ Object
43 44 45 |
# File 'lib/dinstaller/storage/proposal.rb', line 43 def add_on_change_listener(&block) @listeners << block end |
#available_devices ⇒ Array<Y2Storage::Device>
Available devices for installation
54 55 56 |
# File 'lib/dinstaller/storage/proposal.rb', line 54 def available_devices disk_analyzer.candidate_disks end |
#calculate(settings = {}) ⇒ Boolean
Calculates a new proposal
105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/dinstaller/storage/proposal.rb', line 105 def calculate(settings = {}) proposal_settings = generate_proposal_settings(settings) @proposal = Y2Storage::GuidedProposal.initial( settings: proposal_settings, devicegraph: probed_devicegraph, disk_analyzer: disk_analyzer ) save changed! !proposal.failed? end |
#candidate_devices ⇒ Array<String>
Name of devices where to perform the installation
81 82 83 84 85 |
# File 'lib/dinstaller/storage/proposal.rb', line 81 def candidate_devices raise NoProposalError unless proposal proposal.settings.candidate_devices end |
#changed! ⇒ Object
47 48 49 |
# File 'lib/dinstaller/storage/proposal.rb', line 47 def changed! @listeners.each(&:call) end |
#device_label(device) ⇒ String
Label that should be used to represent the given disk in the UI
NOTE: this is likely a temporary solution. The label should not be calculated in the backend in the future. See the note about available_devices at DBus::Storage::Proposal.
The label has the form: “NAME, SIZE, [USB], INSTALLED_SYSTEMS”.
Examples:
"/dev/sda, 250.00 GiB, Windows, OpenSUSE"
"/dev/sdb, 8.00 GiB, USB"
72 73 74 |
# File 'lib/dinstaller/storage/proposal.rb', line 72 def device_label(device) disk_helper.label(device) end |
#lvm? ⇒ Boolean
Whether the proposal should create LVM devices
92 93 94 95 96 |
# File 'lib/dinstaller/storage/proposal.rb', line 92 def lvm? raise NoProposalError unless proposal proposal.settings.use_lvm end |