From 66dd69ac30e9a1eb8efddedcc4b700a3c4572c0b Mon Sep 17 00:00:00 2001 From: Knut Anderssen Date: Thu, 18 Nov 2021 09:24:04 +0000 Subject: [PATCH] Changed the way the DASD data is refreshed --- src/lib/y2s390/dasd.rb | 14 ++++---------- src/lib/y2s390/dasds_reader.rb | 28 ++++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/lib/y2s390/dasd.rb b/src/lib/y2s390/dasd.rb index e56fbc57..73091ee8 100644 --- a/src/lib/y2s390/dasd.rb +++ b/src/lib/y2s390/dasd.rb @@ -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 @@ -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 diff --git a/src/lib/y2s390/dasds_reader.rb b/src/lib/y2s390/dasds_reader.rb index 2a17d13a..c8f63009 100644 --- a/src/lib/y2s390/dasds_reader.rb +++ b/src/lib/y2s390/dasds_reader.rb @@ -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) @@ -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? @@ -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 @@ -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)