Class: Installation::AutoClient

Inherits:
Yast::Client
  • Object
show all
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:
    • if cancelled/aborted, #import is called (on the previous result of #export)
    • otherwise #export is called. If the output is different from the previous call, then #modified is called.
  • #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

Examples:

how to run a client

require "installation/example_auto"
::Installation::ExampleAuto.run

See Also:

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.runObject

Entry point for calling the client. The only part needed in client rb file.

Returns:

  • response from abstract methods


51
52
53
# File 'library/general/src/lib/installation/auto_client.rb', line 51

def self.run
  new.run
end

Instance Method Details

#changeSymbol (protected)

Run UI to modify the configuration.

Returns:

  • (Symbol)

    If one of :accept, :next, :finish is returned, the changes are accepted, otherwise they are discarded.

Raises:

  • (NotImplementedError)

122
123
124
# File 'library/general/src/lib/installation/auto_client.rb', line 122

def change
  raise NotImplementedError, "Calling abstract method 'change'"
end

#exportHash, Array (protected)

Export profile data from AutoYaST.

The profile is a Hash or an Array according to the configuration item X-SuSE-YaST-AutoInstDataType

Returns:

  • (Hash, Array)

    profile data

Raises:

  • (NotImplementedError)

103
104
105
# File 'library/general/src/lib/installation/auto_client.rb', line 103

def export
  raise NotImplementedError, "Calling abstract method 'export'"
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

Parameters:

  • _profile (Hash, Array)

    profile data specific to this module.

Returns:

  • true on success

Raises:

  • (NotImplementedError)

94
95
96
# File 'library/general/src/lib/installation/auto_client.rb', line 94

def import(_profile)
  raise NotImplementedError, "Calling abstract method 'import'"
end

#modifiedvoid (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.

Raises:

  • (NotImplementedError)

162
163
164
# File 'library/general/src/lib/installation/auto_client.rb', line 162

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.

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)

170
171
172
# File 'library/general/src/lib/installation/auto_client.rb', line 170

def modified?
  raise NotImplementedError, "Calling abstract method 'modified?'"
end

#packagesHash (protected)

Return a hash with packages that need to be installed or removed for configuration.

The default implementation returns an empty hash.

Examples:


def packages
  { "install" => ["package1"], "remove" => ["package2"] }
end

Returns:

  • (Hash)

    of packages to be installed and removed


143
144
145
146
147
# File 'library/general/src/lib/installation/auto_client.rb', line 143

def packages
  log.info "#{self.class}#packages not implemented, returning {}."

  {}
end

#readvoid (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.

Raises:

  • (NotImplementedError)

154
155
156
# File 'library/general/src/lib/installation/auto_client.rb', line 154

def read
  raise NotImplementedError, "Calling abstract method 'write'"
end

#resetvoid (protected)

This method returns an undefined value.

Reset configuration to default state.

Raises:

  • (NotImplementedError)

115
116
117
# File 'library/general/src/lib/installation/auto_client.rb', line 115

def reset
  raise NotImplementedError, "Calling abstract method 'reset'"
end

#runObject

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
# 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"
    export
  when "Summary"
    summary
  when "Reset"
    reset
  when "Change"
    change
  when "Write"
    write
  when "Packages"
    packages
  when "Read"
    read
  when "GetModified"
    modified?
  when "SetModified"
    modified
  else
    raise ArgumentError, "Invalid action for auto client '#{func.inspect}'"
  end
end

#summaryString (protected)

Provide a brief summary of configuration.

Returns:

  • (String)

    description in RichText format

Raises:

  • (NotImplementedError)

109
110
111
# File 'library/general/src/lib/installation/auto_client.rb', line 109

def summary
  raise NotImplementedError, "Calling abstract method 'summary'"
end

#writeBoolean (protected)

Write settings to the target system.

Returns:

  • (Boolean)

    true on success

Raises:

  • (NotImplementedError)

128
129
130
# File 'library/general/src/lib/installation/auto_client.rb', line 128

def write
  raise NotImplementedError, "Calling abstract method 'write'"
end