Class: Yast::AutoInstallClass

Inherits:
Module
  • Object
show all
Includes:
Logger
Defined in:
../../src/modules/AutoInstall.rb

Instance Method Summary (collapse)

Instance Method Details

- (void) AutoInstall

This method returns an undefined value.

Constructer



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File '../../src/modules/AutoInstall.rb', line 146

def AutoInstall
  if Stage.cont
    ret = Continue()
    if ret && Ops.greater_than(Builtins.size(Profile.current), 0)
      if Mode.autoupgrade
        Builtins.y2milestone(
          "AutoYaST upgrade mode already set, keeping it"
        )
      else
        Builtins.y2milestone("Enabling Auto-Installation mode")
        Mode.SetMode("autoinstallation")
      end
    elsif Mode.autoinst
      Builtins.y2milestone(
        "No autoyast data found, switching back to manual installation"
      )
      Mode.SetMode("installation")
    elsif Mode.autoupgrade
      Builtins.y2milestone(
        "No autoyast data found, switching back to manual update"
      )
      Mode.SetMode("update")
    end
  elsif Stage.initial
    if SCR.Read(path(".target.size"), AutoinstConfig.xml_tmpfile) != -1 &&
        Builtins.size(Profile.current) == 0
      Builtins.y2milestone("autoyast: %1 found", AutoinstConfig.xml_tmpfile)
      # Profile is available and it has not been parsed yet.
      Profile.ReadXML(AutoinstConfig.xml_tmpfile)
    end
  end
  nil
end

- (Object) callback_void_map(dummy_map)



47
48
49
50
# File '../../src/modules/AutoInstall.rb', line 47

def callback_void_map(dummy_map)
  dummy_map = deep_copy(dummy_map)
  nil
end

- (Object) callbackFalse_boolean_map(dummy_map)



57
58
59
60
# File '../../src/modules/AutoInstall.rb', line 57

def callbackFalse_boolean_map(dummy_map)
  dummy_map = deep_copy(dummy_map)
  false
end

- (Object) callbackFalse_boolean_map_integer(dummy_map, dummy)



67
68
69
70
# File '../../src/modules/AutoInstall.rb', line 67

def callbackFalse_boolean_map_integer(dummy_map, dummy)
  dummy_map = deep_copy(dummy_map)
  false
end

- (Object) callbackFalse_boolean_string(dummy)



35
36
37
# File '../../src/modules/AutoInstall.rb', line 35

def callbackFalse_boolean_string(dummy)
  false
end

- (Object) callbackFalse_boolean_string_integer(dummy, dummy2)



43
44
45
# File '../../src/modules/AutoInstall.rb', line 43

def callbackFalse_boolean_string_integer(dummy, dummy2)
  false
end

- (Object) callbackFalse_boolean_string_map_integer(dummy, dummy_map, dummy_int)



77
78
79
80
# File '../../src/modules/AutoInstall.rb', line 77

def callbackFalse_boolean_string_map_integer(dummy, dummy_map, dummy_int)
  dummy_map = deep_copy(dummy_map)
  false
end

- (Object) callbackFalse_boolean_string_string(dummy1, dummy2)



86
87
88
# File '../../src/modules/AutoInstall.rb', line 86

def callbackFalse_boolean_string_string(dummy1, dummy2)
  false
end

- (Object) callbackFalse_boolean_string_string_integer(dummy1, dummy2, dummy3)



94
95
96
# File '../../src/modules/AutoInstall.rb', line 94

def callbackFalse_boolean_string_string_integer(dummy1, dummy2, dummy3)
  false
end

- (Object) callbackFalse_boolean_string_string_string(dummy1, dummy2, dummy3)



102
103
104
# File '../../src/modules/AutoInstall.rb', line 102

def callbackFalse_boolean_string_string_string(dummy1, dummy2, dummy3)
  false
end

- (Object) callbackTrue_boolean_map(dummy_map)



52
53
54
55
# File '../../src/modules/AutoInstall.rb', line 52

def callbackTrue_boolean_map(dummy_map)
  dummy_map = deep_copy(dummy_map)
  true
end

- (Object) callbackTrue_boolean_map_integer(dummy_map, dummy)



62
63
64
65
# File '../../src/modules/AutoInstall.rb', line 62

def callbackTrue_boolean_map_integer(dummy_map, dummy)
  dummy_map = deep_copy(dummy_map)
  true
end

- (Object) callbackTrue_boolean_string(dummy)



31
32
33
# File '../../src/modules/AutoInstall.rb', line 31

def callbackTrue_boolean_string(dummy)
  true
end

- (Object) callbackTrue_boolean_string_integer(dummy, dummy2)



39
40
41
# File '../../src/modules/AutoInstall.rb', line 39

def callbackTrue_boolean_string_integer(dummy, dummy2)
  true
end

- (Object) callbackTrue_boolean_string_map_integer(dummy, dummy_map, dummy_int)



72
73
74
75
# File '../../src/modules/AutoInstall.rb', line 72

def callbackTrue_boolean_string_map_integer(dummy, dummy_map, dummy_int)
  dummy_map = deep_copy(dummy_map)
  true
end

- (Object) callbackTrue_boolean_string_string(dummy1, dummy2)



82
83
84
# File '../../src/modules/AutoInstall.rb', line 82

def callbackTrue_boolean_string_string(dummy1, dummy2)
  true
end

- (Object) callbackTrue_boolean_string_string_integer(dummy1, dummy2, dummy3)



90
91
92
# File '../../src/modules/AutoInstall.rb', line 90

def callbackTrue_boolean_string_string_integer(dummy1, dummy2, dummy3)
  true
end

- (Object) callbackTrue_boolean_string_string_string(dummy1, dummy2, dummy3)



98
99
100
# File '../../src/modules/AutoInstall.rb', line 98

def callbackTrue_boolean_string_string_string(dummy1, dummy2, dummy3)
  true
end

- (Boolean) Continue

Read saved data in continue mode

Returns:

  • (Boolean)

    true on success



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
141
142
# File '../../src/modules/AutoInstall.rb', line 108

def Continue
  #
  # First check if there are some other control files availabe
  # i.e. for post-installation only
  #
  ret = false
  if SCR.Read(path(".target.size"), AutoinstConfig.autoconf_file) != -1
    Builtins.y2milestone(
      "XML Post installation data found: %1",
      AutoinstConfig.autoconf_file
    )
    ret = Profile.ReadXML(AutoinstConfig.autoconf_file)
    SCR.Execute(
      path(".target.bash"),
      Builtins.sformat(
        "/bin/mv %1 %2",
        AutoinstConfig.autoconf_file,
        AutoinstConfig.cache
      )
    )
    return ret
  else
    ret = Profile.ReadProfileStructure(AutoinstConfig.parsedControlFile)
    if Profile.current == {} || !ret
      Builtins.y2milestone("No saved autoinstall data found")
      return false
    else
      Builtins.y2milestone("Found and read saved autoinst data")
      SCR.Execute(path(".target.remove"), AutoinstConfig.parsedControlFile)
      return true
    end
  end

  false
end

- (void) Finish(destdir)

This method returns an undefined value.

Finish Auto-Installation by saving misc files

Parameters:

  • destdir (String)


194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# File '../../src/modules/AutoInstall.rb', line 194

def Finish(destdir)
  dircontents = Convert.to_list(
    SCR.Read(
      path(".target.dir"),
      Ops.add(AutoinstConfig.tmpDir, "/pre-scripts/")
    )
  )
  if Ops.greater_than(Builtins.size(dircontents), 0)
    SCR.Execute(
      path(".target.bash"),
      Ops.add(
        Ops.add(
          Ops.add(
            Ops.add("/bin/cp ", AutoinstConfig.tmpDir),
            "/pre-scripts/* "
          ),
          destdir
        ),
        AutoinstConfig.scripts_dir
      )
    )
    SCR.Execute(
      path(".target.bash"),
      Ops.add(
        Ops.add(
          Ops.add(
            Ops.add("/bin/cp ", AutoinstConfig.tmpDir),
            "/pre-scripts/logs/* "
          ),
          destdir
        ),
        AutoinstConfig.logs_dir
      )
    )
  end

  SCR.Execute(
    path(".target.bash"),
    Builtins.sformat(
      "/bin/cp %1 %2%3",
      "/tmp/profile/autoinst.xml",
      destdir,
      AutoinstConfig.xml_file
    )
  )
  SCR.Execute(
    path(".target.bash"),
    Builtins.sformat(
      "/bin/chmod 700 %1%2",
      destdir,
      AutoinstConfig.xml_file
    )
  )

  SCR.Execute(
    path(".target.bash"),
    Builtins.sformat(
      "/bin/cp %1 %2%3",
      Ops.add(AutoinstConfig.profile_dir, "/pre-autoinst.xml"),
      destdir,
      AutoinstConfig.cache
    )
  )
  SCR.Execute(
    path(".target.bash"),
    Builtins.sformat(
      "/bin/chmod 700 %1%2",
      destdir,
      Ops.add(AutoinstConfig.cache, "/pre-autoinst.xml")
    )
  )

  nil
end

- (Object) main



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File '../../src/modules/AutoInstall.rb', line 16

def main
  textdomain "autoinst"

  Yast.import "Profile"
  Yast.import "Mode"
  Yast.import "Stage"
  Yast.import "AutoinstConfig"
  Yast.import "AutoInstallRules"
  Yast.import "Report"
  Yast.import "TFTP"

  @autoconf = false
  AutoInstall()
end

- (String) pkg_gpg_check(data)

Implement pkgGpgCheck callback

Parameters:

  • data (Hash)

    Output from pkgGpgCheck callback.

Returns:

  • (String)

    ā€œIā€ if the package should be accepted; otherwise a blank string is returned (so no decision is made).



317
318
319
320
321
322
# File '../../src/modules/AutoInstall.rb', line 317

def pkg_gpg_check(data)
  log.debug("pkgGpgCheck data: #{data}")
  accept = PkgGpgCheckHandler.new(data, Profile.current).accept?
  log.info("PkgGpgCheckerHandler for #{data["Package"]} returned #{accept}")
  accept ? "I" : ""
end

- (Object) PXELocalBoot

Put PXE file on the boot server using tftp

Returns:

  • true on success



272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
# File '../../src/modules/AutoInstall.rb', line 272

def PXELocalBoot
  tmpdir = Convert.to_string(SCR.Read(path(".target.tmpdir")))
  hexfile = Builtins.sformat("%1/%2", tmpdir, AutoInstallRules.hostid)
  pxe = Ops.get_map(Profile.current, "pxe", {})
  dest_file = Ops.get_string(pxe, "filename", AutoInstallRules.hostid)
  if dest_file == "__MAC__"
    mac = AutoInstallRules.mac
    dest_file = Builtins.sformat(
      "01-%1-%2-%3-%4-%5-%6",
      Builtins.substring(mac, 0, 2),
      Builtins.substring(mac, 2, 2),
      Builtins.substring(mac, 4, 2),
      Builtins.substring(mac, 6, 2),
      Builtins.substring(mac, 8, 2),
      Builtins.substring(mac, 10, 2)
    )
  end
  server = Ops.get_string(pxe, "tftp-server", "")
  if server != "" && Ops.get_boolean(pxe, "pxe_localboot", false)
    Builtins.y2milestone(
      "putting pxe local boot file '%2' on server :%1",
      server,
      dest_file
    )
    config = Ops.get_string(pxe, "pxelinux-config", "")
    dir = Ops.get_string(pxe, "pxelinux-dir", "pxelinux.cfg")
    config = "DEFAULT linux\nLABEL linux\n  localboot 0" if config == ""

    SCR.Write(path(".target.string"), hexfile, config)

    return TFTP.Put(server, Ops.add(Ops.add(dir, "/"), dest_file), hexfile)
  end
  true
end

- (Boolean) Save

Save configuration

Returns:

  • (Boolean)

    true on success



183
184
185
186
187
188
189
# File '../../src/modules/AutoInstall.rb', line 183

def Save
  if Mode.autoinst || Mode.autoupgrade
    return Profile.SaveProfileStructure(AutoinstConfig.parsedControlFile)
  else
    return true
  end
end