[yast-commit] r63979 - in /branches/SuSE-Code-11-SP2-Branch/iscsi-client: ./ agents/ doc/ doc/autodocs/ package/ src/ testsuite/
Author: fehr Date: Thu May 12 16:20:20 2011 New Revision: 63979 URL: http://svn.opensuse.org/viewcvs/yast?rev=63979&view=rev Log: - implement support for iSCSI offload cards (fate#311711) - 2.17.24 Modified: branches/SuSE-Code-11-SP2-Branch/iscsi-client/ (props changed) branches/SuSE-Code-11-SP2-Branch/iscsi-client/.cvsignore branches/SuSE-Code-11-SP2-Branch/iscsi-client/VERSION branches/SuSE-Code-11-SP2-Branch/iscsi-client/agents/ (props changed) branches/SuSE-Code-11-SP2-Branch/iscsi-client/doc/ (props changed) branches/SuSE-Code-11-SP2-Branch/iscsi-client/doc/autodocs/ (props changed) branches/SuSE-Code-11-SP2-Branch/iscsi-client/package/ (props changed) branches/SuSE-Code-11-SP2-Branch/iscsi-client/package/yast2-iscsi-client.changes branches/SuSE-Code-11-SP2-Branch/iscsi-client/src/ (props changed) branches/SuSE-Code-11-SP2-Branch/iscsi-client/src/IscsiClient.ycp branches/SuSE-Code-11-SP2-Branch/iscsi-client/src/IscsiClientLib.ycp branches/SuSE-Code-11-SP2-Branch/iscsi-client/src/dialogs.ycp branches/SuSE-Code-11-SP2-Branch/iscsi-client/src/widgets.ycp branches/SuSE-Code-11-SP2-Branch/iscsi-client/testsuite/ (props changed) Modified: branches/SuSE-Code-11-SP2-Branch/iscsi-client/.cvsignore URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/iscsi-... ============================================================================== --- branches/SuSE-Code-11-SP2-Branch/iscsi-client/.cvsignore (original) +++ branches/SuSE-Code-11-SP2-Branch/iscsi-client/.cvsignore Thu May 12 16:20:20 2011 @@ -18,3 +18,4 @@ stamp-h iscsi-client.pot autom4te.cache +*.ami Modified: branches/SuSE-Code-11-SP2-Branch/iscsi-client/VERSION URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/iscsi-... ============================================================================== --- branches/SuSE-Code-11-SP2-Branch/iscsi-client/VERSION (original) +++ branches/SuSE-Code-11-SP2-Branch/iscsi-client/VERSION Thu May 12 16:20:20 2011 @@ -1 +1 @@ -2.17.23 +2.17.24 Modified: branches/SuSE-Code-11-SP2-Branch/iscsi-client/package/yast2-iscsi-client.changes URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/iscsi-... ============================================================================== --- branches/SuSE-Code-11-SP2-Branch/iscsi-client/package/yast2-iscsi-client.changes (original) +++ branches/SuSE-Code-11-SP2-Branch/iscsi-client/package/yast2-iscsi-client.changes Thu May 12 16:20:20 2011 @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Thu May 12 14:20:50 CEST 2011 - fehr@suse.de + +- implement support for iSCSI offload cards (fate#311711) +- 2.17.24 + +------------------------------------------------------------------- Tue Mar 1 16:24:05 CET 2011 - jsrain@suse.cz - assure required packages are installed via AutoYaST (bnc#670863) Modified: branches/SuSE-Code-11-SP2-Branch/iscsi-client/src/IscsiClient.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/iscsi-... ============================================================================== --- branches/SuSE-Code-11-SP2-Branch/iscsi-client/src/IscsiClient.ycp (original) +++ branches/SuSE-Code-11-SP2-Branch/iscsi-client/src/IscsiClient.ycp Thu May 12 16:20:20 2011 @@ -106,13 +106,16 @@ global map Export () { list tgets = []; foreach(string sess, IscsiClientLib::sessions, { - string target = splitstring(sess, " ")[1]:""; - string portal = splitstring(sess, " ")[0]:""; - IscsiClientLib::currentRecord = [portal, target]; + list<string> sl = splitstring(sess, " "); + string target = sl[1]:""; + string portal = sl[0]:""; + string iface = sl[2]:"default"; + IscsiClientLib::currentRecord = [portal, target, iface]; map<string, any> auth = IscsiClientLib::getNode(); map new_target = $["target": target, "portal" : portal, + "iface" : iface, "startup" : IscsiClientLib::getStartupStatus(), ]; if (auth["authmethod"]:"None"=="None") new_target["authmethod"]="None"; Modified: branches/SuSE-Code-11-SP2-Branch/iscsi-client/src/IscsiClientLib.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/iscsi-... ============================================================================== --- branches/SuSE-Code-11-SP2-Branch/iscsi-client/src/IscsiClientLib.ycp (original) +++ branches/SuSE-Code-11-SP2-Branch/iscsi-client/src/IscsiClientLib.ycp Thu May 12 16:20:20 2011 @@ -15,6 +15,8 @@ global list <string> discovered = []; global list <string> targets = []; global list<string> currentRecord = []; +map<string,string> iface_file = $[]; +list<string> iface_eth = []; // status of rcopen-iscsi service boolean serviceStatus = false; @@ -26,8 +28,34 @@ global string initiatorname = ""; // map used for autoYaST global map ay_settings=nil; +// interface type for hardware offloading +string offload_card = "default"; +void CallConfigScript(); +global string GetOffloadCard() + { + return( offload_card ); + } + +global void SetOffloadCard( string new_card ) + { + y2milestone( "SetOffloadCard:%1 cur:%2", new_card, offload_card ); + if( new_card != offload_card ) + { + offload_card = new_card; + if( new_card != "default" ) + CallConfigScript(); + } + } + +global string GetAdmCmd( string params ) + { + string ret = "iscsiadm"; + ret = ret + " " + params; + y2milestone( "GetAdmCmd:%1", ret ); + return( ret ); + } global map<string, any> hidePassword(map<string, any> orig){ map<string, any> hidden=$[]; @@ -50,7 +78,7 @@ } ibft=$[]; y2milestone("check and modprobe iscsi_ibft : %1", SCR::Execute(.target.bash_output, "lsmod |grep -q iscsi_ibft || modprobe iscsi_ibft")); - string from_bios = ((map<string, any>)SCR::Execute(.target.bash_output, "iscsiadm -m fw"))["stdout"]:""; + string from_bios = ((map<string, any>)SCR::Execute(.target.bash_output, GetAdmCmd("-m fw")))["stdout"]:""; foreach(string row, splitstring(from_bios, "\n"), { list<string> key_val=splitstring(row, "="); // if (size(key_val[0]:"")>0) ibft[key_val[0]:""] = key_val[1]:""; @@ -59,7 +87,6 @@ }); } y2milestone("iBFT %1", hidePassword(ibft)); - y2milestone("Autologin into iBFT : %1", SCR::Execute(.target.bash_output, "iscsiadm -m fw -l")); return ibft; } @@ -119,13 +146,14 @@ global map<string, any> getNode(){ - map<string, any> cmd = (map<string, any>)SCR::Execute(.target.bash_output, "iscsiadm -S -m node -T $TARGET -p $IP", $["TARGET":currentRecord[1]:"", "IP":currentRecord[0]:""]); - if (cmd["exit"]:0!=0) return $[]; - map<string, any> auth = $[]; - foreach(string row, splitstring(cmd["stdout"]:"", "\n"), { - string key = splitstring(row," = ")[0]:""; - string val = splitstring(row," = ")[3]:""; - if(val == "<empty>") val=""; + string cmdline = GetAdmCmd(sformat( "-S -m node -I %3 -T %1 -p %2", currentRecord[1]:"", currentRecord[0]:"", currentRecord[2]:"default" )); + map<string, any> cmd = (map<string, any>)SCR::Execute(.target.bash_output, cmdline); + if (cmd["exit"]:0!=0) return $[]; + map<string, any> auth = $[]; + foreach(string row, splitstring(cmd["stdout"]:"", "\n"), { + string key = splitstring(row," = ")[0]:""; + string val = splitstring(row," = ")[3]:""; + if(val == "<empty>") val=""; switch(key){ case("node.session.auth.authmethod"): auth["authmethod"]=val; @@ -217,29 +245,54 @@ SCR::Write(.etc.iscsid, nil); } -// get all discovered targets -global list<string> getDiscovered(){ - discovered=[]; - map<string, any> retcode = (map<string, any>)SCR::Execute(.target.bash_output, "iscsiadm -m node"); - if (size(retcode["stderr"]:"")==0) { - list<string> tmp_disc = filter(string row, splitstring(retcode["stdout"]:"", "\n"), { - return ( size(row)>0 && (search(row, "session")==nil) ); - }); - foreach(string row, tmp_disc, { - list<string> tmp_row = splitstring(row, " "); - discovered = add(discovered, sformat("%1 %2", tmp_row[0]:"", tmp_row[1]:"")); +global list<string> ScanDiscovered( list<string> data ) + { + list<string> ret = []; + string target = ""; + string portal = ""; + string iface = ""; + foreach( string row, data, + { + row = deletechars(row,"\t"); + if( search(row,"Target:")!=nil ) + target = splitstring(row, " ")[1]:""; + else if( search(row,"Portal:")!=nil ) + { + if( search(row,"Current Portal:")!=nil ) + portal = splitstring(row, " ")[2]:""; + else if( search(row,"Persistent Portal:")==nil ) + portal = splitstring(row, " ")[1]:""; + } + else if( search(row,"Iface Name:")!=nil ) + { + iface = splitstring(row, " ")[2]:""; + iface = iface_file[iface]:iface; + if( findfirstof( portal, "[]" )==nil ) + ret = add(ret, portal + " " + target + " " + iface); + } }); + y2milestone( "ScanDiscovered ret:%1", ret ); + return( ret ); + } + +// get all discovered targets +global list<string> getDiscovered() + { + discovered=[]; + map<string, any> retcode = (map<string, any>)SCR::Execute(.target.bash_output, GetAdmCmd("-m node -P 1")); + if (size(retcode["stderr"]:"")==0) + { + discovered = ScanDiscovered( splitstring(retcode["stdout"]:"","\n") ); } - y2milestone("Discovered sessions %1", discovered); - return discovered; -} + return discovered; + } global void startIScsid(){ SCR::Execute(.target.bash, "pgrep iscsid || iscsid"); foreach(integer i,[0,1,2,3,4,5,6,7,8,9],{ sleep(1*1000); - map<string, any> cmd=(map<string, any>)SCR::Execute(.target.bash_output, "iscsiadm -m session"); + map<string, any> cmd=(map<string, any>)SCR::Execute(.target.bash_output, GetAdmCmd("-m session")); y2internal("iteration %1, retcode %2",i, cmd["exit"]:-1); if (cmd["exit"]:-1==0){ y2internal("Good response from daemon, exit."); @@ -250,21 +303,11 @@ // get all connected targets global boolean readSessions(){ - y2milestone("reading current settings"); - map<string, any> retcode = (map<string, any>)SCR::Execute(.target.bash_output, "iscsiadm -m session"); -// if ( retcode["exit"]:0 != 0 ) return false; - list<string> tmp_sessions = []; - tmp_sessions = filter(string row, splitstring(retcode["stdout"]:"", "\n"), { - return ( size(row)>0 && (search(row, "session")==nil) ); - }); - sessions=[]; - foreach(string row, tmp_sessions, { - list<string> tmp_row = splitstring(row, " "); - sessions = add(sessions, sformat("%1 %2", tmp_row[2]:"", tmp_row[3]:"")); - }); - + y2milestone("reading current settings"); + map<string, any> retcode = (map<string, any>)SCR::Execute(.target.bash_output, GetAdmCmd("-m session -P 1")); + sessions = ScanDiscovered( splitstring(retcode["stdout"]:"", "\n") ); y2milestone("Return list from iscsiadm -m session: %1", sessions); - return true; + return true; } /** @@ -347,7 +390,9 @@ boolean ret = true; y2milestone("Delete record %1", currentRecord); - map<string, any> retcode = (map<string, any>)SCR::Execute(.target.bash_output, sformat("iscsiadm -m node -T %1 -p %2 --logout", currentRecord[1]:"", currentRecord[0]:"")); + map<string, any> retcode = (map<string, any>)SCR::Execute(.target.bash_output, GetAdmCmd(sformat("-m node -I %3 -T %1 -p %2 --logout", + currentRecord[1]:"", currentRecord[0]:"", + currentRecord[2]:"default"))); if (size(retcode["stderr"]:"")>0) return false; readSessions(); @@ -358,7 +403,9 @@ global string getStartupStatus(){ string status = ""; y2milestone("Getting status of record %1", currentRecord); - map<string, any> retcode = (map<string, any>)SCR::Execute(.target.bash_output, sformat("iscsiadm -m node -T %1 -p %2", currentRecord[1]:"", currentRecord[0]:"")); + map<string, any> retcode = (map<string, any>)SCR::Execute(.target.bash_output, GetAdmCmd(sformat("-m node -I %3 -T %1 -p %2", + currentRecord[1]:"", currentRecord[0]:"", + currentRecord[2]:"default"))); if (size(retcode["stderr"]:"")>0) return ""; foreach(string row, splitstring(retcode["stdout"]:"", "\n"), { if (issubstring(row, "node.conn[0].startup")){ @@ -373,8 +420,9 @@ // update authentication value global boolean setValue(string name, string value){ y2milestone("set %1 for record %2", name, currentRecord); - string command = sformat("iscsiadm -m node -T %1 -p %2 --op=update --name=%3 --value=%4", currentRecord[1]:"", currentRecord[0]:"", name, value); - y2milestone("execute command - %1", command ); + string command = GetAdmCmd(sformat("-m node -I %3 -T %1 -p %2 --op=update --name=%4 --value=%5", + currentRecord[1]:"", currentRecord[0]:"", currentRecord[2]:"default", + name, value)); boolean ret = true; map<string, any> retcode = (map<string, any>) SCR::Execute(.target.bash_output, command); if (size(retcode["stderr"]:"")>0) { @@ -392,7 +440,8 @@ boolean ret = false; foreach(string row, sessions, { list<string> list_row = splitstring(row, " "); - if (list_row[1]:"" == currentRecord[1]:"" && (check_ip ? splitstring(list_row[0]:"", ",")[0]:"" == splitstring(currentRecord[0]:"", ",")[0]:"" : true)){ + if (list_row[1]:"" == currentRecord[1]:"" && list_row[2]:"" == currentRecord[2]:"" && + (check_ip ? splitstring(list_row[0]:"", ",")[0]:"" == splitstring(currentRecord[0]:"", ",")[0]:"" : true)){ ret = true; break; } @@ -405,10 +454,12 @@ y2milestone("Set startup status for %1 to %2", currentRecord, status); boolean ret = true; map<string, any> retcode = (map<string, any>) SCR::Execute(.target.bash_output, - sformat("iscsiadm -m node -T %1 -p %2 --op=update --name=node.conn[0].startup --value=%3", currentRecord[1]:"", currentRecord[0]:"", status)); + GetAdmCmd(sformat("-m node -I%3 -T %1 -p %2 --op=update --name=node.conn[0].startup --value=%4", + currentRecord[1]:"", currentRecord[0]:"", currentRecord[2]:"default", status))); if (size(retcode["stderr"]:"")>0) return false; else retcode = (map<string, any>) SCR::Execute(.target.bash_output, - sformat("iscsiadm -m node -T %1 -p %2 --op=update --name=node.startup --value=%3", currentRecord[1]:"", currentRecord[0]:"", status)); + GetAdmCmd(sformat("-m node -I %3 -T %1 -p %2 --op=update --name=node.startup --value=%4", + currentRecord[1]:"", currentRecord[0]:"", currentRecord[2]:"default", status))); y2internal("retcode %1", retcode); return ret; @@ -417,14 +468,14 @@ global boolean autoLogOn(){ y2milestone("begin of autoLogOn function"); if (size(getiBFT())>0){ - y2milestone("Autologin into iBFT : %1", SCR::Execute(.target.bash_output, "iscsiadm -m fw -l")); + y2milestone("Autologin into iBFT : %1", SCR::Execute(.target.bash_output, GetAdmCmd("-m fw -l"))); } return true; } global boolean loginIntoTarget(map target){ - currentRecord = [target["portal"]:"", target["target"]:""]; + currentRecord = [target["portal"]:"", target["target"]:"",target["iface"]:""]; if (target["authmethod"]:"None"!="None"){ string user_in = target["username_in"]:""; string pass_in = target["password_in"]:""; @@ -449,7 +500,8 @@ } else setValue("node.session.auth.authmethod", "None"); map<string, any> output = (map<string, any>)SCR::Execute(.target.bash_output, - sformat("iscsiadm -m node -T %1 -p %2 --login", target["target"]:"", target["portal"]:"")); + GetAdmCmd(sformat("-m node -I %3 -T %1 -p %2 --login", + target["target"]:"", target["portal"]:"", target["iface"]:""))); y2internal("output %1", output); // if (output["exit"]:-1==0){ // set startup status to auto by default (bnc#400610) @@ -512,20 +564,243 @@ global boolean autoyastWrite(){ // do discovery first list<string> portals = []; +list<string> ifaces = []; +string ifacepar = ""; +foreach(map target, ay_settings["targets"]:[], { + if (!contains(ifaces, target["iface"]:"")){ + ifacepar = ifacepar + "-I " + target["iface"]:""; + ifaces = add(ifaces, target["iface"]:""); + } +}); foreach(map target, ay_settings["targets"]:[], { if (!contains(portals, target["portal"]:"")){ - SCR::Execute(.target.bash, sformat("iscsiadm -m discovery -t st -p %1", target["portal"]:"")); + SCR::Execute(.target.bash, GetAdmCmd(sformat("-m discovery %1 -t st -p %2", ifacepar, target["portal"]:""))); portals = add(portals, target["portal"]:""); } }); foreach(map target, ay_settings["targets"]:[], { y2internal("login into target %1", target); loginIntoTarget(target); - currentRecord = [target["portal"]:"", target["target"]:""]; + currentRecord = [target["portal"]:"", target["target"]:"", target["iface"]:""]; setStartupStatus(target["startup"]:"manual"); }); return true; } +global string Overview(){ + string overview = _("Configuration summary..."); + if (size(ay_settings)>0){ + overview=""; + if (size(ay_settings["initiatorname"]:"")>0) overview = overview + "<p><b>Initiatorname: </b>" + ay_settings["initiatorname"]:"" + "</p>"; + if (size(ay_settings["targets"]:[])>0){ + foreach(map target, (list<map>)ay_settings["targets"]:[], { + overview = overview + "<p>" + target["portal"]:"" + ", " + target["target"]:"" + ", " + target["iface"]:"" + ", " + target["startup"]:"" + "</p>"; + }); + } + } + return overview; +} + +string InitOffloadCard() + { + string ret = "default"; + map<string, any> retcode = (map<string, any>)SCR::Execute(.target.bash_output, GetAdmCmd("-m node -P 1")); + list<string> ifaces = []; + if (size(retcode["stderr"]:"")==0) + { + foreach( string s, ScanDiscovered( splitstring(retcode["stdout"]:"","\n") ), + { + list<string> sl = splitstring( s, " " ); + if( size(sl[2]:"")>0 && !contains( ifaces, sl[2]:"" )) + { + ifaces = add( ifaces, sl[2]:"" ); + } + }); + } + y2milestone( "InitOffloadCard ifaces:%1", ifaces ); + if( size(ifaces)>1 ) + ret = "all"; + else if( contains( iface_eth, ifaces[0]:"" )) + ret = ifaces[0]:"default"; + y2milestone( "InitOffloadCard ret:%1", ret ); + return( ret ); + } + +list<list<any> > offload = [ + [ "default", "default"+" "+_("(Software)"), [] ], + [ "all", "all", [] ], + [ "bnx2", "bnx2/bnx2i/bnx2x", [ "bnx2", "bnx2i", "bnx2x" ] ], + [ "cxgb3", "cxgb3/cxgb3i", [ "cxgb3", "cxgb3i" ] ], + [ "enic", "enic/cnic/fnic", [ "enic", "cnic", "fnic" ] ], + [ "qla4xxx", "qla4xxx", [ "qla4xxx" ] ], + [ "be2net", "be2net/be2iscsi", [ "be2net", "be2iscsi" ] ] + ]; + +map<integer,list> offload_valid = nil; + +void InitIfaceFile() + { + iface_file = $[]; + list<string> files = (list<string>)SCR::Read(.target.dir, "/etc/iscsi/ifaces"); + y2milestone( "files:%1", files ); + foreach( string file, files, + { + list<string> ls = splitstring( (string)SCR::Read(.target.string, "/etc/iscsi/ifaces/"+file), "\n" ); + y2milestone( "file:%1", file ); + y2milestone( "ls:%1", ls ); + ls = filter( string l, ls, ``(search(l,"iface.iscsi_ifacename")!=nil)); + y2milestone( "ls:%1", ls ); + if( size(ls)>0 ) + iface_file[splitstring(deletechars(ls[0]:""," "),"=")[1]:""] = file; + }); + y2milestone( "iface_file:%1", iface_file ); + } + +global list<term> GetOffloadItems() + { + integer i=0; + boolean init = false; + if( offload_valid==nil ) + { + init = true; + InitIfaceFile(); + offload_valid = $[]; + list<map> cards = (list<map>)SCR::Read(.probe.netcard); + list<map> hw_mods = maplist( map c, cards, + { + y2milestone( "GetOffloadItems card:%1", c ); + list<list> tmp = maplist( map m, c["drivers"]:[], + ``(flatten((list<list>)m["modules"]:[]))); + return( $["modules": [ c["driver_module"]:"" ], + "iface":c["dev_name"]:"", + "macaddr":c["resource","hwaddr",0,"addr"]:""]); + }); + y2milestone( "GetOffloadItems hw_mods:%1", hw_mods ); + integer idx = 0; + foreach( list<any> l, offload, + ``{ + boolean valid = false; + list<string> mod = (list<string>)sort(l[2]:[]); + if( size(mod)>0 ) + { + i=0; + foreach( map hw, hw_mods, + ``{ + //if( size(multiset::intersection(mod,(list<string>)sort(hw["modules"]:[])))>0 ) + if( size(mod)+size(hw["modules"]:[])>size(union(mod,hw["modules"]:[]))) + offload_valid[idx] = add( offload_valid[idx]:[], + [ hw["iface"]:"", hw["macaddr"]:""] ); + }); + } + idx = idx+1; + }); + foreach( integer i, list eth, offload_valid, + { + offload_valid[i] = maplist( list l, (list<list>)eth, + { + map out = (map) SCR::Execute (.target.bash_output, "ifconfig " + l[0]:"" ); + y2milestone( "GetOffloadItems out:%1", out ); + string line = filter( string ln, splitstring( out["stdout"]:"", "\n" ), + ``(search(ln,"inet addr:")!=nil))[0]:""; + y2milestone( "GetOffloadItems line:%1", line ); + line = substring( line, search( line, "inet addr:")+10 ); + y2milestone( "GetOffloadItems line:%1", line ); + l = add( l, substring( line, 0, findfirstof( line, " \t" )) ); + return( l ); + }); + }); + y2milestone( "GetOffloadItems offload_valid:%1", offload_valid ); + } + map<string,string> entries = $[]; + foreach( integer i, list eth, offload_valid, + { + foreach( list l, (list<list>)eth, + { + if( size(l[0]:"")>0 ) + { + string s = l[0]:""; + if( size(l[1]:"" )>0 ) + s = s + " - " + l[1]:""; + s = s + " - " + offload[i,1]:""; + entries[l[0]:""] = s; + } + }); + }); + y2milestone( "GetOffloadItems entries:%1", entries ); + iface_eth = sort(maplist( string e, string val, entries, ``(e))); + y2milestone( "GetOffloadItems eth:%1", iface_eth ); + if( init ) + { + offload_card = InitOffloadCard(); + y2milestone( "GetOffloadItems offload_card:%1", offload_card ); + } + list<term> ret = [ `item( `id(offload[0,0]:""), offload[0,1]:"", offload_card==offload[0,0]:"" )]; + if( size(offload_valid)>0 ) + ret = add( ret, `item( `id(offload[1,0]:""), offload[1,1]:"", offload_card==offload[1,0]:"" ) ); + ret = (list<term>)merge( ret, maplist( string e, iface_eth, + ``(`item( `id(e), entries[e]:"", + offload_card==e )))); + y2milestone( "GetOffloadItems ret:%1", ret ); + return( ret ); + } + +list<string> GetDiscIfaces() + { + list<string> ret = []; + if( GetOffloadCard()=="all" ) + { + list<string> tl = maplist( term t, GetOffloadItems(), ``(argsof(t)[0,0]:"")); + y2milestone( "GetDiscIfaces:%1", tl ); + ret = filter( string s, tl, ``(s!="all")); + } + else + ret = [ GetOffloadCard() ]; + y2milestone( "GetDiscIfaces:%1", ret ); + return( ret ); + } + +void CallConfigScript() + { + list<string> sl = filter( string s, GetDiscIfaces(), ``(s!="default")); + y2milestone( "CallConfigScript list:%1", sl ); + foreach( string s, sl, + { + string cmd = "/sbin/iscsi-offload-config " + " "; + list hw = []; + hw = maplist( integer i, list e, + filter( integer i, list eth, offload_valid, ``(contains(flatten((list<list>)eth),s))), + ``(e))[0]:[]; + y2milestone( "CallConfigScript hw:%1", hw ); + hw = find( list l, (list<list>)hw, ``(l[0]:""==s)); + y2milestone( "CallConfigScript hw:%1", hw ); + if( hw != nil ) + { + cmd = cmd + hw[1]:"" + " " + hw[2]:"" + " " + s; + y2milestone( "CallConfigScript cmd:%1", cmd ); + map output = (map)SCR::Execute(.target.bash_output, cmd ); + y2milestone( "CallConfigScript %1", output ); + } + }); + } + +global string GetDiscoveryCmd( string ip, string port) + { + y2milestone( "GetDiscoveryCmd ip:%1 port:%2", ip, port); + string command = "-m discovery -P 1"; + if( useISNS() ) + command = command + " -t isns"; + else + { + list<string> ifs = GetDiscIfaces(); + y2milestone( "ifs=%1", ifs ); + ifs = maplist( string s, ifs, ``("-I "+s)); + y2milestone( "ifs=%1", ifs ); + command = command + sformat( " -t st %3 -p %1:%2", ip, port, mergestring(ifs," ")); + } + command = GetAdmCmd(command); + y2milestone( "GetDiscoveryCmd %1", command ); + return( command ); + } + } Modified: branches/SuSE-Code-11-SP2-Branch/iscsi-client/src/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/iscsi-... ============================================================================== --- branches/SuSE-Code-11-SP2-Branch/iscsi-client/src/dialogs.ycp (original) +++ branches/SuSE-Code-11-SP2-Branch/iscsi-client/src/dialogs.ycp Thu May 12 16:20:20 2011 @@ -61,12 +61,19 @@ "widget" : `custom, "custom_widget" : `HBox( - `MinWidth( 16, `TextEntry(`id(`initiator_name), _("Initiator Name")) ) + `MinWidth( 16, + `HBox( + `TextEntry(`id(`initiator_name), _("Initiator Name")), + `MinWidth( 8, + `ComboBox(`id(`offload_card), `opt(`notify), + _("Offloa&d Card"), + IscsiClientLib::GetOffloadItems() )))) ), "init" : initInitName, "validate_type" : `function, "validate_function" : validateInitName, "store" : storeInitName, + "handle" : handleOffload, "help" : HELPS["initiator_name"]:"" ], // table of connected targets @@ -75,7 +82,7 @@ "custom_widget" : `VBox( `Table(`id(`connected), `opt(`notify, `immediate ), - `header(_("Portal Address"), _("Target Name"), _("Start-Up")), + `header(_("Interface"),_("Portal Address"), _("Target Name"), _("Start-Up")), [] ), `Left(`HBox( @@ -96,7 +103,7 @@ "custom_widget" : `VBox( `Table(`id(`discovered), `opt(`notify, `immediate ), - `header(_("Portal Address"), _("Target Name"), _("Connected")), + `header(_("Interface"),_("Portal Address"), _("Target Name"), _("Connected")), [] ), `Left(`HBox( @@ -313,7 +320,9 @@ string help = CWM::MergeHelps(w); contents = CWM::PrepareDialog(contents, w); Wizard::SetContentsButtons(caption, contents, help, Label::BackButton (), Mode::installation() ? Label::NextButton() : Label::FinishButton ()); - Wizard::DisableBackButton(); + Wizard::SetNextButton(`next, Label::OKButton()); + Wizard::SetAbortButton(`abort, Label::CancelButton()); + Wizard::HideBackButton(); symbol ret = CWM::Run(w, $[`abort:ReallyAbort ]); return ret; } Modified: branches/SuSE-Code-11-SP2-Branch/iscsi-client/src/widgets.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/iscsi-... ============================================================================== --- branches/SuSE-Code-11-SP2-Branch/iscsi-client/src/widgets.ycp (original) +++ branches/SuSE-Code-11-SP2-Branch/iscsi-client/src/widgets.ycp Thu May 12 16:20:20 2011 @@ -97,7 +97,8 @@ integer row = 0; foreach(string s, IscsiClientLib::sessions, { IscsiClientLib::currentRecord = splitstring(s, " "); - items = add(items, `item(`id(row), IscsiClientLib::currentRecord[0]:"", IscsiClientLib::currentRecord[1]:"", IscsiClientLib::getStartupStatus())); + items = add(items, `item(`id(row), IscsiClientLib::currentRecord[2]:"", IscsiClientLib::currentRecord[0]:"", + IscsiClientLib::currentRecord[1]:"", IscsiClientLib::getStartupStatus())); row = row + 1; }); UI::ChangeWidget (`id (`connected), `Items, items); @@ -244,6 +245,8 @@ void initInitName(string key){ y2milestone("initiatorname %1", IscsiClientLib::initiatorname); UI::ChangeWidget(`initiator_name, `Value, IscsiClientLib::initiatorname); + UI::ChangeWidget(`offload_card, `Value, IscsiClientLib::GetOffloadCard()); + y2milestone("OffloadCard %1", IscsiClientLib::GetOffloadCard()); if (size(IscsiClientLib::getiBFT()["iSCSI_INITIATOR_NAME"]:"")>0){ UI::ChangeWidget(`initiator_name, `Enabled, false); UI::ChangeWidget(`write, `Enabled, false); @@ -295,8 +298,26 @@ else SCR::Execute(.target.bash, "rcopen-iscsi restart"); y2milestone("write initiatorname %1", IscsiClientLib::initiatorname); } + if ((string)UI::QueryWidget(`offload_card, `Value) != IscsiClientLib::GetOffloadCard()){ + IscsiClientLib::SetOffloadCard((string)UI::QueryWidget(`offload_card, `Value)); + y2milestone("OffloadCard %1", IscsiClientLib::GetOffloadCard()); + } return nil; } + +symbol handleOffload (string key, map event) + { + if( event["EventReason"]:""=="ValueChanged" && event["ID"]:`none==`offload_card ) + { + if( (string)UI::QueryWidget(`offload_card, `Value) != IscsiClientLib::GetOffloadCard()) + { + IscsiClientLib::SetOffloadCard((string)UI::QueryWidget(`offload_card, `Value)); + y2milestone("handleOffload OffloadCard %1", IscsiClientLib::GetOffloadCard()); + } + } + return nil; + } + // ***************** iBFT table ************************** void initiBFT(string key){ list<term> items = []; @@ -347,6 +368,8 @@ UI::ChangeWidget(`id(`pass_out),`Value, auth["password"]:"" ); // if ((size(auth["username"]:"")>0)&&(size(auth["password"]:"")>0)) setAuthOut(true); } + string startup=IscsiClientLib::getStartupStatus(); + if(size(startup)>0) UI::ChangeWidget(`id("startup"), `Value, startup); } // handle for enable/disable widgets in authentication dialog symbol handleDiscAuth(string key, map event){ @@ -448,13 +471,9 @@ //y2internal("auth: %1/%2, %3/%4", user_in, pass_in, user_out, pass_out); bg_finish=false; // ` with authentication - string command = IscsiClientLib::useISNS()? "iscsiadm -m discovery -t isns" : sformat("iscsiadm -m discovery -t st -p %1:%2", ip, port); + string command = IscsiClientLib::GetDiscoveryCmd(ip,port); list<string>trg_list = runInBg( command ); - IscsiClientLib::targets = []; -foreach(string row, trg_list, { - list<string> tmp_list=splitstring(row, " "); - if (issubstring(tmp_list[0]:"", sformat("%1:%2",ip,port))) IscsiClientLib::targets=add(IscsiClientLib::targets, sformat("%1 %2", tmp_list[0]:"", tmp_list[1]:"")); -}); + IscsiClientLib::targets = IscsiClientLib::ScanDiscovered( trg_list ); while(!bg_finish){}; // restore old config IscsiClientLib::oldConfig(); @@ -471,7 +490,7 @@ any selected = UI::QueryWidget(`discovered, `CurrentItem); if (selected != nil) { params = splitstring( IscsiClientLib::discovered[tointeger(selected)]:"", " " ); } else { params = []; } - IscsiClientLib::currentRecord = [ splitstring(params[0]:"", ",")[0]:"", params[1]:""]; + IscsiClientLib::currentRecord = [ splitstring(params[0]:"", ",")[0]:"", params[1]:"", params[2]:""]; if ((params==[])||(IscsiClientLib::connected( true ))){ UI::ChangeWidget (`id (`connect), `Enabled, false); UI::ChangeWidget (`id (`delete), `Enabled, false); @@ -486,13 +505,14 @@ list <term> items = []; integer row = 0; foreach(string s, IscsiClientLib::getDiscovered(), { - IscsiClientLib::currentRecord = splitstring(s, " "); -// string record = deletechars(row_in_string[0]:"", "[]"); - items = add(items, `item(`id(row), IscsiClientLib::currentRecord[0]:"", IscsiClientLib::currentRecord[1]:"", + IscsiClientLib::currentRecord = splitstring(s, " "); +// string record = deletechars(row_in_string[0]:"", "[]"); + items = add(items, `item(`id(row), IscsiClientLib::currentRecord[2]:"", + IscsiClientLib::currentRecord[0]:"", + IscsiClientLib::currentRecord[1]:"", (IscsiClientLib::connected( true ))?_("True"):_("False") )); - row = row + 1; - }); - + row = row + 1; + }); UI::ChangeWidget (`id (`discovered), `Items, items); UI::SetFocus (`id (`discovered)); setDiscoveredButtons(); @@ -504,7 +524,7 @@ any selected = UI::QueryWidget(`discovered, `CurrentItem); if (selected != nil) { params = splitstring( IscsiClientLib::discovered[tointeger(selected)]:"", " " ); } else { params = []; } - IscsiClientLib::currentRecord = [ splitstring(params[0]:"", ",")[0]:"", params[1]:"" ] ; + IscsiClientLib::currentRecord = [ splitstring(params[0]:"", ",")[0]:"", params[1]:"", params[2]:"default" ] ; if ( event["EventReason"]:"" == "Activated" ){ // connect new target if ( event["ID"]:nil == `connect) { @@ -523,8 +543,9 @@ // delete connected item if ( event["ID"]:nil == `delete) { if ((params == [])||(!IscsiClientLib::connected( true ))){ - string cmd = sformat("iscsiadm -m node -T %1 -p %2 --op=delete", params[1]:"", params[0]:""); - y2milestone("%1 : %2", cmd, SCR::Execute (.target.bash_output,cmd, $[] )); + string cmd = IscsiClientLib::GetAdmCmd(sformat("-m node -T %1 -p %2 -I %3 --op=delete", + params[1]:"", params[0]:"", params[2]:"")); + y2milestone("%1", SCR::Execute (.target.bash_output,cmd, $[] )); IscsiClientLib::readSessions(); initDiscoveredTable(""); if (selected != nil) { params = splitstring( IscsiClientLib::discovered[tointeger(selected)]:"", " " ); } @@ -544,7 +565,7 @@ integer row = 0; foreach(string s, IscsiClientLib::targets, { IscsiClientLib::currentRecord = splitstring(s, " "); - items = add(items, `item(`id(row), IscsiClientLib::currentRecord[0]:"", IscsiClientLib::currentRecord[1]:"", + items = add(items, `item(`id(row), IscsiClientLib::currentRecord[2]:"", IscsiClientLib::currentRecord[0]:"", IscsiClientLib::currentRecord[1]:"", (IscsiClientLib::connected( true ))?_("True"):_("False") )); row = row + 1; }); @@ -593,6 +614,7 @@ map<string, any> target=$[ "target" : IscsiClientLib::currentRecord[1]:"", "portal" : IscsiClientLib::currentRecord[0]:"", + "iface" : IscsiClientLib::currentRecord[2]:"default", "authmethod" : (auth_none)?"None":"CHAP", "username" : user_out, "password" : pass_out, @@ -600,10 +622,10 @@ "password_in" : pass_in ]; if (IscsiClientLib::connected(true) || IscsiClientLib::loginIntoTarget(target)) { -// IscsiClientLib::currentRecord = [target["portal"]:"", target["target"]:""]; +// IscsiClientLib::currentRecord = [target["portal"]:"", target["target"]:"", target["iface"]:"default"]; IscsiClientLib::setStartupStatus((string)UI::QueryWidget(`id("startup"), `Value)); - IscsiClientLib::readSessions(); - return true; + IscsiClientLib::readSessions(); + return true; } else return false; } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
fehr@svn2.opensuse.org