Class: Yast::ReiplClass

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

Instance Method Summary (collapse)

Instance Method Details

- (Boolean) Abort

Abort function

Returns:

  • (Boolean)

    return true if abort



88
89
90
91
# File '../../src/modules/Reipl.rb', line 88

def Abort
  return @AbortFunction.call == true if @AbortFunction != nil
  false
end

- (Hash) AutoPackages

Return packages needed to be installed and removed during Autoinstallation to insure module has all needed software installed.

Returns:

  • (Hash)

    with 2 lists.



1032
1033
1034
# File '../../src/modules/Reipl.rb', line 1032

def AutoPackages
  { "install" => [], "remove" => [] }
end

- (Hash) Export

Dump the reipl settings to a single map (For use by autoinstallation.)

Returns:

  • (Hash)

    Dumped settings (later acceptable by Import ())



982
983
984
# File '../../src/modules/Reipl.rb', line 982

def Export
  deep_copy(@reipl_configuration)
end

- (Object) FindBootPartition

Returns the parameters of the boot partition that was found where the MBR was located.

Returns:

  • a list of parameters



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
268
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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
# File '../../src/modules/Reipl.rb', line 209

def FindBootPartition
  uParts = nil
  fError = false
  command = nil
  result = nil

  mp = Storage.GetMountPoints

  mountdata_boot = Ops.get_list(mp, "/boot", Ops.get_list(mp, "/", []))
  Builtins.y2milestone("mountdata_boot %1", mountdata_boot)
  boot_device = Ops.get_string(mountdata_boot, 0, "")

  # Examples: /dev/dasda2 or /dev/sda3
  Builtins.y2milestone(
    "FindBootPartition: BootPartitionDevice = %1",
    boot_device
  )

  # Examples: dasda2 or sda3
  fullDisk = Builtins.substring(boot_device, 5)

  Builtins.y2milestone("FindBootPartition: fullDisk = %1", fullDisk)

  if Builtins.substring(fullDisk, 0, 4) == "dasd"
    disk = nil
    #   fullDisk might be a full block device or just a partition on such a
    #   block device. If it is a partition we have to get rid of the suffix
    #   specifying the partition in order to get the containing block device.
    #   This device could have thousands of block devices, which is not uncommon
    #   on s390. In such a case the devices would have names such as "dasdaab" or
    #   "dasdaab1."
    split = Builtins.regexptokenize(fullDisk, "^(dasd)([a-z]*)([0-9]*)$")

    if split == nil || Builtins.size(split) != 3
      Builtins.y2error(
        "FindBootPartition: Could not regexptokenize fullDisk, split = %1",
        split
      )

      fError = true
    else
      disk = Ops.add(Ops.get(split, 0, ""), Ops.get(split, 1, ""))
    end

    Builtins.y2milestone(
      "FindBootPartition: found that the MBR uses dasd (%1)",
      disk
    )

    if disk != nil
      # bash-3.1# readlink -m /sys/block/dasda/device
      # /sys/devices/css0/0.0.0006/0.0.4dcf
      command = Ops.add(
        Ops.add(
          Ops.add(
            Ops.add("/usr/bin/readlink -n -m ", FindSysfsRoot()),
            "/block/"
          ),
          disk
        ),
        "/device"
      )
      Builtins.y2milestone("Executing %1", command)
      result = Convert.to_map(
        SCR.Execute(path(".target.bash_output"), command)
      )

      if Ops.get_integer(result, "exit", -1) != 0
        Builtins.y2error(
          "FindBootPartition: Execute errors and returns %1",
          Ops.get_integer(result, "exit", -1)
        )
        Builtins.y2error(
          "FindBootPartition: Execute stdout is \"%1\"",
          Ops.get_string(result, "stdout", "")
        )
        Builtins.y2error(
          "FindBootPartition: Execute stderr is \"%1\"",
          Ops.get_string(result, "stderr", "")
        )

        fError = true
      end

      Builtins.y2milestone("FindBootPartition: result = %1", result)

      readlinkParts = nil

      readlinkParts = Builtins.splitstring(
        Ops.get_string(result, "stdout", ""),
        "/"
      )

      Builtins.y2milestone(
        "FindBootPartition: readlinkParts = %1",
        readlinkParts
      )

      if Ops.less_than(Builtins.size(readlinkParts), 1)
        Builtins.y2error(
          "FindBootPartition: readlinkParts size is unexpected %1",
          readlinkParts
        )

        fError = true
      end

      ccwDevice = Ops.get(
        readlinkParts,
        Ops.subtract(Builtins.size(readlinkParts), 1),
        ""
      )

      uParts = ["ccw", ccwDevice] if !fError
    end
  elsif Builtins.substring(fullDisk, 0, 2) == "sd"
    disk = nil
    #   fullDisk might be a full block device or just a partition on such a
    #   block device. If it is a partition we have to get rid of the suffix
    #   specifying the partition in order to get the containing block device.
    #   This device could have thousands of block devices, which is not uncommon
    #   on s390. In such a case the devices would have names such as "sdaab" or
    #   "sdaab1."
    split = Builtins.regexptokenize(fullDisk, "^(sd)([a-z]*)([0-9]*)$")

    if split == nil || Builtins.size(split) != 3
      Builtins.y2error(
        "FindBootPartition: Could not regexptokenize fullDisk, split = %1",
        split
      )

      fError = true
    else
      disk = Ops.add(Ops.get(split, 0, ""), Ops.get(split, 1, ""))
    end

    if disk != nil
      Builtins.y2milestone(
        "FindBootPartition: found that the MBR uses SCSI (%1)",
        disk
      )

      deviceDirectory = Ops.add(
        Ops.add(Ops.add(FindSysfsRoot(), "/block/"), disk),
        "/device/"
      )

      # bash-3.1# cat /sys/block/sda/device/hba_id
      # 0.0.1734
      hbaId = Convert.to_string(
        SCR.Read(path(".target.string"), Ops.add(deviceDirectory, "hba_id"))
      )

      # bash-3.1# cat /sys/block/sda/device/wwpn
      # 0x500507630300c562
      wwpn = Convert.to_string(
        SCR.Read(path(".target.string"), Ops.add(deviceDirectory, "wwpn"))
      )

      # bash-3.1# cat /sys/block/sda/device/fcp_lun
      # 0x401040eb00000000
      fcpLun = Convert.to_string(
        SCR.Read(
          path(".target.string"),
          Ops.add(deviceDirectory, "fcp_lun")
        )
      )

      Builtins.y2milestone("FindBootPartition: hbaId  = %1", hbaId)
      Builtins.y2milestone("FindBootPartition: wwpn   = %1", wwpn)
      Builtins.y2milestone("FindBootPartition: fcpLun = %1", fcpLun)

      hbaId = Builtins.deletechars(hbaId, "\n ")
      wwpn = Builtins.deletechars(wwpn, "\n ")
      fcpLun = Builtins.deletechars(fcpLun, "\n ")

      if hbaId == nil || Builtins.size(hbaId) == 0
        Builtins.y2error("FindBootPartition: hbaId is empty!")
        fError = true
      end
      if wwpn == nil || Builtins.size(wwpn) == 0
        Builtins.y2error("FindBootPartition: wwpn is empty!")
        fError = true
      end
      if fcpLun == nil || Builtins.size(fcpLun) == 0
        Builtins.y2error("FindBootPartition: fcpLun is empty!")
        fError = true
      end

      uParts = ["zfcp", hbaId, wwpn, fcpLun] if !fError
    end
  else
    Builtins.y2error(
      "FindBootPartition: Unexpected format \"%1\"",
      fullDisk
    )
  end

  Builtins.y2milestone("FindBootPartition: returning uParts = %1", uParts)

  deep_copy(uParts)
end

- (String) FindSysfsRoot

Find where sysfs has been mounted.

Returns:

  • (String)

    the root



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/Reipl.rb', line 110

def FindSysfsRoot
  ret = nil
  mounts = nil

  mounts = Convert.convert(
    SCR.Read(path(".etc.mtab")),
    :from => "any",
    :to   => "list <map>"
  )

  Builtins.foreach(mounts) do |mount|
    Builtins.y2debug("FindSysfsRoot: mount = %1", mount)
    if ret == nil && Ops.get_string(mount, "vfstype", "ERROR") == "sysfs" &&
        Ops.get_string(mount, "spec", "ERROR") == "sysfs"
      ret = Ops.get_string(mount, "file")
    end
  end

  if ret == nil
    Builtins.y2error("FindSysfsRoot: after all this, ret is still nil!")

    # Note: This likely won't work so you need to check the results of calls using what we
    # are returning now.
    ret = "/sys"
  end

  Builtins.y2milestone("FindSysfsRoot: returning %1", ret)

  ret
end

- (Boolean) Import(settings)

Get all reipl settings from the first parameter (For use by autoinstallation.)

Parameters:

  • settings (Hash)

    The YCP structure to be imported.

Returns:

  • (Boolean)

    True on success



923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
# File '../../src/modules/Reipl.rb', line 923

def Import(settings)
  settings = deep_copy(settings)
  imported = {}

  if Ops.get(settings, "ccw") != nil
    ccwIn = Ops.get_map(settings, "ccw", {})
    ccwOut = { "device" => "", "loadparm" => "", "parm" => "" } # SLES 11 and z/VM only

    if Ops.get(ccwIn, "device") != nil
      Ops.set(ccwOut, "device", Ops.get(ccwIn, "device"))
    end
    if Ops.get(ccwIn, "loadparm") != nil
      Ops.set(ccwOut, "loadparm", Ops.get(ccwIn, "loadparm"))
    end
    # SLES 11 and z/VM only
    if Ops.get(ccwIn, "parm") != nil
      Ops.set(ccwOut, "parm", Ops.get(ccwIn, "parm"))
    end

    Ops.set(imported, "ccw", ccwOut)
  end

  if Ops.get(settings, "fcp") != nil
    fcpIn = Ops.get_map(settings, "fcp", {})
    fcpOut = {
      "device"   => "",
      "wwpn"     => "",
      "lun"      => "",
      "bootprog" => "",
      "br_lba"   => ""
    }

    if Ops.get(fcpIn, "device") != nil
      Ops.set(fcpOut, "device", Ops.get(fcpIn, "device"))
    end
    if Ops.get(fcpIn, "wwpn") != nil
      Ops.set(fcpOut, "wwpn", Ops.get(fcpIn, "wwpn"))
    end
    if Ops.get(fcpIn, "lun") != nil
      Ops.set(fcpOut, "lun", Ops.get(fcpIn, "lun"))
    end
    if Ops.get(fcpIn, "bootprog") != nil
      Ops.set(fcpOut, "bootprog", Ops.get(fcpIn, "bootprog"))
    end
    if Ops.get(fcpIn, "br_lba") != nil
      Ops.set(fcpOut, "br_lba", Ops.get(fcpIn, "br_lba"))
    end

    Ops.set(imported, "fcp", fcpOut)
  end

  @reipl_configuration = deep_copy(imported)

  true
end

- (Object) main



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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 '../../src/modules/Reipl.rb', line 35

def main
  textdomain "reipl"

  Yast.import "Progress"
  Yast.import "Report"
  Yast.import "Summary"
  Yast.import "Message"
  Yast.import "FileUtils"
  Yast.import "Confirm"
  Yast.import "Popup"
  Yast.import "Storage"

  # Data was modified?
  @modified = false


  @proposal_valid = false

  # Write only, used during autoinstallation.
  # Don't run services and SuSEconfig, it's all done at one place.
  @write_only = false

  # Abort function
  # return boolean return true if abort
  @AbortFunction = fun_ref(method(:Modified), "boolean ()")

  # Settings: Define all variables needed for configuration of reipl
  @reipl_configuration = {}
  # global map <string, any> reipl_configuration = $[
  #	"method":	"ccw",
  #	"ccw":		$[
  #			"device":	"0.0.4711",
  #			"loadparm":	"",
  #			"parm": 	"" /* SLES 11 and z/VM only */
  #		],
  #	"fcp":		$[
  #			"device":	"0.0.4711",
  #			"wwpn":		"0x5005076303004711",
  #			"lun":		"0x4711000000000000",
  #			"bootprog":	"0",
  #			"br_lba":	"0"
  #		]
  #];

  @reipl_directory = Ops.add(FindSysfsRoot(), "/firmware/reipl")
  @ccw_directory = Ops.add(@reipl_directory, "/ccw")
  @fcp_directory = Ops.add(@reipl_directory, "/fcp")
  @ccw_exists = FileUtils.IsDirectory(@ccw_directory) != nil
  @fcp_exists = FileUtils.IsDirectory(@fcp_directory) != nil
end

- (Object) Modified

Data was modified?

Returns:

  • true if modified



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

def Modified
  Builtins.y2debug("modified=%1", @modified)
  @modified
end

- (Object) ModifyReiplWithBootPartition(configuration)

Returns the reipl configuration passed in with what it should be for the detected boot partition.

Parameters:

  • configuration (Hash{String => Object})

    an old configuration.

Returns:

  • a map of the new target configuration.



416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
# File '../../src/modules/Reipl.rb', line 416

def ModifyReiplWithBootPartition(configuration)
  configuration = deep_copy(configuration)
  # get target information
  uParts = FindBootPartition()

  if uParts == nil
    Builtins.y2error("ModifyReiplWithBootPartition: uParts is nil")
  end

  fCCW = false
  fFCP = false

  if Builtins.size(uParts) == 2
    if Ops.get(uParts, 0, "") == "ccw"
      fCCW = true
    else
      Builtins.y2error(
        "ModifyReiplWithBootPartition: size of uParts is 2, but first word is not ccw!"
      )
    end
  elsif Builtins.size(uParts) == 4
    if Ops.get(uParts, 0, "") == "zfcp"
      fFCP = true
    else
      Builtins.y2error(
        "ModifyReiplWithBootPartition: size of uParts is 4, but format is not what we expect"
      )
    end
  else
    Builtins.y2error(
      "ModifyReiplWithBootPartition: size of uParts is not 2 or 4"
    )
  end

  if fCCW
    Ops.set(configuration, "method", "ccw")
    ccw_map = Ops.get_map(configuration, "ccw")

    Ops.set(ccw_map, "device", Ops.get(uParts, 1, ""))
    Ops.set(ccw_map, "loadparm", "")
    #ccw_map["parm"] = ""; /* SLES 11 and z/VM only */ // read only
    Ops.set(configuration, "ccw", ccw_map)
    Builtins.y2milestone("ModifyReiplWithBootPartition: modified ccw map")
  elsif fFCP
    Ops.set(configuration, "method", "fcp")
    fcp_map = Ops.get_map(configuration, "fcp")

    Ops.set(fcp_map, "device", Ops.get(uParts, 1, ""))
    Ops.set(fcp_map, "wwpn", Ops.get(uParts, 2, ""))
    Ops.set(fcp_map, "lun", Ops.get(uParts, 3, ""))
    Ops.set(fcp_map, "bootprog", "0")
    Ops.set(fcp_map, "br_lba", "0")
    Ops.set(configuration, "fcp", fcp_map)
    Builtins.y2milestone("ModifyReiplWithBootPartition: modified fcp map")
  else
    Builtins.y2error("ModifyReiplWithBootPartition: Unknown disk type!")
    Ops.set(configuration, "method", "unknown_disk_type")
  end

  deep_copy(configuration)
end

- (Object) Read

Read all reipl settings

Returns:

  • true on success



642
643
644
645
646
647
648
649
650
# File '../../src/modules/Reipl.rb', line 642

def Read
  configuration = ReadState()

  @reipl_configuration = deep_copy(configuration) if configuration != nil

  return false if Abort()
  @modified = false
  true
end

- (Hash{String => Object}) ReadState

Read all reipl settings

Returns:

  • (Hash{String => Object})

    of settings



480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
# File '../../src/modules/Reipl.rb', line 480

def ReadState
  configuration = {}
  Ops.set(
    configuration,
    "ccw",
    { "device" => "", "loadparm" => "", "parm" => "" }
  )
  Ops.set(
    configuration,
    "fcp",
    {
      "device"   => "",
      "wwpn"     => "",
      "lun"      => "",
      "bootprog" => "",
      "br_lba"   => ""
    }
  )

  if !SanityCheck()
    Builtins.y2error("Reipl::Read: SanityCheck failed!")

    # Popup::Error (_("This machine does not support reipl!"));
    # Don't bother the user, just silently do shutdown in the end.
    #    Especially, since this would currently popup three times
    #    during installation.

    return deep_copy(configuration)
  end

  if @ccw_exists
    ccw_map = Ops.get_map(configuration, "ccw")

    Ops.set(
      ccw_map,
      "device",
      Builtins.deletechars(
        Convert.to_string(
          SCR.Read(
            path(".target.string"),
            Ops.add(@ccw_directory, "/device")
          )
        ),
        "\n "
      )
    )
    Ops.set(
      ccw_map,
      "loadparm",
      Builtins.deletechars(
        Convert.to_string(
          SCR.Read(
            path(".target.string"),
            Ops.add(@ccw_directory, "/loadparm")
          )
        ),
        "\n "
      )
    )
    Ops.set(
      ccw_map,
      "parm",
      Builtins.deletechars(
        Convert.to_string(
          SCR.Read(path(".target.string"), Ops.add(@ccw_directory, "/parm"))
        ),
        "\n "
      )
    ) # SLES 11 and z/VM only

    Ops.set(configuration, "ccw", ccw_map)
  else
    Builtins.y2warning("Reipl::Read: ccw is not configured.")
  end

  if @fcp_exists
    fcp_map = Ops.get_map(configuration, "fcp")

    Ops.set(
      fcp_map,
      "device",
      Builtins.deletechars(
        Convert.to_string(
          SCR.Read(
            path(".target.string"),
            Ops.add(@fcp_directory, "/device")
          )
        ),
        "\n "
      )
    )
    Ops.set(
      fcp_map,
      "wwpn",
      Builtins.deletechars(
        Convert.to_string(
          SCR.Read(path(".target.string"), Ops.add(@fcp_directory, "/wwpn"))
        ),
        "\n "
      )
    )
    Ops.set(
      fcp_map,
      "lun",
      Builtins.deletechars(
        Convert.to_string(
          SCR.Read(path(".target.string"), Ops.add(@fcp_directory, "/lun"))
        ),
        "\n "
      )
    )
    Ops.set(
      fcp_map,
      "bootprog",
      Builtins.deletechars(
        Convert.to_string(
          SCR.Read(
            path(".target.string"),
            Ops.add(@fcp_directory, "/bootprog")
          )
        ),
        "\n "
      )
    )
    Ops.set(
      fcp_map,
      "br_lba",
      Builtins.deletechars(
        Convert.to_string(
          SCR.Read(
            path(".target.string"),
            Ops.add(@fcp_directory, "/br_lba")
          )
        ),
        "\n "
      )
    )

    Ops.set(configuration, "fcp", fcp_map)
  else
    Builtins.y2warning("Reipl::Read: fcp is not configured.")
  end

  Ops.set(
    configuration,
    "method",
    Builtins.deletechars(
      Convert.to_string(
        SCR.Read(
          path(".target.string"),
          Ops.add(@reipl_directory, "/reipl_type")
        )
      ),
      "\n "
    )
  )

  deep_copy(configuration)
end

- (Boolean) SanityCheck

Check to see if reipl is supported by the kernel.

Returns:

  • (Boolean)

    true if support exists.



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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File '../../src/modules/Reipl.rb', line 143

def SanityCheck
  # @TBD The following is broken during install since the id command is missing
  # bash-3.1# find `echo $PATH | tr ':' ' '` -name id
  #	if (!Confirm::MustBeRoot ()) {
  #		y2error ("User must be root!");
  #	}

  if !FileUtils.IsDirectory(@reipl_directory)
    Builtins.y2error("Directory does not exist: %1", @reipl_directory)
    return false
  end

  if !@ccw_exists && !@fcp_exists
    Builtins.y2error(
      "Either ccw or fcp must exist under %1",
      @reipl_directory
    )
    return false
  end

  if @ccw_exists
    if !FileUtils.Exists(Ops.add(@ccw_directory, "/device"))
      Builtins.y2error("Missing device under %1", @ccw_directory)
      return false
    end
    if !FileUtils.Exists(Ops.add(@ccw_directory, "/loadparm"))
      Builtins.y2error("Missing loadparm under %1", @ccw_directory)
      return false
    end 
    # don't check for "parm" since it might not be there under zLPAR
  end

  if @fcp_exists
    if !FileUtils.Exists(Ops.add(@fcp_directory, "/device"))
      Builtins.y2error("Missing device under %1", @fcp_directory)
      return false
    end
    if !FileUtils.Exists(Ops.add(@fcp_directory, "/wwpn"))
      Builtins.y2error("Missing wwpn under %1", @fcp_directory)
      return false
    end
    if !FileUtils.Exists(Ops.add(@fcp_directory, "/lun"))
      Builtins.y2error("Missing lun under %1", @fcp_directory)
      return false
    end
    if !FileUtils.Exists(Ops.add(@fcp_directory, "/bootprog"))
      Builtins.y2error("Missing bootprog under %1", @fcp_directory)
      return false
    end
    if !FileUtils.Exists(Ops.add(@fcp_directory, "/br_lba"))
      Builtins.y2error("Missing br_lba under %1", @fcp_directory)
      return false
    end
  end

  if !FileUtils.Exists(Ops.add(@reipl_directory, "/reipl_type"))
    Builtins.y2error("Missing reipl_type under %1", @reipl_directory)
    return false
  end

  true
end

- (Object) SetModified

Indicate that the data was modified



101
102
103
104
105
106
# File '../../src/modules/Reipl.rb', line 101

def SetModified
  Builtins.y2debug("Reipl::SetModified")
  @modified = true

  nil
end

- (Object) Summary

Create a textual summary and a list of unconfigured cards

Returns:

  • summary of the current configuration



988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
# File '../../src/modules/Reipl.rb', line 988

def Summary
  summary = ""
  status = nil
  found = nil

  summary = Summary.AddHeader(summary, _("Configured reipl methods"))

  summary = Summary.OpenList(summary)

  found = Ops.get_map(@reipl_configuration, "ccw")
  if found != nil
    if Ops.get(@reipl_configuration, "method") == "ccw"
      status = _("The method ccw is configured and being used.")
    else
      status = _("The method ccw is configured.")
    end
  else
    status = _("The method ccw is not supported.")
  end

  summary = Summary.AddListItem(summary, status)

  found = Ops.get_map(@reipl_configuration, "fcp")
  if found != nil
    if Ops.get(@reipl_configuration, "method") == "fcp"
      status = _("The method fcp is configured and being used.")
    else
      status = _("The method fcp is configured.")
    end
  else
    status = _("The method fcp is not supported.")
  end

  summary = Summary.AddListItem(summary, status)

  summary = Summary.CloseList(summary)

  [summary, []]
end

- (Object) Write

Write all reipl settings

Returns:

  • true on success



911
912
913
914
915
916
917
# File '../../src/modules/Reipl.rb', line 911

def Write
  rc = WriteState(@reipl_configuration)

  return false if Abort()

  rc
end

- (Object) WriteState(configuration)

Write all reipl setting to the firmware

Parameters:

  • configuration (Hash{String => Object})

    the current configuration.

Returns:

  • true on success



655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
# File '../../src/modules/Reipl.rb', line 655

def WriteState(configuration)
  configuration = deep_copy(configuration)
  rc = true

  if Ops.get(configuration, "method") != nil &&
      Ops.get_string(configuration, "method", "unknown_disk_type") !=
        "unknown_disk_type"
    Builtins.y2milestone(
      "Reipl::WriteState: writing out method %1",
      Ops.get_string(configuration, "method", "")
    )

    SCR.Write(
      path(".target.string"),
      Ops.add(@reipl_directory, "/reipl_type"),
      Ops.get_string(configuration, "method")
    ) 
    #   I see a difference between the value written to the log and written to sysfs:
    #   configuration["method"]:"" <===> (string)configuration["method"]:nil
    #   But that's probably OK here and not the reason for the obvious bug in the y2log.
  end

  if @ccw_exists
    result = nil
    echoCmd = nil

    Builtins.y2milestone(
      "Reipl::WriteState: writing out ccw configuration."
    )

    ccw_map = Ops.get_map(configuration, "ccw")

    if ccw_map != nil
      Builtins.y2milestone(
        "Reipl::WriteState: ccw_map device is now \"%1\"",
        Ops.get_string(ccw_map, "device", "???")
      )
      Builtins.y2milestone(
        "Reipl::WriteState: ccw_map loadparm is now \"%1\"",
        Ops.get_string(ccw_map, "loadparm", "???")
      )

      # NOTE: It should be this, but you cannot write an empty ("") string out!
      #	    rc = SCR::Write (.target.string, ccw_directory + "/device", (string)ccw_map["device"]:nil);
      #	    rc = SCR::Write (.target.string, ccw_directory + "/loadparm", (string)ccw_map["loadparm"]:nil);

      echoCmd = Ops.add(
        Ops.add(
          Ops.add(
            Ops.add("echo \"", Ops.get_string(ccw_map, "device")),
            "\" > "
          ),
          @ccw_directory
        ),
        "/device"
      )
      Builtins.y2milestone("Executing %1", echoCmd)
      result = Convert.to_map(
        SCR.Execute(path(".target.bash_output"), echoCmd)
      )
      if Ops.get_integer(result, "exit", -1) != 0
        Builtins.y2error(
          "Error: Writing ccw device returns %1",
          Ops.get_string(result, "stderr", "")
        )

        rc = false
      end

      echoCmd = Ops.add(
        Ops.add(
          Ops.add(
            Ops.add("echo \"", Ops.get_string(ccw_map, "loadparm")),
            "\" > "
          ),
          @ccw_directory
        ),
        "/loadparm"
      )
      Builtins.y2milestone("Executing %1", echoCmd)
      result = Convert.to_map(
        SCR.Execute(path(".target.bash_output"), echoCmd)
      )
      if Ops.get_integer(result, "exit", -1) != 0
        Builtins.y2error(
          "Error: Writing ccw loadparm returns %1",
          Ops.get_string(result, "stderr", "")
        )

        rc = false
      end
    else
      Builtins.y2error("Reipl::WriteState: ccw_map is nil!")

      rc = false
    end
  end

  if @fcp_exists
    result = nil
    echoCmd = nil

    Builtins.y2milestone(
      "Reipl::WriteState: writing out fcp configuration."
    )

    fcp_map = Ops.get_map(configuration, "fcp")

    if fcp_map != nil
      Builtins.y2milestone(
        "Reipl::WriteState: fcp_map device is now \"%1\"",
        Ops.get_string(fcp_map, "device", "???")
      )
      Builtins.y2milestone(
        "Reipl::WriteState: fcp_map wwpn is now \"%1\"",
        Ops.get_string(fcp_map, "wwpn", "???")
      )
      Builtins.y2milestone(
        "Reipl::WriteState: fcp_map lun is now \"%1\"",
        Ops.get_string(fcp_map, "lun", "???")
      )
      Builtins.y2milestone(
        "Reipl::WriteState: fcp_map bootprog is now \"%1\"",
        Ops.get_string(fcp_map, "bootprog", "???")
      )
      Builtins.y2milestone(
        "Reipl::WriteState: fcp_map br_lba is now \"%1\"",
        Ops.get_string(fcp_map, "br_lba", "???")
      )

      echoCmd = Ops.add(
        Ops.add(
          Ops.add(
            Ops.add("echo \"", Ops.get_string(fcp_map, "device")),
            "\" > "
          ),
          @fcp_directory
        ),
        "/device"
      )
      Builtins.y2milestone("Executing %1", echoCmd)
      result = Convert.to_map(
        SCR.Execute(path(".target.bash_output"), echoCmd)
      )
      if Ops.get_integer(result, "exit", -1) != 0
        Builtins.y2error(
          "Error: Writing fcp device returns %1",
          Ops.get_string(result, "stderr", "")
        )

        rc = false
      end

      echoCmd = Ops.add(
        Ops.add(
          Ops.add(
            Ops.add("echo \"", Ops.get_string(fcp_map, "wwpn")),
            "\" > "
          ),
          @fcp_directory
        ),
        "/wwpn"
      )
      Builtins.y2milestone("Executing %1", echoCmd)
      result = Convert.to_map(
        SCR.Execute(path(".target.bash_output"), echoCmd)
      )
      if Ops.get_integer(result, "exit", -1) != 0
        Builtins.y2error(
          "Error: Writing fcp wwpn returns %1",
          Ops.get_string(result, "stderr", "")
        )

        rc = false
      end

      echoCmd = Ops.add(
        Ops.add(
          Ops.add(
            Ops.add("echo \"", Ops.get_string(fcp_map, "lun")),
            "\" > "
          ),
          @fcp_directory
        ),
        "/lun"
      )
      Builtins.y2milestone("Executing %1", echoCmd)
      result = Convert.to_map(
        SCR.Execute(path(".target.bash_output"), echoCmd)
      )
      if Ops.get_integer(result, "exit", -1) != 0
        Builtins.y2error(
          "Error: Writing fcp lun returns %1",
          Ops.get_string(result, "stderr", "")
        )

        rc = false
      end

      echoCmd = Ops.add(
        Ops.add(
          Ops.add(
            Ops.add("echo \"", Ops.get_string(fcp_map, "bootprog")),
            "\" > "
          ),
          @fcp_directory
        ),
        "/bootprog"
      )
      Builtins.y2milestone("Executing %1", echoCmd)
      result = Convert.to_map(
        SCR.Execute(path(".target.bash_output"), echoCmd)
      )
      if Ops.get_integer(result, "exit", -1) != 0
        Builtins.y2error(
          "Error: Writing fcp bootprog returns %1",
          Ops.get_string(result, "stderr", "")
        )

        rc = false
      end

      echoCmd = Ops.add(
        Ops.add(
          Ops.add(
            Ops.add("echo \"", Ops.get_string(fcp_map, "br_lba")),
            "\" > "
          ),
          @fcp_directory
        ),
        "/br_lba"
      )
      Builtins.y2milestone("Executing %1", echoCmd)
      result = Convert.to_map(
        SCR.Execute(path(".target.bash_output"), echoCmd)
      )
      if Ops.get_integer(result, "exit", -1) != 0
        Builtins.y2error(
          "Error: Writing fcp br_lba returns %1",
          Ops.get_string(result, "stderr", "")
        )

        rc = false
      end
    else
      Builtins.y2error("Reipl::Write: fcp_map is nil!")

      rc = false
    end
  end

  rc
end