Skip to content

Commit

Permalink
Merge pull request #79 from jsrain/master
Browse files Browse the repository at this point in the history
fixed parsing of iscsiadm -m node -P 1 (bsc#1121806)
  • Loading branch information
jsrain committed Mar 4, 2019
2 parents 71d39f2 + 026fd39 commit 56e89da
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
6 changes: 6 additions & 0 deletions package/yast2-iscsi-client.changes
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Mon Mar 4 13:36:13 UTC 2019 - jsrain@suse.cz

- fixed parsing of iscsiadm -m node -P 1 (bsc#1121806)
- 4.1.6

-------------------------------------------------------------------
Fri Mar 1 13:36:35 UTC 2019 - snwint@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-iscsi-client.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-iscsi-client
Version: 4.1.5
Version: 4.1.6
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
20 changes: 16 additions & 4 deletions src/modules/IscsiClientLib.rb
Expand Up @@ -473,12 +473,23 @@ def ScanDiscovered(data)
target = ""
portal = ""
iface = ""
dumped = true
Builtins.y2milestone("Got data: %1", data)

# Each entry starts with Target:, the other two values are optional
# (except the first entry) and, if missing, are inherited from previous
# entry. Therefore: Dump whatever is cached on Target: entry and once
# again at the end. Example input in the test case.

Builtins.foreach(data) do |row|
row = Builtins.substring(row, Builtins.findfirstnotof(row, "\t "), 999)
if Builtins.search(row, "Target:") != nil
if !dumped
# don't add Scope:Link IPv6 address
ret << "#{portal} #{target} #{iface}" if !portal.start_with?("[fe80:")
end
target = Ops.get(Builtins.splitstring(row, " "), 1, "")
dumped = false
elsif Builtins.search(row, "Portal:") != nil
if Builtins.search(row, "Current Portal:") != nil
portal = Ops.get(Builtins.splitstring(row, " "), 2, "")
Expand All @@ -494,12 +505,13 @@ def ScanDiscovered(data)
elsif Builtins.search(row, "Iface Name:") != nil
iface = Ops.get(Builtins.splitstring(row, " "), 2, "")
iface = Ops.get(@iface_file, iface, iface)
# don't add Scope:Link IPv6 address
if !portal.start_with?("[fe80:")
ret = ret << "#{portal} #{target} #{iface}"
end
end
end
if !dumped
# don't add Scope:Link IPv6 address
ret << "#{portal} #{target} #{iface}" if !portal.start_with?("[fe80:")
end

Builtins.y2milestone("ScanDiscovered ret:%1", ret)
deep_copy(ret)
end
Expand Down
8 changes: 5 additions & 3 deletions test/ScanDiscovered_spec.rb
Expand Up @@ -58,12 +58,14 @@
["Target: iqn.2013-10.de.suse:test_file2",
"\tPortal: [fe80::a00:27ff:fe1b:a7fe]:3260,1",
"\t\tIface Name: default",
"Target: iqn.2013-10.de.suse:test_file2",
"\tPortal: [2620:113:80c0:8080:e051:f9ea:73c7:9171]:3260,1",
"\t\tIface Name: default",
"Target: iqn.2013-10.de.suse:test_file2",
"\tPortal: 10.120.66.182:3260,1",
"\t\tIface Name: default",
"\tPortal: [2620:113:80c0:8080:a00:27ff:fe1b:a7fe]:3260,1",
"\t\tIface Name: default"]
"Target: iqn.2013-10.de.suse:test_file2",
"\tPortal: [2620:113:80c0:8080:a00:27ff:fe1b:a7fe]:3260,1"]

)). to eq(
[
"[2620:113:80c0:8080:e051:f9ea:73c7:9171]:3260 iqn.2013-10.de.suse:test_file2 default",
Expand Down

0 comments on commit 56e89da

Please sign in to comment.