Skip to content

Commit

Permalink
Changed the way the DASD data is refreshed
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed Nov 18, 2021
1 parent 0a9ed8c commit 66dd69a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
14 changes: 4 additions & 10 deletions src/lib/y2s390/dasd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ def partition_info
"[ \t]+([^ \t]+)[ \t]+([^ \t]+([ \t]+[^ \t]+))*[ \t]*$")

lines = out.split("\n").select { |s| s.match?(regexp) }
lines.map { |line| r = line.match(regexp); "#{r[1]} (#{r[6]})" }.join(", ")
lines.map do |line|
r = line.match(regexp)
"#{r[1]} (#{r[6]})"
end.join(", ")
end

def hwinfo
Expand Down Expand Up @@ -157,14 +160,5 @@ def sys_device_name
disk = Yast::Execute.stdout.on_target!(cmd).strip
disk.to_s.empty? ? nil : "/dev/#{disk}"
end

def refresh_data!
cmd = [LIST_CMD, id]
data = Yast::Execute.stdout.locally!(*cmd).split("\n").find { |l| l.start_with? /\d/ }

return if data.to_s.empty?

_id, @status, @device_name, _, @type, = data.split(" ")
end
end
end
28 changes: 24 additions & 4 deletions src/lib/y2s390/dasds_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def list(offline: true, force_probing: false)
a = dasd_entries(offline: offline).each_with_object([]) do |entry, arr|
next unless entry.start_with?(/\d/)

id, offline, name, _, type, = entry.split(" ")
attrs = Yast::Mode.config ? {} : { status: offline, device_name: name, type: type }
id, status, name, _, type, = entry.split(" ")
attrs = Yast::Mode.config ? {} : { status: status, device_name: name, type: type }
dasd = Y2S390::Dasd.new(id, **attrs).tap do |d|
if Yast::Mode.config
d.diag = d.use_diag = use_diag?(d)
Expand All @@ -63,6 +63,23 @@ def list(offline: true, force_probing: false)
Y2S390::DasdsCollection.new(a)
end

def refresh_data!(dasds)
dasd_entries(offline: true).each do |entry|
next unless entry.start_with?(/\d/)

id, status, name, _, type, = entry.split(" ")
dasd = dasds.by_id(id)
next unless dasd

dasd.status = status
dasd.device_name = name
dasd.type = type
update_additional_info(dasd)
end

true
end

def update_info(dasd, extended: false)
data = dasd_entries(dasd: dasd).find { |e| e.start_with?(/\d/) }
return false if data.to_s.empty?
Expand Down Expand Up @@ -90,7 +107,7 @@ def dasd_entries(offline: true, dasd: nil)
if ENV["S390_MOCKING"]
File.read("test/data/lsdasd.txt")
else
cmd = cmd_for(offline: offline)
cmd = cmd_for(offline: offline, dasd: dasd)
Yast::Execute.stdout.locally!(cmd)
end.split("\n")
end
Expand Down Expand Up @@ -150,7 +167,10 @@ def partition_info(dasd)
"[ \t]+([^ \t]+)[ \t]+([^ \t]+([ \t]+[^ \t]+))*[ \t]*$")

lines = out.split("\n").select { |s| s.match?(regexp) }
lines.map { |line| r = line.match(regexp); "#{r[1]} (#{r[6]})" }.join(", ")
lines.map do |line|
r = line.match(regexp)
"#{r[1]} (#{r[6]})"
end.join(", ")
end

def device_type_for(dasd)
Expand Down

0 comments on commit 66dd69a

Please sign in to comment.