Class: Installation::AutoClient
- Inherits:
-
Yast::Client
- Object
- Yast::Client
- Installation::AutoClient
- Includes:
- Yast::Logger
- Defined in:
- library/general/src/lib/installation/auto_client.rb
Overview
An abstract class that simplifies writing *_auto.rb
clients for AutoYaST.
It provides a single entry point which dispatches calls to the abstract methods that all proposal clients need to implement.
You need to implement all the methods, except #packages.
"Autoinstall" basically means #import, then #write.
The workflow for interactive editing in the UI
(Mode.config == true
, see Yast::ModeClass)
is more complicated. The user can choose to perform any action, and
a corresponding method is called:
- #summary: clicking on the icon of the module.
- #reset: clicking Clear.
- if the user clicks to Edit a module, at first #export is called, then #change is called for UI interaction, which can end up in multiple situations:
- #write: clicking Apply to System.
- #read: clicking Clone.
- #import: selecting File/Open to load an autoyast profile
- it calls #modified? to recognize if a given module is modified and needs its section with content of #export when saving the profile
- the order of all calls is independent, so the client should not depend on a certain order unless it is defined here as a workflow call
Class Method Summary collapse
-
.run ⇒ Object
Entry point for calling the client.
Instance Method Summary collapse
-
#change ⇒ Symbol
protected
Run UI to modify the configuration.
-
#export(target:) ⇒ Hash, Array
protected
Export profile data from AutoYaST.
-
#import(_profile) ⇒ Object
protected
Import data from AutoYaST profile.
-
#modified ⇒ void
protected
Set that the profile data has beed modified and should be exported from the interactive editor, or included in the cloned data.
-
#modified? ⇒ Boolean
protected
Query whether the profile data has beed modified and should be exported from the interactive editor, or included in the cloned data.
-
#packages ⇒ Hash
protected
Return a hash with packages that need to be installed or removed for configuration.
-
#read ⇒ void
protected
Read settings from the target system.
-
#reset ⇒ void
protected
Reset configuration to default state.
-
#run ⇒ Object
Dispatches to abstract method based on passed Arguments to client.
-
#summary ⇒ String
protected
Provide a brief summary of configuration.
-
#write ⇒ Boolean
protected
Write settings to the target system.
Class Method Details
.run ⇒ Object
Entry point for calling the client. The only part needed in client rb file.
51 52 53 |
# File 'library/general/src/lib/installation/auto_client.rb', line 51 def self.run new.run end |
Instance Method Details
#change ⇒ Symbol (protected)
Run UI to modify the configuration.
130 131 132 |
# File 'library/general/src/lib/installation/auto_client.rb', line 130 def change raise NotImplementedError, "Calling abstract method 'change'" end |
#export(target:) ⇒ Hash, Array (protected)
Export profile data from AutoYaST.
The profile is a Hash or an Array according to the configuration item
X-SuSE-YaST-AutoInstDataType
111 112 113 |
# File 'library/general/src/lib/installation/auto_client.rb', line 111 def export(target:) raise NotImplementedError, "Calling abstract method 'export' with target '#{target}'" end |
#import(_profile) ⇒ Object (protected)
Import data from AutoYaST profile.
The profile is a Hash or an Array according to the configuration item
X-SuSE-YaST-AutoInstDataType
100 101 102 |
# File 'library/general/src/lib/installation/auto_client.rb', line 100 def import(_profile) raise NotImplementedError, "Calling abstract method 'import'" end |
#modified ⇒ void (protected)
This method returns an undefined value.
Set that the profile data has beed modified and should be exported from the interactive editor, or included in the cloned data.
170 171 172 |
# File 'library/general/src/lib/installation/auto_client.rb', line 170 def modified raise NotImplementedError, "Calling abstract method 'modified'" end |
#modified? ⇒ Boolean (protected)
Query whether the profile data has beed modified and should be exported from the interactive editor, or included in the cloned data.
178 179 180 |
# File 'library/general/src/lib/installation/auto_client.rb', line 178 def modified? raise NotImplementedError, "Calling abstract method 'modified?'" end |
#packages ⇒ Hash (protected)
Return a hash with packages that need to be installed or removed for configuration.
The default implementation returns an empty hash.
151 152 153 154 155 |
# File 'library/general/src/lib/installation/auto_client.rb', line 151 def packages log.info "#{self.class}#packages not implemented, returning {}." {} end |
#read ⇒ void (protected)
This method returns an undefined value.
Read settings from the target system.
It is used to initialize configuration from the current system for further represent in AutoYaST profile.
162 163 164 |
# File 'library/general/src/lib/installation/auto_client.rb', line 162 def read raise NotImplementedError, "Calling abstract method 'write'" end |
#reset ⇒ void (protected)
This method returns an undefined value.
Reset configuration to default state.
123 124 125 |
# File 'library/general/src/lib/installation/auto_client.rb', line 123 def reset raise NotImplementedError, "Calling abstract method 'reset'" end |
#run ⇒ Object
Dispatches to abstract method based on passed Arguments to client
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'library/general/src/lib/installation/auto_client.rb', line 56 def run func, param = Yast::WFM.Args log.info "Called #{self.class}.run with #{func} and params #{param}" case func when "Import" import(param) when "Export" target = param["target"] if param.is_a?(Hash) target ||= "default" m = method(:export) m.arity.zero? ? export : export(target: target.to_sym) when "Summary" summary when "Reset" reset nil # return type is ignored, so always return nil to avoid issues with ycp component system when "Change" change when "Write" write when "Packages" packages when "Read" read nil # return type is ignored, so always return nil to avoid issues with ycp component system when "GetModified" modified? when "SetModified" modified nil # return type is ignored, so always return nil to avoid issues with ycp component system else raise ArgumentError, "Invalid action for auto client '#{func.inspect}'" end end |
#summary ⇒ String (protected)
Provide a brief summary of configuration.
117 118 119 |
# File 'library/general/src/lib/installation/auto_client.rb', line 117 def summary raise NotImplementedError, "Calling abstract method 'summary'" end |
#write ⇒ Boolean (protected)
Write settings to the target system.
136 137 138 |
# File 'library/general/src/lib/installation/auto_client.rb', line 136 def write raise NotImplementedError, "Calling abstract method 'write'" end |