Class: Yast::AutoInstallClass

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

Instance Method Summary (collapse)

Instance Method Details

- (void) AutoInstall

This method returns an undefined value.

Constructer



143
144
145
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
# File '../../src/modules/AutoInstall.rb', line 143

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)



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

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

- (Object) callbackFalse_boolean_map(dummy_map)



54
55
56
57
# File '../../src/modules/AutoInstall.rb', line 54

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

- (Object) callbackFalse_boolean_map_integer(dummy_map, dummy)



64
65
66
67
# File '../../src/modules/AutoInstall.rb', line 64

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

- (Object) callbackFalse_boolean_string(dummy)



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

def callbackFalse_boolean_string(dummy)
  false
end

- (Object) callbackFalse_boolean_string_integer(dummy, dummy2)



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

def callbackFalse_boolean_string_integer(dummy, dummy2)
  false
end

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



74
75
76
77
# File '../../src/modules/AutoInstall.rb', line 74

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)



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

def callbackFalse_boolean_string_string(dummy1, dummy2)
  false
end

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



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

def callbackFalse_boolean_string_string_integer(dummy1, dummy2, dummy3)
  false
end

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



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

def callbackFalse_boolean_string_string_string(dummy1, dummy2, dummy3)
  false
end

- (Object) callbackTrue_boolean_map(dummy_map)



49
50
51
52
# File '../../src/modules/AutoInstall.rb', line 49

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

- (Object) callbackTrue_boolean_map_integer(dummy_map, dummy)



59
60
61
62
# File '../../src/modules/AutoInstall.rb', line 59

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

- (Object) callbackTrue_boolean_string(dummy)



28
29
30
# File '../../src/modules/AutoInstall.rb', line 28

def callbackTrue_boolean_string(dummy)
  true
end

- (Object) callbackTrue_boolean_string_integer(dummy, dummy2)



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

def callbackTrue_boolean_string_integer(dummy, dummy2)
  true
end

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



69
70
71
72
# File '../../src/modules/AutoInstall.rb', line 69

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)



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

def callbackTrue_boolean_string_string(dummy1, dummy2)
  true
end

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



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

def callbackTrue_boolean_string_string_integer(dummy1, dummy2, dummy3)
  true
end

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



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

def callbackTrue_boolean_string_string_string(dummy1, dummy2, dummy3)
  true
end

- (Boolean) Continue

Read saved data in continue mode

Returns:

  • (Boolean)

    true on success



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

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)


191
192
193
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
# File '../../src/modules/AutoInstall.rb', line 191

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



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File '../../src/modules/AutoInstall.rb', line 13

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

- (Object) PXELocalBoot

Put PXE file on the boot server using tftp

Returns:

  • true on success



269
270
271
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
# File '../../src/modules/AutoInstall.rb', line 269

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



180
181
182
183
184
185
186
# File '../../src/modules/AutoInstall.rb', line 180

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

- (Object) TurnOff

Turn off the second stage of autoyast



306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
# File '../../src/modules/AutoInstall.rb', line 306

def TurnOff
  if !Ops.get_boolean(
      Profile.current,
      ["general", "mode", "second_stage"],
      true
    )
    Builtins.y2milestone(
      "switching from autoinstallation to manual installation in second stage"
    )
    SCR.Execute(
      path(".target.bash"),
      "/bin/grep -v -i '^autoyast:' /etc/install.inf > /tmp/install.inf.new"
    )
    SCR.Execute(
      path(".target.bash"),
      "/bin/mv /tmp/install.inf.new /etc/install.inf"
    )
  end

  nil
end