Class: DInstaller::Manager

Inherits:
Object
  • Object
show all
Includes:
WithProgress
Defined in:
lib/dinstaller/manager.rb

Overview

This class represents the top level installer manager.

It is responsible for orchestrating the installation process. For module specific stuff it delegates it to the corresponding module class (e.g., Network, Storage::Proposal, etc.) or asks other services via D-Bus (e.g., ‘org.opensuse.DInstaller.Software`).

Instance Attribute Summary collapse

Attributes included from WithProgress

#progress

Instance Method Summary collapse

Methods included from WithProgress

#on_progress_change, #on_progress_finish, #start_progress

Constructor Details

#initialize(config, logger) ⇒ Manager

Constructor

Parameters:



61
62
63
64
65
66
67
# File 'lib/dinstaller/manager.rb', line 61

def initialize(config, logger)
  @config = config
  @logger = logger
  @questions_manager = QuestionsManager.new(logger)
  @installation_phase = InstallationPhase.new
  @service_status_recorder = ServiceStatusRecorder.new
end

Instance Attribute Details

#installation_phaseInstallationPhase (readonly)

Returns:



56
57
58
# File 'lib/dinstaller/manager.rb', line 56

def installation_phase
  @installation_phase
end

#loggerLogger (readonly)

Returns:



50
51
52
# File 'lib/dinstaller/manager.rb', line 50

def logger
  @logger
end

#questions_managerQuestionsManager (readonly)

Returns:



53
54
55
# File 'lib/dinstaller/manager.rb', line 53

def questions_manager
  @questions_manager
end

Instance Method Details

#busy_servicesArray<String>

Name of busy services

See Also:

Returns:



206
207
208
# File 'lib/dinstaller/manager.rb', line 206

def busy_services
  service_status_recorder.busy_services
end

#config_phaseObject

Runs the config phase



79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/dinstaller/manager.rb', line 79

def config_phase
  installation_phase.config

  storage.probe(questions_manager)
  security.probe
  network.probe

  logger.info("Config phase done")
rescue StandardError => e
  logger.error "Startup error: #{e.inspect}. Backtrace: #{e.backtrace}"
  # TODO: report errors
end

#install_phaseObject

Runs the install phase rubocop:disable Metrics/AbcSize



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/dinstaller/manager.rb', line 94

def install_phase
  installation_phase.install

  start_progress(9)

  progress.step("Reading software repositories") do
    software.probe
    Yast::Installation.destdir = "/mnt"
  end

  progress.step("Partitioning") do
    # lets propose it here to be sure that software proposal reflects product selection
    # FIXME: maybe repropose after product selection change?
    # first make bootloader proposal to be sure that required packages are installed
    proposal = ::Bootloader::ProposalClient.new.make_proposal({})
    logger.info "Bootloader proposal #{proposal.inspect}"
    storage.install
    # propose software after /mnt is already separated, so it uses proper
    # target
    software.propose

    # call inst bootloader to get properly initialized bootloader
    # sysconfig before package installation
    Yast::WFM.CallFunction("inst_bootloader", [])
  end

  progress.step("Installing Software") { software.install }

  on_target do
    progress.step("Writing Users") { users.write }

    progress.step("Writing Network Configuration") { network.install }

    progress.step("Installing Bootloader") do
      security.write
      ::Bootloader::FinishClient.new.write
    end

    progress.step("Saving Language Settings") { language.finish }

    progress.step("Writing repositories information") { software.finish }

    progress.step("Finishing installation") { finish_installation }
  end

  logger.info("Install phase done")
end

#languageDBus::Clients::Language

Language manager

Returns:



157
158
159
# File 'lib/dinstaller/manager.rb', line 157

def language
  @language ||= DBus::Clients::Language.new
end

#networkNetwork

Network manager

Returns:



175
176
177
# File 'lib/dinstaller/manager.rb', line 175

def network
  @network ||= Network.new(logger)
end

#on_services_status_change(&block) ⇒ Object

Registers a callback to be called when the status of a service changes



213
214
215
# File 'lib/dinstaller/manager.rb', line 213

def on_services_status_change(&block)
  service_status_recorder.on_service_status_change(&block)
end

#securitySecurity

Security manager

Returns:



189
190
191
# File 'lib/dinstaller/manager.rb', line 189

def security
  @security ||= Security.new(logger, config)
end

#select_product(product) ⇒ Object

Note:

The config phase is executed.

Actions to perform when a product is selected



196
197
198
199
# File 'lib/dinstaller/manager.rb', line 196

def select_product(product)
  config.pick_product(product)
  config_phase
end

#softwareDBus::Clients::Software

Software client

Returns:



146
147
148
149
150
151
152
# File 'lib/dinstaller/manager.rb', line 146

def software
  @software ||= DBus::Clients::Software.new.tap do |client|
    client.on_service_status_change do |status|
      service_status_recorder.save(client.service.name, status)
    end
  end
end

#startup_phaseObject

Runs the startup phase



70
71
72
73
74
75
76
# File 'lib/dinstaller/manager.rb', line 70

def startup_phase
  installation_phase.startup

  probe_single_product unless config.multi_product?

  logger.info("Startup phase done")
end

#storageStorage::Manager

Storage manager

Returns:



182
183
184
# File 'lib/dinstaller/manager.rb', line 182

def storage
  @storage ||= Storage::Manager.new(logger, config)
end

#usersDBus::Clients::Users

Users client

Returns:



164
165
166
167
168
169
170
# File 'lib/dinstaller/manager.rb', line 164

def users
  @users ||= DBus::Clients::Users.new.tap do |client|
    client.on_service_status_change do |status|
      service_status_recorder.save(client.service.name, status)
    end
  end
end