commit yast2-iscsi-client for openSUSE:Factory
![](https://seccdn.libravatar.org/avatar/e2145bc5cf53dda95c308a3c75e8fef3.jpg?s=120&d=mm&r=g)
Hello community, here is the log from the commit of package yast2-iscsi-client for openSUSE:Factory checked in at 2016-02-25 21:58:58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-iscsi-client (Old) and /work/SRC/openSUSE:Factory/.yast2-iscsi-client.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "yast2-iscsi-client" Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-iscsi-client/yast2-iscsi-client.changes 2015-08-13 18:09:55.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-iscsi-client.new/yast2-iscsi-client.changes 2016-02-25 22:36:50.000000000 +0100 @@ -1,0 +2,13 @@ +Tue Feb 16 11:28:14 CET 2016 - gs@suse.de + +- fix syntax error in "publish" section of IscsiClientLib.rb +- 3.1.25 + +------------------------------------------------------------------- +Tue Feb 9 15:23:12 CET 2016 - gs@suse.de + +- display startup mode "onboot" for iBFT sessions and don't allow + to change the mode on 'Edit' screen (bnc#954509) +- 3.1.24 + +------------------------------------------------------------------- Old: ---- yast2-iscsi-client-3.1.23.tar.bz2 New: ---- yast2-iscsi-client-3.1.25.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-iscsi-client.spec ++++++ --- /var/tmp/diff_new_pack.De5lyT/_old 2016-02-25 22:36:51.000000000 +0100 +++ /var/tmp/diff_new_pack.De5lyT/_new 2016-02-25 22:36:51.000000000 +0100 @@ -1,7 +1,7 @@ # # spec file for package yast2-iscsi-client # -# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: yast2-iscsi-client -Version: 3.1.23 +Version: 3.1.25 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -29,7 +29,6 @@ BuildRequires: update-desktop-files BuildRequires: yast2 >= 2.23.15 BuildRequires: yast2-devtools >= 3.1.10 -BuildRequires: yast2-testsuite BuildRequires: rubygem(rspec) Requires: yast2-packager ++++++ yast2-iscsi-client-3.1.23.tar.bz2 -> yast2-iscsi-client-3.1.25.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-iscsi-client-3.1.23/package/yast2-iscsi-client.changes new/yast2-iscsi-client-3.1.25/package/yast2-iscsi-client.changes --- old/yast2-iscsi-client-3.1.23/package/yast2-iscsi-client.changes 2015-08-11 15:47:11.000000000 +0200 +++ new/yast2-iscsi-client-3.1.25/package/yast2-iscsi-client.changes 2016-02-16 11:57:08.000000000 +0100 @@ -1,4 +1,17 @@ ------------------------------------------------------------------- +Tue Feb 16 11:28:14 CET 2016 - gs@suse.de + +- fix syntax error in "publish" section of IscsiClientLib.rb +- 3.1.25 + +------------------------------------------------------------------- +Tue Feb 9 15:23:12 CET 2016 - gs@suse.de + +- display startup mode "onboot" for iBFT sessions and don't allow + to change the mode on 'Edit' screen (bnc#954509) +- 3.1.24 + +------------------------------------------------------------------- Thu Jul 30 12:06:28 CEST 2015 - gs@suse.de - show error popup if target connection failed (bsc#9339537) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-iscsi-client-3.1.23/package/yast2-iscsi-client.spec new/yast2-iscsi-client-3.1.25/package/yast2-iscsi-client.spec --- old/yast2-iscsi-client-3.1.23/package/yast2-iscsi-client.spec 2015-08-11 15:47:11.000000000 +0200 +++ new/yast2-iscsi-client-3.1.25/package/yast2-iscsi-client.spec 2016-02-16 11:57:08.000000000 +0100 @@ -17,7 +17,7 @@ Name: yast2-iscsi-client -Version: 3.1.23 +Version: 3.1.25 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -27,7 +27,7 @@ License: GPL-2.0 # Service module switched to systemd BuildRequires: yast2 >= 2.23.15 -BuildRequires: docbook-xsl-stylesheets libxslt update-desktop-files yast2-testsuite +BuildRequires: docbook-xsl-stylesheets libxslt update-desktop-files BuildRequires: yast2-devtools >= 3.1.10 BuildRequires: rubygem(rspec) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-iscsi-client-3.1.23/src/include/iscsi-client/dialogs.rb new/yast2-iscsi-client-3.1.25/src/include/iscsi-client/dialogs.rb --- old/yast2-iscsi-client-3.1.23/src/include/iscsi-client/dialogs.rb 2015-08-11 15:47:11.000000000 +0200 +++ new/yast2-iscsi-client-3.1.25/src/include/iscsi-client/dialogs.rb 2016-02-16 11:57:08.000000000 +0100 @@ -156,7 +156,7 @@ ), Left( HBox( - PushButton(Id(:add), _("Add")), # `PushButton(`id(`toggle), _("Toggle Start-Up")) + PushButton(Id(:add), _("Add")), PushButton(Id(:edit), _("Edit")), PushButton(Id(:del), _("Disconnect")) ) @@ -300,9 +300,12 @@ "opt" => [:hstretch, :notify], "label" => _("Startup"), "items" => [ - ["manual", "manual"], - ["onboot", "onboot"], - ["automatic", "automatic"] + # iSCSI target has to be connected manually + ["manual", _("manual")], + # iSCSI target available at boot (respected by 'dracut') + ["onboot", _("onboot")], + # iSCSI target enabled automatically (by 'systemd') + ["automatic", _("automatic")] ] }, # widget for portal address @@ -503,6 +506,7 @@ @current_tab = return_to caption = _("iSCSI Initiator Discovery") w = CWM.CreateWidgets(["startup", "conn_auth"], @widgets) + contents = VBox( VStretch(), HBox( @@ -528,6 +532,11 @@ Label.BackButton, Label.NextButton ) + + if (IscsiClientLib.iBFT?(IscsiClientLib.getCurrentNodeValues)) + UI.ChangeWidget(Id("startup"), :Enabled, false) + end + ret = CWM.Run( w, { :abort => fun_ref(method(:ReallyAbort), "boolean ()") } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-iscsi-client-3.1.23/src/include/iscsi-client/widgets.rb new/yast2-iscsi-client-3.1.25/src/include/iscsi-client/widgets.rb --- old/yast2-iscsi-client-3.1.23/src/include/iscsi-client/widgets.rb 2015-08-11 15:47:11.000000000 +0200 +++ new/yast2-iscsi-client-3.1.25/src/include/iscsi-client/widgets.rb 2016-02-16 11:57:08.000000000 +0100 @@ -230,41 +230,6 @@ when :edit record = setRecord return :edit - when :toggle - # change manual/onboot status of connected target - # don't use automatic anymore (replaced by onboot) (bnc#449108) - record = setRecord - if Ops.greater_than(Builtins.size(record), 0) - Builtins.y2milestone("toggle record %1", record) - startup = IscsiClientLib.getStartupStatus - if Ops.greater_than(Builtins.size(startup), 0) - # toggle all 3 possible values (bnc#457252) - options = ["manual", "onboot", "automatic"] - pos = 0 - Builtins.foreach(options) do |option| - if startup == option - startup = Ops.get( - options, - Ops.greater_than(Builtins.size(options), Ops.add(pos, 1)) ? - Ops.add(pos, 1) : - 0, - "" - ) - Builtins.y2milestone( - "Changing state from %1 to %2", - option, - startup - ) - IscsiClientLib.setStartupStatus(startup) - raise Break - end - pos = Ops.add(pos, 1) - end - initConnectedTable("") - end - else - Popup.Error(_("No record found.")) - end end end # if nothing selected - disable some buttons, otherwise enable them diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-iscsi-client-3.1.23/src/modules/IscsiClientLib.rb new/yast2-iscsi-client-3.1.25/src/modules/IscsiClientLib.rb --- old/yast2-iscsi-client-3.1.23/src/modules/IscsiClientLib.rb 2015-08-11 15:47:11.000000000 +0200 +++ new/yast2-iscsi-client-3.1.25/src/modules/IscsiClientLib.rb 2016-02-16 11:57:08.000000000 +0100 @@ -190,45 +190,62 @@ deep_copy(hidden) end + # Look for iSCSI boot firmware table (available only on special hardware/netcards) + # + # @return [String] stdout of command 'iscsiadm -m fw' (--mode fw) + # + def getFirmwareInfo + bios_info = SCR.Execute(path(".target.bash_output"), GetAdmCmd("-m fw")) - # get iBFT (available only on some special hardware) + bios_info["stdout"] || "" + end + + # Takes the output of 'iscsiadm' either in 'node', 'session' or 'fw' mode, i.e. + # output where info is seperated by '=', like + # iface.transport_name = tcp + # iface.hwaddress = 42:52:54:00:8b:6a + # iface.bootproto = DHCP + # + # @param [String] stdout (where info is seperated by '=') of iscsiadm command + # @return [Hash] command output converted to hash + # + def nodeInfoToMap (stdout) + retval = {} + return retval if stdout.empty? + + stdout.lines.each do |row| + key, val = row.split("=") + + key = key.to_s.strip + if !key.empty? + retval[key] = val.to_s.strip + end + end + + retval + end + + # Get iBFT (iSCSI boot firmware table) info + # + # @return [Hash] iBFT data converted to a hash (passwords are hidden) + # def getiBFT if @ibft == nil - if !Arch.i386 && !Arch.x86_64 - Builtins.y2milestone( - "Because architecture %1 is is different from x86, not using iBFT", - Arch.arch_short - ) - return {} - end @ibft = {} - Builtins.y2milestone( - "check and modprobe iscsi_ibft : %1", - SCR.Execute( - path(".target.bash_output"), - "lsmod |grep -q iscsi_ibft || modprobe iscsi_ibft" - ) - ) - from_bios = Ops.get_string( - Convert.convert( - SCR.Execute(path(".target.bash_output"), GetAdmCmd("-m fw")), - :from => "any", - :to => "map <string, any>" - ), - "stdout", - "" - ) - Builtins.foreach(Builtins.splitstring(from_bios, "\n")) do |row| - key_val = Builtins.splitstring(row, "=") - # if (size(key_val[0]:"")>0) ibft[key_val[0]:""] = key_val[1]:""; - kv = String.CutBlanks(Ops.get(key_val, 0, "")) - if Ops.greater_than(Builtins.size(kv), 0) - Ops.set(@ibft, kv, String.CutBlanks(Ops.get(key_val, 1, ""))) - end + + if !Arch.i386 && !Arch.x86_64 + log.info "Because architecture #{Arch.arch_short} is different from x86, not using iBFT" + return @ibft end + ret = SCR.Execute(path(".target.bash_output"), + "lsmod |grep -q iscsi_ibft || modprobe iscsi_ibft") + log.info "check and modprobe iscsi_ibft: #{ret}" + + @ibft = nodeInfoToMap(getFirmwareInfo) end - Builtins.y2milestone("iBFT %1", hidePassword(@ibft)) - deep_copy(@ibft) + + log.info "iBFT: #{hidePassword(@ibft)}" + @ibft end @@ -631,7 +648,7 @@ def checkInitiatorName ret = true file = "/etc/iscsi/initiatorname.iscsi" - name_from_bios = Ops.get_string(getiBFT, "iface.initiatorname", "") + name_from_bios = getiBFT["iface.initiatorname"] || "" # if (size((map<string, any>)SCR::Read (.target.lstat, file)) == 0 || ((map<string, any>)SCR::Read (.target.lstat, file))["size"]:0==0){ @initiatorname = Ops.get_string( Convert.convert( @@ -746,44 +763,63 @@ ret end - # get (manual/onboot) status of target connecting + # Get info about current iSCSI node + # + # @return [Hash] stdout of 'iscsiadm -m node -I <iface> -T <target> -p <ip>' + # converted to a hash + def getCurrentNodeValues + ret = SCR.Execute(path(".target.bash_output"), + GetAdmCmd("-m node -I #{@currentRecord[2]||"default"} -T #{@currentRecord[1]||""} -p #{@currentRecord[0]||""}")) + return {} if ret["exit"] != 0 + + nodeInfoToMap(ret["stdout"] || "") + end + + # Check whether iSCSI nodes are equal + # + # @param [Hash] iSCSI node values as hash + # @param [Hash] iSCSI node values as hash + # + # @return [Bool] nodes are equal? + # + def equalNodes?(n1, n2) + return false if n1.empty? + + keys = [ + "iface.transport_name", + "iface.initiatorname", + "node.name", + "node.conn[0].address" + ] + + keys.all? { |key| n1[key] == n2[key] } + end + + # Checks whether iSCSI session (values provided as hash) is iBFT session + # + # @param [Hash] iSCSI node values as hash + # @return [Bool] is iSCSI session booted from firmware? + # + def iBFT?(node_info) + return equalNodes?(getiBFT, node_info) + end + + # Get (manual/onboot/automatic) status of target connection + # + # @return [String] startup status of the iSCSI node + # def getStartupStatus - status = "" - Builtins.y2milestone("Getting status of record %1", @currentRecord) - retcode = Convert.convert( - SCR.Execute( - path(".target.bash_output"), - GetAdmCmd( - Builtins.sformat( - "-m node -I %3 -T %1 -p %2", - Ops.get(@currentRecord, 1, ""), - Ops.get(@currentRecord, 0, ""), - Ops.get(@currentRecord, 2, "default") - ) - ) - ), - :from => "any", - :to => "map <string, any>" - ) - if Ops.greater_than( - Builtins.size(Ops.get_string(retcode, "stderr", "")), - 0 - ) - return "" - end - Builtins.foreach( - Builtins.splitstring(Ops.get_string(retcode, "stdout", ""), "\n") - ) do |row| - if Builtins.issubstring(row, "node.conn[0].startup") - status = Ops.get(Builtins.splitstring(row, " "), 2, "") - raise Break - end + log.info "Getting status of record #{@currentRecord}" + curr_node = getCurrentNodeValues + + if (iBFT?(curr_node)) + # always show status "onboot" for iBFT (startup value from node doesn't matter) + log.info "Startup status for iBFT is always onboot" + return "onboot" end - Builtins.y2milestone( - "Startup status for %1 is %2", - @currentRecord, - status - ) + status = curr_node["node.conn[0].startup"] || "" + log.info "Startup status for #{@currentRecord} is #{status}" + status end @@ -945,8 +981,8 @@ def autoLogOn ret = true - Builtins.y2milestone("begin of autoLogOn function") - if Ops.greater_than(Builtins.size(getiBFT), 0) + log.info "begin of autoLogOn function" + if !getiBFT.empty? result = Convert.to_map(SCR.Execute(path(".target.bash_output"), GetAdmCmd("-m fw -l"))) if result["exit"] != 0 @@ -1305,6 +1341,7 @@ :from => "any", :to => "list <map>" ) + hw_mods = Builtins.maplist(cards) do |c| Builtins.y2milestone("GetOffloadItems card:%1", c) tmp = Builtins.maplist(Ops.get_list(c, "drivers", [])) do |m| @@ -1321,7 +1358,8 @@ } Builtins.y2milestone("GetOffloadItems cinf:%1", r) deep_copy(r) - end + end # maplist(cards) + idx = 0 Builtins.foreach(@offload) do |l| valid = false @@ -1692,6 +1730,8 @@ publish :function => :GetOffloadModules, :type => "list <string> ()" publish :function => :LoadOffloadModules, :type => "list <string> ()" publish :function => :GetDiscoveryCmd, :type => "string (string, string, map)" + publish :function => :getCurrentNodeValues, :type => "map <string, any> ()" + publish :function => :iBFT?, :type => "boolean (map <string, any>)" end IscsiClientLib = IscsiClientLibClass.new diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-iscsi-client-3.1.23/test/Makefile.am new/yast2-iscsi-client-3.1.25/test/Makefile.am --- old/yast2-iscsi-client-3.1.23/test/Makefile.am 2015-08-11 15:47:11.000000000 +0200 +++ new/yast2-iscsi-client-3.1.25/test/Makefile.am 2016-02-16 11:57:08.000000000 +0100 @@ -1,6 +1,8 @@ TESTS = \ ipEqual_spec.rb \ - ScanDiscovered_spec.rb + saveConfig_spec.rb \ + ScanDiscovered_spec.rb \ + getiBFT_spec.rb TEST_EXTENSIONS = .rb RB_LOG_COMPILER = rspec diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-iscsi-client-3.1.23/test/getiBFT_spec.rb new/yast2-iscsi-client-3.1.25/test/getiBFT_spec.rb --- old/yast2-iscsi-client-3.1.23/test/getiBFT_spec.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-iscsi-client-3.1.25/test/getiBFT_spec.rb 2016-02-16 11:57:08.000000000 +0100 @@ -0,0 +1,66 @@ +#!/usr/bin/env rspec +require_relative '../src/modules/IscsiClientLib' + +describe Yast::IscsiClientLibClass do + + before :each do + @iscsilib = Yast::IscsiClientLibClass.new + @iscsilib.main() + end + + describe "#getiBFT" do + context "when filtering output of 'iscsiadm -m fw'" do + it "returns data in form of a map " do + allow(Yast::Arch).to receive(:architecture).and_return("x86_64") + allow(@iscsilib).to receive(:getFirmwareInfo). + and_return("# BEGIN RECORD 2.0-872\n"\ + "iface.bootproto = STATIC\n"\ + "iface.transport_name = tcp\n"\ + "iface.hwaddress = 00:00:c9:b1:bc:7f\n"\ + "iface.initiatorname = iqn.2011-05.com.emulex:eraptorrfshoneport1\n"\ + "iface.ipaddress = 2620:0113:80c0:8000:000c:0000:0000:04dc\n"\ + "node.conn[0].address = 172.0.21.6\n"\ + "node.conn[0].port = 3260\n"\ + "node.name = iqn.1986-03.com.ibm:sn.135061874\n"\ + "# END RECORD\n" + ) + + ibft_data = @iscsilib.getiBFT() + + expect(ibft_data).to eq( + {"# BEGIN RECORD 2.0-872" => "", + "# END RECORD" => "", + "iface.bootproto" => "STATIC", + "iface.hwaddress" => "00:00:c9:b1:bc:7f", + "iface.initiatorname" => "iqn.2011-05.com.emulex:eraptorrfshoneport1", + "iface.transport_name" => "tcp", + "iface.ipaddress" => "2620:0113:80c0:8000:000c:0000:0000:04dc", + "node.conn[0].address" => "172.0.21.6", + "node.conn[0].port" => "3260", + "node.name" => "iqn.1986-03.com.ibm:sn.135061874"}) + end + end + + context "when could not get list of targets from firmware" do + it "returns an empty map " do + allow(Yast::Arch).to receive(:architecture).and_return("x86_64") + allow(@iscsilib).to receive(:getFirmwareInfo).and_return("") + + ibft_data = @iscsilib.getiBFT() + + expect(ibft_data).to eq({}) + end + end + + context "when not on x86 hardware" do + it "returns an empty map " do + allow(Yast::Arch).to receive(:architecture).and_return("s390_64") + + ibft_data = @iscsilib.getiBFT() + + expect(ibft_data).to eq({}) + end + end + + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-iscsi-client-3.1.23/test/saveConfig_spec.rb new/yast2-iscsi-client-3.1.25/test/saveConfig_spec.rb --- old/yast2-iscsi-client-3.1.23/test/saveConfig_spec.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-iscsi-client-3.1.25/test/saveConfig_spec.rb 2016-02-16 11:57:08.000000000 +0100 @@ -0,0 +1,305 @@ +#!/usr/bin/env rspec +require_relative '../src/modules/IscsiClientLib' + +describe Yast::IscsiClientLibClass do + subject do + @iscsilib = Yast::IscsiClientLibClass.new + @iscsilib.main() + @iscsilib + end + + describe "#getConfig,#saveConfig,#oldConfig" do + let(:etc_iscsid_all) { Yast::Path.new ".etc.iscsid.all" } + let(:etc_iscsid) { Yast::Path.new ".etc.iscsid" } + let(:read_data) do + { + "comment" => "", + "file" => -1, + "kind" => "section", + "name" => "", + "type" => -1, + "value" => [ + { + "comment" => "#\n" + + "# Open-iSCSI default configuration.\n" + + "# Could be located at /etc/iscsid.conf or ~/.iscsid.conf\n" + + "#\n", + "kind" => "value", + "name" => "node.active_cnx", + "type" => 1, + "value" => "1" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.startup", + "type" => 1, + "value" => "manual" + }, + { + "comment" => "#node.session.auth.username = dima\n#node.session.auth.password = aloha\n", + "kind" => "value", + "name" => "node.session.timeo.replacement_timeout", + "type" => 1, + "value" => "120" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.session.err_timeo.abort_timeout", + "type" => 1, + "value" => "10" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.session.err_timeo.reset_timeout", + "type" => 1, + "value" => "30" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.session.iscsi.InitialR2T", + "type" => 1, + "value" => "No" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.session.iscsi.ImmediateData", + "type" => 1, + "value" => "Yes" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.session.iscsi.FirstBurstLength", + "type" => 1, + "value" => "262144" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.session.iscsi.MaxBurstLength", + "type" => 1, + "value" => "16776192" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.session.iscsi.DefaultTime2Wait", + "type" => 1, + "value" => "0" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.session.iscsi.DefaultTime2Retain", + "type" => 1, + "value" => "0" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.session.iscsi.MaxConnections", + "type" => 1, + "value" => "0" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.cnx[0].iscsi.HeaderDigest", + "type" => 1, + "value" => "None" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.cnx[0].iscsi.DataDigest", + "type" => 1, + "value" => "None" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.cnx[0].iscsi.MaxRecvDataSegmentLength", + "type" => 1, + "value" => "65536" + } + ] + } + end + + let(:written_data) do + { + "comment" => "", + "file" => -1, + "kind" => "section", + "name" => "", + "type" => -1, + "value" => [ + { + "comment" => "#\n# Open-iSCSI default configuration.\n# Could be located at /etc/iscsid.conf or ~/.iscsid.conf\n#\n", + "kind" => "value", + "name" => "node.active_cnx", + "type" => 1, + "value" => "1" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.startup", + "type" => 1, + "value" => "manual" + }, + { + "comment" => "#node.session.auth.username = dima\n#node.session.auth.password = aloha\n", + "kind" => "value", + "name" => "node.session.timeo.replacement_timeout", + "type" => 1, + "value" => "120" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.session.err_timeo.abort_timeout", + "type" => 1, + "value" => "10" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.session.err_timeo.reset_timeout", + "type" => 1, + "value" => "30" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.session.iscsi.InitialR2T", + "type" => 1, + "value" => "No" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.session.iscsi.ImmediateData", + "type" => 1, + "value" => "Yes" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.session.iscsi.FirstBurstLength", + "type" => 1, + "value" => "262144" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.session.iscsi.MaxBurstLength", + "type" => 1, + "value" => "16776192" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.session.iscsi.DefaultTime2Wait", + "type" => 1, + "value" => "0" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.session.iscsi.DefaultTime2Retain", + "type" => 1, + "value" => "0" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.session.iscsi.MaxConnections", + "type" => 1, + "value" => "0" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.cnx[0].iscsi.HeaderDigest", + "type" => 1, + "value" => "None" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.cnx[0].iscsi.DataDigest", + "type" => 1, + "value" => "None" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.cnx[0].iscsi.MaxRecvDataSegmentLength", + "type" => 1, + "value" => "65536" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.session.auth.username", + "type" => 1, + "value" => "incuser" + }, + { + "comment" => "", + "kind" => "value", + "name" => "node.session.auth.password", + "type" => 1, + "value" => "incpass" + }, + { + "comment" => "", + "kind" => "value", + "name" => "discovery.sendtargets.auth.authmethod", + "type" => 1, + "value" => "CHAP" + }, + { + "comment" => "", + "kind" => "value", + "name" => "discovery.sendtargets.auth.username", + "type" => 1, + "value" => "outuser" + }, + { + "comment" => "", + "kind" => "value", + "name" => "discovery.sendtargets.auth.password", + "type" => 1, + "value" => "outpass" + } + ] + } + end + + it "mimics a legacy test" do + allow(Yast::SCR).to receive(:Read) + .with(etc_iscsid_all).and_return(read_data) + expect(subject.getConfig).to eq(read_data.fetch("value")) + + expect(Yast::SCR).to receive(:Write) + .with(etc_iscsid_all, written_data).and_return(true) + expect(Yast::SCR).to receive(:Write) + .with(etc_iscsid, nil).and_return(true) + expect(subject.saveConfig("incuser", "incpass", "outuser", "outpass")) + .to eq(nil) + + expect(Yast::SCR).to receive(:Write) + .with(etc_iscsid_all, read_data).and_return(true) + expect(Yast::SCR).to receive(:Write) + .with(etc_iscsid, nil).and_return(true) + expect(subject.oldConfig).to eq(nil) + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-iscsi-client-3.1.23/testsuite/Makefile.am new/yast2-iscsi-client-3.1.25/testsuite/Makefile.am --- old/yast2-iscsi-client-3.1.23/testsuite/Makefile.am 2015-08-11 15:47:11.000000000 +0200 +++ new/yast2-iscsi-client-3.1.25/testsuite/Makefile.am 1970-01-01 01:00:00.000000000 +0100 @@ -1,21 +0,0 @@ -# -# Makefile.am for .../testsuite -# -# Do not edit this file (Makefile.am) as it will be overwritten! -# - -AUTOMAKE_OPTIONS = dejagnu -EXTRA_DIST = $(wildcard tests/*.out) $(wildcard tests/*.err) $(wildcard tests/*.rb) - -testsuite_prepare = @ydatadir@/testsuite/Makefile.testsuite - -all-local: $(testsuite_prepare) - make -f $(testsuite_prepare) RPMNAME=$(RPMNAME) srcdir=$(srcdir) - -clean-local: $(testsuite_prepare) - make -f $(testsuite_prepare) RPMNAME=$(RPMNAME) srcdir=$(srcdir) clean - -check-local: $(testsuite_prepare) - make -f $(testsuite_prepare) RPMNAME=$(RPMNAME) srcdir=$(srcdir) check - -# EOF diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-iscsi-client-3.1.23/testsuite/tests/SaveConfig.out new/yast2-iscsi-client-3.1.25/testsuite/tests/SaveConfig.out --- old/yast2-iscsi-client-3.1.23/testsuite/tests/SaveConfig.out 2015-08-11 15:47:11.000000000 +0200 +++ new/yast2-iscsi-client-3.1.25/testsuite/tests/SaveConfig.out 1970-01-01 01:00:00.000000000 +0100 @@ -1,9 +0,0 @@ -Read .target.tmpdir "/tmp" -Read .etc.iscsid.all $["comment":"", "file":-1, "kind":"section", "name":"", "type":-1, "value":[$["comment":"#\n# Open-iSCSI default configuration.\n# Could be located at /etc/iscsid.conf or ~/.iscsid.conf\n#\n", "kind":"value", "name":"node.active_cnx", "type":1, "value":"1"], $["comment":"", "kind":"value", "name":"node.startup", "type":1, "value":"manual"], $["comment":"#node.session.auth.username = dima\n#node.session.auth.password = aloha\n", "kind":"value", "name":"node.session.timeo.replacement_timeout", "type":1, "value":"120"], $["comment":"", "kind":"value", "name":"node.session.err_timeo.abort_timeout", "type":1, "value":"10"], $["comment":"", "kind":"value", "name":"node.session.err_timeo.reset_timeout", "type":1, "value":"30"], $["comment":"", "kind":"value", "name":"node.session.iscsi.InitialR2T", "type":1, "value":"No"], $["comment":"", "kind":"value", "name":"node.session.iscsi.ImmediateData", "type":1, "value":"Yes"], $["comment":"", "kind":"value", "name":"node.session.iscsi.FirstBurstLength", "type":1, "value":"262144"], $["comment":"", "kind":"value", "name":"node.session.iscsi.MaxBurstLength", "type":1, "value":"16776192"], $["comment":"", "kind":"value", "name":"node.session.iscsi.DefaultTime2Wait", "type":1, "value":"0"], $["comment":"", "kind":"value", "name":"node.session.iscsi.DefaultTime2Retain", "type":1, "value":"0"], $["comment":"", "kind":"value", "name":"node.session.iscsi.MaxConnections", "type":1, "value":"0"], $["comment":"", "kind":"value", "name":"node.cnx[0].iscsi.HeaderDigest", "type":1, "value":"None"], $["comment":"", "kind":"value", "name":"node.cnx[0].iscsi.DataDigest", "type":1, "value":"None"], $["comment":"", "kind":"value", "name":"node.cnx[0].iscsi.MaxRecvDataSegmentLength", "type":1, "value":"65536"]]] -Return [$["comment":"#\n# Open-iSCSI default configuration.\n# Could be located at /etc/iscsid.conf or ~/.iscsid.conf\n#\n", "kind":"value", "name":"node.active_cnx", "type":1, "value":"1"], $["comment":"", "kind":"value", "name":"node.startup", "type":1, "value":"manual"], $["comment":"#node.session.auth.username = dima\n#node.session.auth.password = aloha\n", "kind":"value", "name":"node.session.timeo.replacement_timeout", "type":1, "value":"120"], $["comment":"", "kind":"value", "name":"node.session.err_timeo.abort_timeout", "type":1, "value":"10"], $["comment":"", "kind":"value", "name":"node.session.err_timeo.reset_timeout", "type":1, "value":"30"], $["comment":"", "kind":"value", "name":"node.session.iscsi.InitialR2T", "type":1, "value":"No"], $["comment":"", "kind":"value", "name":"node.session.iscsi.ImmediateData", "type":1, "value":"Yes"], $["comment":"", "kind":"value", "name":"node.session.iscsi.FirstBurstLength", "type":1, "value":"262144"], $["comment":"", "kind":"value", "name":"node.session.iscsi.MaxBurstLength", "type":1, "value":"16776192"], $["comment":"", "kind":"value", "name":"node.session.iscsi.DefaultTime2Wait", "type":1, "value":"0"], $["comment":"", "kind":"value", "name":"node.session.iscsi.DefaultTime2Retain", "type":1, "value":"0"], $["comment":"", "kind":"value", "name":"node.session.iscsi.MaxConnections", "type":1, "value":"0"], $["comment":"", "kind":"value", "name":"node.cnx[0].iscsi.HeaderDigest", "type":1, "value":"None"], $["comment":"", "kind":"value", "name":"node.cnx[0].iscsi.DataDigest", "type":1, "value":"None"], $["comment":"", "kind":"value", "name":"node.cnx[0].iscsi.MaxRecvDataSegmentLength", "type":1, "value":"65536"]] -Write .etc.iscsid.all $["comment":"", "file":-1, "kind":"section", "name":"", "type":-1, "value":[$["comment":"#\n# Open-iSCSI default configuration.\n# Could be located at /etc/iscsid.conf or ~/.iscsid.conf\n#\n", "kind":"value", "name":"node.active_cnx", "type":1, "value":"1"], $["comment":"", "kind":"value", "name":"node.startup", "type":1, "value":"manual"], $["comment":"#node.session.auth.username = dima\n#node.session.auth.password = aloha\n", "kind":"value", "name":"node.session.timeo.replacement_timeout", "type":1, "value":"120"], $["comment":"", "kind":"value", "name":"node.session.err_timeo.abort_timeout", "type":1, "value":"10"], $["comment":"", "kind":"value", "name":"node.session.err_timeo.reset_timeout", "type":1, "value":"30"], $["comment":"", "kind":"value", "name":"node.session.iscsi.InitialR2T", "type":1, "value":"No"], $["comment":"", "kind":"value", "name":"node.session.iscsi.ImmediateData", "type":1, "value":"Yes"], $["comment":"", "kind":"value", "name":"node.session.iscsi.FirstBurstLength", "type":1, "value":"262144"], $["comment":"", "kind":"value", "name":"node.session.iscsi.MaxBurstLength", "type":1, "value":"16776192"], $["comment":"", "kind":"value", "name":"node.session.iscsi.DefaultTime2Wait", "type":1, "value":"0"], $["comment":"", "kind":"value", "name":"node.session.iscsi.DefaultTime2Retain", "type":1, "value":"0"], $["comment":"", "kind":"value", "name":"node.session.iscsi.MaxConnections", "type":1, "value":"0"], $["comment":"", "kind":"value", "name":"node.cnx[0].iscsi.HeaderDigest", "type":1, "value":"None"], $["comment":"", "kind":"value", "name":"node.cnx[0].iscsi.DataDigest", "type":1, "value":"None"], $["comment":"", "kind":"value", "name":"node.cnx[0].iscsi.MaxRecvDataSegmentLength", "type":1, "value":"65536"], $["comment":"", "kind":"value", "name":"node.session.auth.username", "type":1, "value":"incuser"], $["comment":"", "kind":"value", "name":"node.session.auth.password", "type":1, "value":"incpass"], $["comment":"", "kind":"value", "name":"discovery.sendtargets.auth.authmethod", "type":1, "value":"CHAP"], $["comment":"", "kind":"value", "name":"discovery.sendtargets.auth.username", "type":1, "value":"outuser"], $["comment":"", "kind":"value", "name":"discovery.sendtargets.auth.password", "type":1, "value":"outpass"]]] true -Write .etc.iscsid nil true -Return nil -Write .etc.iscsid.all $["comment":"", "file":-1, "kind":"section", "name":"", "type":-1, "value":[$["comment":"#\n# Open-iSCSI default configuration.\n# Could be located at /etc/iscsid.conf or ~/.iscsid.conf\n#\n", "kind":"value", "name":"node.active_cnx", "type":1, "value":"1"], $["comment":"", "kind":"value", "name":"node.startup", "type":1, "value":"manual"], $["comment":"#node.session.auth.username = dima\n#node.session.auth.password = aloha\n", "kind":"value", "name":"node.session.timeo.replacement_timeout", "type":1, "value":"120"], $["comment":"", "kind":"value", "name":"node.session.err_timeo.abort_timeout", "type":1, "value":"10"], $["comment":"", "kind":"value", "name":"node.session.err_timeo.reset_timeout", "type":1, "value":"30"], $["comment":"", "kind":"value", "name":"node.session.iscsi.InitialR2T", "type":1, "value":"No"], $["comment":"", "kind":"value", "name":"node.session.iscsi.ImmediateData", "type":1, "value":"Yes"], $["comment":"", "kind":"value", "name":"node.session.iscsi.FirstBurstLength", "type":1, "value":"262144"], $["comment":"", "kind":"value", "name":"node.session.iscsi.MaxBurstLength", "type":1, "value":"16776192"], $["comment":"", "kind":"value", "name":"node.session.iscsi.DefaultTime2Wait", "type":1, "value":"0"], $["comment":"", "kind":"value", "name":"node.session.iscsi.DefaultTime2Retain", "type":1, "value":"0"], $["comment":"", "kind":"value", "name":"node.session.iscsi.MaxConnections", "type":1, "value":"0"], $["comment":"", "kind":"value", "name":"node.cnx[0].iscsi.HeaderDigest", "type":1, "value":"None"], $["comment":"", "kind":"value", "name":"node.cnx[0].iscsi.DataDigest", "type":1, "value":"None"], $["comment":"", "kind":"value", "name":"node.cnx[0].iscsi.MaxRecvDataSegmentLength", "type":1, "value":"65536"]]] true -Write .etc.iscsid nil true -Return nil diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-iscsi-client-3.1.23/testsuite/tests/SaveConfig.rb new/yast2-iscsi-client-3.1.25/testsuite/tests/SaveConfig.rb --- old/yast2-iscsi-client-3.1.23/testsuite/tests/SaveConfig.rb 2015-08-11 15:47:11.000000000 +0200 +++ new/yast2-iscsi-client-3.1.25/testsuite/tests/SaveConfig.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,151 +0,0 @@ -# encoding: utf-8 - -module Yast - class SaveConfigClient < Client - def main - Yast.include self, "testsuite.rb" - - @READ = { - "target" => { "tmpdir" => "/tmp" }, - "etc" => { - "iscsid" => { - "all" => { - "comment" => "", - "file" => -1, - "kind" => "section", - "name" => "", - "type" => -1, - "value" => [ - { - "comment" => "#\n" + - "# Open-iSCSI default configuration.\n" + - "# Could be located at /etc/iscsid.conf or ~/.iscsid.conf\n" + - "#\n", - "kind" => "value", - "name" => "node.active_cnx", - "type" => 1, - "value" => "1" - }, - { - "comment" => "", - "kind" => "value", - "name" => "node.startup", - "type" => 1, - "value" => "manual" - }, - { - "comment" => "#node.session.auth.username = dima\n#node.session.auth.password = aloha\n", - "kind" => "value", - "name" => "node.session.timeo.replacement_timeout", - "type" => 1, - "value" => "120" - }, - { - "comment" => "", - "kind" => "value", - "name" => "node.session.err_timeo.abort_timeout", - "type" => 1, - "value" => "10" - }, - { - "comment" => "", - "kind" => "value", - "name" => "node.session.err_timeo.reset_timeout", - "type" => 1, - "value" => "30" - }, - { - "comment" => "", - "kind" => "value", - "name" => "node.session.iscsi.InitialR2T", - "type" => 1, - "value" => "No" - }, - { - "comment" => "", - "kind" => "value", - "name" => "node.session.iscsi.ImmediateData", - "type" => 1, - "value" => "Yes" - }, - { - "comment" => "", - "kind" => "value", - "name" => "node.session.iscsi.FirstBurstLength", - "type" => 1, - "value" => "262144" - }, - { - "comment" => "", - "kind" => "value", - "name" => "node.session.iscsi.MaxBurstLength", - "type" => 1, - "value" => "16776192" - }, - { - "comment" => "", - "kind" => "value", - "name" => "node.session.iscsi.DefaultTime2Wait", - "type" => 1, - "value" => "0" - }, - { - "comment" => "", - "kind" => "value", - "name" => "node.session.iscsi.DefaultTime2Retain", - "type" => 1, - "value" => "0" - }, - { - "comment" => "", - "kind" => "value", - "name" => "node.session.iscsi.MaxConnections", - "type" => 1, - "value" => "0" - }, - { - "comment" => "", - "kind" => "value", - "name" => "node.cnx[0].iscsi.HeaderDigest", - "type" => 1, - "value" => "None" - }, - { - "comment" => "", - "kind" => "value", - "name" => "node.cnx[0].iscsi.DataDigest", - "type" => 1, - "value" => "None" - }, - { - "comment" => "", - "kind" => "value", - "name" => "node.cnx[0].iscsi.MaxRecvDataSegmentLength", - "type" => 1, - "value" => "65536" - } - ] - } - } - } - } - TESTSUITE_INIT([@READ, {}, {}], nil) - - Yast.import "IscsiClientLib" - - TEST(lambda { IscsiClientLib.getConfig }, [@READ, {}, {}], nil) - TEST(lambda do - IscsiClientLib.saveConfig("incuser", "incpass", "outuser", "outpass") - end, [ - @READ, - {}, - {} - ], nil) - TEST(lambda { IscsiClientLib.oldConfig }, [@READ, {}, {}], nil) - - nil - end - end -end - -Yast::SaveConfigClient.new.main
participants (1)
-
root@hilbert.suse.de