Skip to content

Commit

Permalink
Merge c3608ff into 4e8c445
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidner committed Oct 7, 2021
2 parents 4e8c445 + c3608ff commit 1ebd7de
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 10 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ For s390 development these resources are used:

- https://www.ibm.com/developerworks/linux/linux390/documentation_dev.html
- https://www.ibm.com/developerworks/linux/linux390/documentation_suse.html (for released products)

##
17 changes: 13 additions & 4 deletions src/include/s390/dasd/dialogs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ def WriteDialog
ret ? :next : :abort
end

# @param [String] channel
# @return [Yast::Term] table cell for the channel, with a sort key
def channel_cell(channel)
sk = DASDController.channel_sort_key(channel)
Yast::Term.new(:cell, Yast::Term.new(:sortKey, sk), channel)
end

# Get the list of items for the table of DASD devices
# @param min_chan integer minimal channel number
# @param max_chan integer maximal channel number
Expand All @@ -86,15 +93,17 @@ def GetDASDDiskItems

if Mode.config
items = Builtins.maplist(devices) do |k, d|
channel = Ops.get_string(d, "channel", "")
channel = d.fetch("channel", "")
channel_c = channel_cell(channel)
diag = String.YesNo(Ops.get_boolean(d, "diag", false))
format = String.YesNo(Ops.get_boolean(d, "format", false))
Item(Id(k), channel, format, diag)
Item(Id(k), channel_c, format, diag)
end
else
items = Builtins.maplist(devices) do |k, d|
active = Ops.get_boolean(d, ["resource", "io", 0, "active"], false)
channel = Ops.get_string(d, "channel", "")
channel = d.fetch("channel", "")
channel_c = channel_cell(channel)
access = Builtins.toupper(
Ops.get_string(d, ["resource", "io", 0, "mode"], "RO")
)
Expand Down Expand Up @@ -144,7 +153,7 @@ def GetDASDDiskItems
end
Item(
Id(k),
channel,
channel_c,
device,
type,
access,
Expand Down
31 changes: 25 additions & 6 deletions src/modules/DASDController.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
require "yast"
require "yast2/popup"
require "shellwords"
require "yaml"

module Yast
class DASDControllerClass < Module
Expand Down Expand Up @@ -274,6 +275,13 @@ def GetDevices
deep_copy(@devices)
end

# @param channel [String] "0.0.0000" "ab.c.Def0"
# @return [String] "0000000" "abcdef0"
def channel_sort_key(channel)
parts = channel.downcase.split(".", 3)
format("%02s%1s%4s", parts[0], parts[1], parts[2])
end

def GetFilteredDevices
min_strs = Builtins.splitstring(@filter_min, ".")
min_css = Builtins.tointeger(Ops.add("0x", Ops.get(min_strs, 0, "")))
Expand Down Expand Up @@ -359,6 +367,21 @@ def Summary
deep_copy(ret)
end

# In production, call SCR.Read(.probe.disk).
# For testing, point YAST2_S390_PROBE_DISK to a YAML file
# with the mock value.
# Suggesstion:
# YAST2_S390_PROBE_DISK=test/data/probe_disk_dasd.yml rake run"[dasd]"
# @return [Array<Hash>] .probe.disk output
def probe_or_mock_disks
mock_filename = ENV["YAST2_S390_PROBE_DISK"]
if mock_filename
YAML.load(File.read(mock_filename))
else
SCR.Read(path(".probe.disk"))
end
end

# Return packages needed to be installed and removed during
# Autoinstallation to insure module has all needed software
# installed.
Expand All @@ -370,7 +393,7 @@ def AutoPackages
# Check if DASD subsystem is available
# @return [Boolean] True if more than one disk
def IsAvailable
disks = SCR.Read(path(".probe.disk"))
disks = probe_or_mock_disks
count = disks.count { |d| d["device"] == "DASD" }
log.info("number of probed DASD devices #{count}")
count > 0
Expand Down Expand Up @@ -829,11 +852,7 @@ def active_disk?(disk)
# @return [Array<Hash>] Found DASD disks
def find_disks(force_probing: false)
return @disks if @disks && !force_probing
disks = Convert.convert(
SCR.Read(path(".probe.disk")),
from: "any",
to: "list <map <string, any>>"
)
disks = probe_or_mock_disks
disks = Builtins.filter(disks) do |d|
Builtins.tolower(Ops.get_string(d, "device", "")) == "dasd"
end
Expand Down

0 comments on commit 1ebd7de

Please sign in to comment.