Mailinglist Archive: yast-commit (215 mails)

< Previous Next >
[yast-commit] r67855 - in /branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src: IscsiLioData.ycp IscsiLioServer.ycp dialogs.ycp helps.ycp widgets.ycp
Author: fehr
Date: Tue Apr 3 18:38:53 2012
New Revision: 67855

URL: http://svn.opensuse.org/viewcvs/yast?rev=67855&view=rev
Log:
update for backup

Modified:
branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/IscsiLioData.ycp
branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/IscsiLioServer.ycp
branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/dialogs.ycp
branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/helps.ycp
branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/widgets.ycp

Modified: branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/IscsiLioData.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/IscsiLioData.ycp?rev=67855&r1=67854&r2=67855&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/IscsiLioData.ycp
(original)
+++ branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/IscsiLioData.ycp Tue
Apr 3 18:38:53 2012
@@ -19,7 +19,7 @@

list<string> SplitStringNE( string str, string delim )
{
- return( filter( string s, splitstring(str,delim), ``(size(s)>0)));
+ return( filter( string s, splitstring(str,delim), ``(!isempty(s))));
}

integer MyFind( string s, string pat )
@@ -33,14 +33,14 @@
map<string,any> GetTgt( map<string,any> data, string tgt, integer tpg )
{
map<string,any> m = data["tgt",tgt,tpg]:$[];
- if( size(tgt)==0 )
+ if( isempty(tgt) )
m = data;
return( m );
}

void SetTgt( map<string,any>& data, string tgt, integer tpg, map<string,any> m
)
{
- if( size(tgt)==0 )
+ if( isempty(tgt) )
data = m;
else
data["tgt",tgt] = $[ tpg : m ];
@@ -75,7 +75,7 @@
string ret = ReplaceSlashUs( p );
string base = ret;
integer count = 0;
- while( size(filter( string s, used, ``(s==ret)))>0 )
+ while( !isempty(filter( string s, used, ``(s==ret))) )
{
count = count+1;
ret = base + "_" + count;
@@ -104,7 +104,7 @@
tgt["ep"] = $[ "lun" : $[] ];
list<string> sl = SplitStringNE( val, " \t" );
y2milestone( "AddLun sl:%1", sl );
- if( size(sl[0]:"")>0 && size(sl[1]:"")>0)
+ if( !isempty(sl[0]:"") && !isempty(sl[1]:""))
{
integer l = tointeger( sl[0]:"" );
if( l!=nil && !haskey( tgt["ep","lun"]:$[],l))
@@ -118,12 +118,12 @@
sl = (list<string>)merge( sl, splitstring( s, "=" ));
});
y2milestone( "AddLun sl:%1", sl );
- while( size(sl)>0 )
+ while( !isempty(sl) )
{
if( sl[0]:""=="Path" && size(sl)>1 )
{
string tk = FindTcmKey( sl[1]:"" );
- if( size(tk)>0 )
+ if( !isempty(tk) )
tgt["ep","lun",l,"tcm_key"] = tk;
else
tgt["ep","lun",l,"path"] = sl[1]:"";
@@ -137,7 +137,7 @@
sl = remove( sl, 0 );
}
}
- if( size(tgt["ep","lun",l,"path"]:"")==0 &&
size(tgt["ep","lun",l,"tcm_key"]:"")==0)
+ if( isempty(tgt["ep","lun",l,"path"]:"") &&
isempty(tgt["ep","lun",l,"tcm_key"]:""))
tgt["ep","lun"] = remove( tgt["ep","lun"]:$[], l );
}
return( tgt );
@@ -146,7 +146,7 @@
map<string,any> AddIncoming( map<string,any> tgt, string val )
{
list<string> sl = SplitStringNE( val, " \t" );
- if( size(sl[0]:"")>0 && size(sl[1]:"")>0)
+ if( !isempty(sl[0]:"") && !isempty(sl[1]:""))
tgt["incoming"] = add( tgt["incoming"]:[], [ sl[0]:"", sl[1]:"" ] );
return( tgt );
}
@@ -154,7 +154,7 @@
map<string,any> AddOutgoing( map<string,any> tgt, string val )
{
list<string> sl = SplitStringNE( val, " \t" );
- if( size(sl[0]:"")>0 && size(sl[1]:"")>0)
+ if( !isempty(sl[0]:"") && !isempty(sl[1]:""))
tgt["outgoing"] = [ sl[0]:"", sl[1]:"" ];
return( tgt );
}
@@ -178,7 +178,7 @@
data["tgt",val] = $[ tpg : $[]];
target = val;
}
- else if( name == "LUN" && size(target)>0 )
+ else if( name == "LUN" && !isempty(target) )
data["tgt",target,tpg] = AddLun( data["tgt",target,tpg]:$[], val );
else if( name == "INCOMINGUSER" )
{
@@ -228,7 +228,7 @@
{
map<string,any> m = GetTgt(data,tgt,tpg);
foreach( string s, incom, ``{m=AddIncoming( m, s );});
- if( size(outgo)>0 )
+ if( !isempty(outgo) )
m = AddOutgoing( m, outgo );
SetTgt(data,tgt,tpg,m);
}
@@ -242,15 +242,17 @@
global boolean HasIncomingAuth( string tgt, integer tpg )
{
map m = GetTgt(data,tgt,tpg);
- y2milestone( "HasIncomingAuth m:%1 ret:%2", m["incoming"]:[],
size(m["incoming"]:[])>0 );
- return( size(m["incoming"]:[])>0 );
+ boolean ret = !isempty(m["incoming"]:[]);
+ y2milestone( "HasIncomingAuth m:%1 ret:%2", m["incoming"]:[], ret );
+ return( ret );
}

global boolean HasOutgoingAuth( string tgt, integer tpg )
{
map m = GetTgt(data,tgt,tpg);
- y2milestone( "HasOutgoingAuth m:%1 ret:%2", m["outgoing"]:[],
size(m["outgoing"]:[])>1 );
- return( size(m["outgoing"]:[])>1 );
+ boolean ret = size(m["outgoing"]:[])>1;
+ y2milestone( "HasOutgoingAuth m:%1 ret:%2", m["outgoing"]:[], ret );
+ return( ret );
}

global boolean HasAuth( string tgt, integer tpg )
@@ -289,11 +291,30 @@
return( ret );
}

+global boolean GetTpgAuth( string tgt, integer tpg )
+ {
+ boolean ret = data["tgt",tgt,tpg,"auth"]:true;
+ return( ret );
+ }
+
+global list<string> GetClntList( string tgt, integer tpg )
+ {
+ list<string> ret =
+ maplist( string s, map m, data["tgt",tgt,tpg,"clnt"]:$[], ``(s));
+ return( ret );
+ }
+
+global map<integer,integer> GetClntLun( string tgt, integer tpg, string clnt )
+ {
+ map<integer,integer> ret = data["tgt",tgt,tpg,"clnt",clnt,"lun"]:$[];
+ return( ret );
+ }
+
global boolean SetNetworkPortal( string tgt, integer tpg, string np )
{
y2milestone( "SetNetworkPortal tgt:%1 tpg:%2 np:%3", tgt, tpg, np );
string kt = tgt + " " + tpg + " ";
- if( size(data["tgt",tgt,tpg,"ep","np"]:[])>0 )
+ if( !isempty(data["tgt",tgt,tpg,"ep","np"]:[]) )
LogExecCmd( "lio_node --delnp " + kt +
sformat( "%1:%2", data["tgt",tgt,tpg,"ep","np",0,"ip"]:"",
data["tgt",tgt,tpg,"ep","np",0,"port"]:1
));
@@ -320,7 +341,7 @@
global string GetExportLun( integer l, map m )
{
string p = m["path"]:"";
- if( size(p)==0 )
+ if( isempty(p) )
p = data["tcm",m["tcm_key"]:"","path"]:"";
string ret = tostring(l) + " Path=" + p + ",Type=fileio";
return( ret );
@@ -442,7 +463,7 @@
{
y2milestone( "ParseAuthData tgt:%1 tpg:%2 clnt:%3", tgt, tpg, clnt );
string cmd = "";
- if( size(tgt)>0 )
+ if( !isempty(tgt) )
cmd = "lio_node --showchapauth " + tgt + " " + tpg + " " + clnt;
else
cmd = "lio_node --showchapdiscauth";
@@ -491,7 +512,7 @@
{
string p = SplitStringNE( substring(ls[i]:"",pos), " "
)[1]:"";
string key = hba + "/" + nm;
- if( size(p)>0 )
+ if( !isempty(p) )
tcm[key] = $[ "path" : p, "type" : `fileio ];
y2milestone( "ParseConfigLio hba[%1]:%2", key,
tcm[key]:$[] );
}
@@ -503,7 +524,7 @@
{
string p = SplitStringNE( substring(ls[i]:"",pos), " "
)[2]:"";
string key = hba + "/" + nm;
- if( size(p)>0 )
+ if( !isempty(p) )
tcm[key] = $[ "path" : p, "type" : `iblock ];
y2milestone( "ParseConfigLio hba[%1]:%2", key,
tcm[key]:$[] );
}
@@ -586,9 +607,9 @@
list<string> mutual = [ "", "" ];
list<string> chap = [ "", "" ];
ParseAuthData( "", 0, "", chap, mutual );
- if( size(mutual[0]:"")>0 && size(mutual[1]:"")>0 )
+ if( !isempty(mutual[0]:"") && !isempty(mutual[1]:"") )
ret["outgoing"] = mutual;
- if( size(chap[0]:"")>0 && size(chap[1]:"")>0 )
+ if( !isempty(chap[0]:"") && !isempty(chap[1]:"") )
ret["incoming"] = [ chap ];
foreach( string tgt, map m, endp,
{
@@ -608,11 +629,11 @@
if( search(ls[i]:"", "InitiatorName ACL:" )!=nil )
{
nm = SplitStringNE( ls[i]:"", " " )[3]:"";
- if( size(nm)>0 )
+ if( !isempty(nm) )
tgmap[tgt,tpg,"clnt",nm] = $[];
y2milestone( "ParseConfigLio nm:%1", nm );
}
- if( size(nm)>0 && search(ls[i]:"", "-> lun")!=nil )
+ if( !isempty(nm) && search(ls[i]:"", "-> lun")!=nil )
{
list<string> tls = SplitStringNE( ls[i]:"", " " );
integer ti = tointeger(substring( SplitStringNE(
tls[1]:"", "/" )[0]:"", 4 ));
@@ -634,11 +655,24 @@
mutual = [ "", "" ];
chap = [ "", "" ];
ParseAuthData( tgt, tpg, clnt, chap, mutual );
- if( size(mutual[0]:"")>0 && size(mutual[1]:"")>0 )
+ if( !isempty(mutual[0]:"") && !isempty(mutual[1]:"") )
tgmap[tgt,tpg,"clnt",clnt,"outgoing"] = mutual;
- if( size(chap[0]:"")>0 && size(chap[1]:"")>0 )
+ if( !isempty(chap[0]:"") && !isempty(chap[1]:"") )
tgmap[tgt,tpg,"clnt",clnt,"incoming"] = [ chap ];
});
+ cmd = "lio_node --listtpgattr " + tgt + " " + tpg;
+ out = (map)SCR::Execute(.target.bash_output, cmd );
+ ls = SplitStringNE( out["stdout"]:"", "\n" );
+ i=0;
+ while( i<size(ls) )
+ {
+ if( search(ls[i]:"", "authentication=" )!=nil )
+ {
+ string val = SplitStringNE( ls[i]:"", "=" )[1]:"";
+ tgmap[tgt,tpg,"auth"] = (val=="1");
+ }
+ i=i+1;
+ }
});
});
ret["tgt"] = tgmap;
@@ -667,19 +701,19 @@
ret = bl[1]:false?"iblock_0/":"fileio_0/";
cmd = cmd + ((bl[1]:false)?"--block ":"--fileio ");
}
- if( size(ret)>0 )
+ if( !isempty(ret) )
{
ret = CreateTcmKey( data["tcm"]:$[], ret, p );
cmd = cmd + ret + " " + p;
if( file )
cmd = cmd + " " + bl[2]:1;
}
- if( size(ret)>0 && !LogExecCmd( cmd ) )
+ if( !isempty(ret) && !LogExecCmd( cmd ) )
ret = "";
else
data["tcm",ret] = $[ "path" : p, "type" : file?`fileio:`iblock ];
y2milestone( "CreateTcmDev path:%1 ret:%2", p, ret );
- if( size(ret)>0 )
+ if( !isempty(ret) )
y2milestone( "CreateTcmDev new tcm:%1", data["tcm",ret]:$[] );
return( ret );
}
@@ -706,10 +740,10 @@
else
done = true;
}
- if( !done && ok && size( lm["tcm_key"]:"" )==0 )
+ if( !done && ok && isempty( lm["tcm_key"]:"" ) )
{
string key = CreateTcmDev( lm["path"]:"" );
- if( size(key)==0 )
+ if( isempty(key) )
ok = false;
else
lm["tcm_key"] = key;
@@ -755,7 +789,7 @@
integer lun = lm["lun"]:-1;
boolean ret = !haskey( data["tgt",tgt,tpg,"ep","lun"]:$[], lun );
string tk = FindTcmKey( lm["path"]:"" );
- if( size(tk)>0 )
+ if( !isempty(tk) )
lm["tcm_key"] = tk;
if( !ret )
{
@@ -799,9 +833,9 @@
tgt, tpg, clnt, inc, out );
string cmd = "";
boolean ret = true;
- if( size(tgt)==0 )
+ if( isempty(tgt) )
{
- if( size(inc)>0 )
+ if( !isempty(inc) )
{
cmd = "lio_node --setchapdiscauth ";
ret = LogExecCmd( cmd + inc[0]:"" + " " + inc[1]:"" ) && ret;
@@ -811,7 +845,7 @@
ret = false;
y2error( "SetAuth: impossible to disable discovery auth" );
}
- if( size(out)>0 )
+ if( !isempty(out) )
{
cmd = "lio_node --setchapdiscmutualauth ";
ret = LogExecCmd( cmd + out[0]:"" + " " + out[1]:"" ) && ret;
@@ -825,7 +859,7 @@
else
{
string param = tgt + " " + tpg + " " + clnt;
- if( size(inc)>0 )
+ if( !isempty(inc) )
{
cmd = "lio_node --setchapauth " + param;
ret = LogExecCmd( cmd + inc[0]:"" + " " + inc[1]:"" ) && ret;
@@ -835,7 +869,7 @@
ret = false;
y2error( "SetAuth: impossible to disable auth" );
}
- if( size(out)>0 )
+ if( !isempty(out) )
{
cmd = "lio_node --setchapmutualauth " + param;
ret = LogExecCmd( cmd + out[0]:"" + " " + out[1]:"" ) && ret;
@@ -850,6 +884,19 @@
return( ret );
}

+global boolean SetTpgAuth( string tgt, integer tpg, boolean value )
+ {
+ y2milestone( "SetTpgAuth tgt:%1 tpg:%2 auth:%3", tgt, tpg, value );
+ boolean ret = true;
+ if( value!=GetTgt(data,tgt,tpg)["auth"]:false )
+ {
+ string cmd = "lio_node " + (value?"--enableauth":"--disableauth") + "
" + tgt + " " + tpg;
+ ret = LogExecCmd( cmd );
+ }
+ y2milestone( "SetTpgAuth ret:%1", ret );
+ return( ret );
+ }
+
global void UpdateConfig()
{
data = ParseConfigLio();

Modified:
branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/IscsiLioServer.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/IscsiLioServer.ycp?rev=67855&r1=67854&r2=67855&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/IscsiLioServer.ycp
(original)
+++ branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/IscsiLioServer.ycp
Tue Apr 3 18:38:53 2012
@@ -525,15 +525,6 @@
{
summary = Summary::AddListItem(summary, keys[0]:"");
summary = Summary::AddLine(summary,
getLunDesc(IscsiLioData::GetLun(keys[0]:"",keys[1]:1)));
- if (!IscsiLioData::HasAuth(keys[0]:"",keys[1]:1))
- summary = Summary::AddLine(summary, _("No Authentication"));
- else
- {
- if(IscsiLioData::HasIncomingAuth(keys[0]:"",keys[1]:1))
- summary = Summary::AddLine(summary, _("Incoming
Authentication"));
- if(IscsiLioData::HasOutgoingAuth(keys[0]:"",keys[1]:1))
- summary = Summary::AddLine(summary, _("Outgoing
Authentication"));
- }
});
summary = Summary::CloseList(summary);
}

Modified: branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/dialogs.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/dialogs.ycp?rev=67855&r1=67854&r2=67855&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/dialogs.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/dialogs.ycp Tue Apr
3 18:38:53 2012
@@ -107,6 +107,9 @@
IscsiLioData::GetIpAddr())),
`HWeight(1,`InputField(`id(`port), _("Port number"),
"3260"))
),
+ `VSpacing(0.5),
+ `Left( `HBox( `CheckBox(`id(`auth), _("Use Authentication"),
true) )),
+ `VSpacing(0.5),
`Table(`id(`lun_table),
`header(_("LUN"), _("Name"), _("Path")), []),
`Left(
@@ -120,6 +123,30 @@
`HWeight( 2, `Empty() ))

],
+ "clnt": $[
+ "contents" :
+ `HBox(
+ `HWeight( 2, `Empty() ),
+ `HWeight( 4,
+ `VBox(
+ `HBox(
+ `HWeight(3,`InputField(`id(`target), `opt(`hstretch),
_("Target"), "iqn.2001-04.com.example")),
+ `HWeight(3,`InputField(`id(`identifier), `opt(`hstretch),
_("Identifier"), "test")),
+ `HWeight(1,`InputField(`id(`tpg), _("Portal group"), "1"))
+ ),
+ `Table(`id(`clnt_table),
+ `header(_("Client"), _("Lun Mapping"), _("Auth")),
[]),
+ `Left(
+ `HBox(
+ `PushButton(`id(`add), _("Add")),
+ `PushButton(`id(`edit_lun), _("Edit LUN")),
+ `PushButton(`id(`edit_auth), _("Edit Auth")),
+ `PushButton(`id(`delete), _("Delete")),
+ `PushButton(`id(`copy), _("Copy"))
+ ))
+ )),
+ `HWeight( 2, `Empty() ))
+ ],
"auth": $[
"contents" :
`VBox(
@@ -278,14 +305,14 @@
],

// dialog for add/edit authentication for target
- "target-auth" : $[
+ "target-clnt" : $[
"widget" : `custom,
- "custom_widget" : tabs_descr["auth", "contents"]:nil,
- "init" : initGlobal,
- "handle" : handleAuth,
- "store" : storeGlobal,
+ "custom_widget" : tabs_descr["clnt", "contents"]:nil,
+ "init" : initClient,
+ "handle" : handleClient,
+ "store" : storeClient,
"validate_type" : `function,
- "validate_function" : validateGlobal,
+ "validate_function" : validateClient,
"help" : HELPS["global_config"]:""
],

@@ -365,8 +392,8 @@
// discovery authentication dialog
any AuthDialog(){
current_tab = "targets";
- string caption = _("Modify iSCSI Target");
- list<map <string, any> > w = CWM::CreateWidgets (["target-auth"], (map
<string, map <string, any> >)widgets);
+ string caption = _("Modify iSCSI Target Client Setup");
+ list<map <string, any> > w = CWM::CreateWidgets (["target-clnt"], (map
<string, map <string, any> >)widgets);
term contents =
`VBox(
`VStretch(),
@@ -395,7 +422,7 @@
// edit target dialog
any EditDialog(){
current_tab = "targets";
- string caption = _("Modify iSCSI Target");
+ string caption = _("Modify iSCSI Target Lun Setup");
list<map <string, any> > w = CWM::CreateWidgets (["target-modify"], (map
<string, map <string, any> >)widgets);
term contents =
`VBox(

Modified: branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/helps.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/helps.ycp?rev=67855&r1=67854&r2=67855&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/helps.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/helps.ycp Tue Apr 3
18:38:53 2012
@@ -104,20 +104,32 @@

// target dialog
"server_table" :_(
-"List of offered targets. Create a new target by clicking <b>Add</b>. \n"
+"List of offered targets and target portal groups. Create a new target by
clicking <b>Add</b>. \n"
"To delete or modify an item, select it and press <b>Modify</b> or
<b>Delete</b>."
),

// edit target
- "target-modify": _("<h1>iSCSI Target</h1>") + _("It is possible
to change the <b>Path</b> to block devices, regular files, LVM, or RAID.
-"),
+ "target-modify": _("<h1>iSCSI Target IP/Port and LUN
setup</h1>") + "<p>" +
+_("It is possible to make arbitary block devices or files available under a
lun.
+You have to provide <b>path</b> to either block devices or file.
+The <b>LUN name</b> is an arbitrary name to uniquely identify the <b>LUN</b>.
+The name needs to be unique within the target portal group. If the user
+does not provide a name for LUN, it is generated automatically.") + "</p>"
+"<p>" +
+_("<p>Under <b>Ip Address</b> and <b>Port Number</b> you specify under which
address
+and port the service will be available. Default for port number is 3260.
+Only ip addresses assigned to one of the network cards are possible.") +
"</p>",

// add target
- "target-add": _("<h1>iSCSI Target</h1>") + _(
-"Create a new target. Replace template values with the correct values.\n"
-"For <b>Target</b>, use the format iqn.yyyy-mm.<reversed domain name>.\n"
-"For <b>Path</b>, use block devices, regular files, LVM, or RAID.\n")
-+_("<b>Add</b> one or more LUNs.\nIf you need any extra options, push
<b>Expert Settings</b>."),
+ "target-add": _("<h1>iSCSI Target IP/Port and LUN setup</h1>") +
"<p>" +
+_("Create a new target. Replace template values with the correct values.") +
"</p>" +
+_("It is possible to make arbitary block devices or files available under a
lun.
+You have to provide <b>path</b> to either block devices or file.
+The <b>LUN name</b> is an arbitrary name to uniquely identify the <b>LUN</b>.
+The name needs to be unique within the target portal group. If the user
+does not provide a name for LUN, it is generated automatically.") + "</p>"
+"<p>" +
+_("<p>Under <b>Ip Address</b> and <b>Port Number</b> you specify under which
address
+and port the service will be available. Default for port number is 3260.
+Only ip addresses assigned to one of the network cards are possible.") +
"</p>",


// expert dialog

Modified: branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/widgets.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/widgets.ycp?rev=67855&r1=67854&r2=67855&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/widgets.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/widgets.ycp Tue Apr
3 18:38:53 2012
@@ -14,7 +14,7 @@
boolean CheckLun( integer l, list<term> other, boolean silent )
{
string s = tostring(l);
- boolean ret = size(filter( term i, other, ``(i[1]:""==s)))==0;
+ boolean ret = isempty(filter( term i, other, ``(i[1]:""==s)));
y2milestone( "CheckLun other:%1", other );
y2milestone( "CheckLun l:%1 ret:%2", l, ret );
if( !ret && !silent )
@@ -24,7 +24,7 @@

boolean CheckName( string n, list<term> other )
{
- boolean ret = size(filter( term i, other, ``(i[2]:""==n)))==0;
+ boolean ret = isempty(filter( term i, other, ``(i[2]:""==n)));
if( !ret )
Popup::Error( _("Selected Name is already in use!") );
return( ret );
@@ -35,7 +35,7 @@
boolean ret = IscsiLioData::CheckPath( p )[0]:false;
if( !ret )
Popup::Error( _("Selected Path must be either block device or normal
file!") );
- if( ret && size(filter( term i, other, ``(i[3]:""==p)))>0 )
+ if( ret && !isempty(filter( term i, other, ``(i[3]:""==p))) )
{
Popup::Error( _("Selected Path is already in use!") );
ret = false;
@@ -100,7 +100,7 @@
sym = `again;
if( sym==`ok )
{
- if( size(name)==0 )
+ if( isempty(name) )
{
list<string> used = maplist( term i, other, ``(i[2]:""));
y2milestone( "LUNDetailDialog used:%1", used );
@@ -179,7 +179,7 @@
break;
}
}
- if (size(user)>0 && size(pass)>0) return [user, pass];
+ if (!isempty(user) && !isempty(pass)) return [user, pass];
else return [];
}

@@ -276,7 +276,7 @@
break;
}
}
- boolean empt = size((list)UI::QueryWidget(`server, `Items))==0;
+ boolean empt = isempty((list)UI::QueryWidget(`server, `Items));
UI::ChangeWidget(`edit, `Enabled, !empt);
UI::ChangeWidget(`delete, `Enabled, !empt);
return ret;
@@ -307,7 +307,7 @@
boolean validateiSNS(string key, map event){
string ip = (string)UI::QueryWidget(`isns_ip, `Value);
boolean valid=true;
- if (size(ip)>0) valid = IP::Check(ip);
+ if (!isempty(ip)) valid = IP::Check(ip);
else valid= true;
if (!valid)Popup::Error (_("Invalid IP address."));
return valid;
@@ -331,31 +331,31 @@
string user = "";
string pass = "";
// incoming authentication
- if( size(auth["incoming"]:[])>0 );
+ if( !isempty(auth["incoming"]:[]) );
{
user = auth["incoming",0]:"";
pass = auth["incoming",1]:"";
}
UI::ChangeWidget(`id(`user_in), `Value, user );
UI::ChangeWidget(`id(`pass_in), `Value, pass );
- setAuthIn(size(auth["incoming"]:[])>0);
+ setAuthIn(!isempty(auth["incoming"]:[]));
// outgoing authentication
user = "";
pass = "";
- if( size(auth["outgoing"]:[])>0 );
+ if( !isempty(auth["outgoing"]:[]) );
{
user = auth["outgoing",0]:"";
pass = auth["outgoing",1]:"";
}
UI::ChangeWidget(`id(`user_out), `Value, user );
UI::ChangeWidget(`id(`pass_out), `Value, pass );
- setAuthOut(size(auth["outgoing"]:[])>0);
+ setAuthOut(!isempty(auth["outgoing"]:[]));
}

// initialize discovery authentication or authentication for given target
void initGlobal (string key)
{
- if (size(curr_target)>0)
+ if (!isempty(curr_target))
initGlobalValues(IscsiLioData::GetAuth(curr_target,curr_tpg,""));
else
initGlobalValues(IscsiLioData::GetAuth("",0,""));
@@ -366,7 +366,7 @@
{
y2milestone( "storeGlobal id:%1 map:%2", option_id, option_map );
boolean ret = false;
- if(size(curr_target)>0)
+ if(!isempty(curr_target))
{
ret = IscsiLioData::SetAuth( curr_target, curr_tpg, "",
getIncomingValues(), getOutgoingValues() );
}
@@ -435,9 +435,10 @@
UI::ChangeWidget( `id(`ipaddr), `Enabled, true);
UI::ChangeWidget( `id(`port), `Value, (splitstring(ipp, ":"))[1]:"3260");
UI::ChangeWidget( `id(`port), `Enabled, true);
- list lun = IscsiLioData::GetLunList( curr_target, curr_tpg );
+ UI::ChangeWidget( `id(`auth), `Value,
IscsiLioData::GetTpgAuth(curr_target,curr_tpg));
+ list<list> lun = IscsiLioData::GetLunList( curr_target, curr_tpg );
y2milestone( "initModify lun:%1", lun );
- foreach( list l, IscsiLioData::GetLunList( curr_target, curr_tpg ),
+ foreach( list l, lun,
{
inc_items = add( inc_items, `item(`id(size(inc_items)), l[0]:99,
l[1]:"", l[2]:""));
});
@@ -490,7 +491,7 @@
break;
}
}
- boolean enab = size((list)UI::QueryWidget(`lun_table, `Items))>0;
+ boolean enab = !isempty((list)UI::QueryWidget(`lun_table, `Items));
UI::ChangeWidget(`edit, `Enabled, enab);
UI::ChangeWidget(`delete, `Enabled, enab);
}
@@ -513,7 +514,7 @@
integer port = tointeger(UI::QueryWidget(`port, `Value ));
y2milestone( "storeModify ip:%1 port:%2 ipp:%3", ip, port, ipp );
string np = sformat( "%1:%2", ip, port );
- if( size(ip)>0 && np != ipp )
+ if( !isempty(ip) && np != ipp )
{
chg = true;
if( !IscsiLioData::SetNetworkPortal( curr_target, curr_tpg, np ))
@@ -558,6 +559,17 @@
}
}
});
+ boolean val = (boolean)UI::QueryWidget(`auth, `Value);
+ if( val!=IscsiLioData::GetTpgAuth(curr_target,curr_tpg))
+ {
+ chg = true;
+ if(!IscsiLioData::SetTpgAuth(curr_target,curr_tpg,val))
+ {
+ string txt = sformat( _("Problem setting auth on %1:%2 to %3"),
+ curr_target, curr_tpg, val );
+ Popup::Error( txt );
+ }
+ }
if( chg )
{
IscsiLioData::UpdateConfig();
@@ -575,7 +587,7 @@
string domain = ((map<string, any>)SCR::Execute(.target.bash_output,
"dnsdomainname"))["stdout"]:"";
string uuid = ((map<string, any>)SCR::Execute(.target.bash_output,
"uuidgen"))["stdout"]:"";
uuid = deletechars(uuid, "\n");
- if (size(domain)>0)
+ if (!isempty(domain))
{
domain = (splitstring(domain, "\n"))[0]:"";
list<string> tmp_list=splitstring(domain, ".");
@@ -595,6 +607,7 @@
UI::ChangeWidget(`id(`ipaddr), `Value, s);
UI::ChangeWidget(`id(`port), `ValidChars, String::CDigit());
UI::ChangeWidget(`id(`port), `Value, "3260");
+ UI::ChangeWidget(`id(`auth), `Value, true);
}

list uiTarget()
@@ -622,7 +635,7 @@
list target = uiTarget();
y2milestone( "validateAddTarget %1", target );
boolean ret = true;
- if( size(target[0]:"")==0 )
+ if( isempty(target[0]:"") )
{
Popup::Error(_("The target cannot be empty."));
UI::SetFocus(`id(`target));
@@ -643,4 +656,115 @@
return ret;
}

+void initClient(string key)
+ {
+ y2milestone( "initClient %1 %2", curr_target, curr_tpg );
+ UI::ChangeWidget( `id(`target), `Value, (splitstring(curr_target,
":"))[0]:"");
+ UI::ChangeWidget( `id(`target),`Enabled, false);
+ UI::ChangeWidget( `id(`identifier), `Value, (splitstring(curr_target,
":"))[1]:"");
+ UI::ChangeWidget( `id(`identifier), `Enabled, false);
+ UI::ChangeWidget( `id(`tpg), `Value, tostring(curr_tpg) );
+ UI::ChangeWidget( `id(`tpg), `Enabled, false);
+ list<string> clnt = IscsiLioData::GetClntList( curr_target, curr_tpg );
+ y2milestone( "initClient clnt:%1", clnt );
+ list <term> inc_items = [];
+ string auth = _("Disabled");
+ boolean tgt_auth = IscsiLioData::GetTpgAuth( curr_target, curr_tpg );
+ foreach( string s, clnt,
+ {
+ if( tgt_auth )
+ {
+ map m = IscsiLioData::GetAuth( curr_target, curr_tpg, s );
+ auth = "";
+ if( !isempty(m["incoming"]:[]) )
+ auth = _("Incoming");
+ if( !isempty(m["outgoing"]:[]) )
+ {
+ if(!isempty(auth))
+ auth = auth + "/";
+ auth = auth + _("Outgoing");
+ }
+ if( isempty(auth) )
+ auth = _("None");
+ }
+ string lun = "";
+ map<integer,integer> lmap = IscsiLioData::GetClntLun( curr_target,
curr_tpg, s );
+ foreach( integer l1, integer l2, lmap,
+ {
+ if(!isempty(lun))
+ lun = lun + "-";
+ lun = lun + sformat("%1:%2",l1,l2);
+ });
+ inc_items = add( inc_items, `item(`id(size(inc_items)), s, lun, auth));
+ });
+ UI::ChangeWidget(`id(`clnt_table), `Items, inc_items);
+ }
+
+symbol handleClient(string key, map event)
+ {
+ if( event["EventReason"]:"" == "Activated" )
+ {
+ switch((symbol)event["WidgetID"]:nil)
+ {
+ case `delete:
+ any del = UI::QueryWidget(`id (`clnt_table),`CurrentItem);
+ if (del != nil)
+ {
+ if(Popup::ContinueCancel(_("Really delete the selected
item?")))
+ {
+ y2milestone("handleClient Delete Client %1 from
table", del);
+ list it=(list)UI::QueryWidget(`clnt_table, `Items);
+ it = remove( it, (integer)del );
+ UI::ChangeWidget(`id(`clnt_table), `Items, it);
+ }
+ else
+ y2milestone("handleClient: Delete canceled");
+ }
+ break;
+ case `edit:
+ list<term> items = (list<term>)UI::QueryWidget(`clnt_table,
`Items);
+ integer edit_pos=tointeger(UI::QueryWidget(`clnt_table,
`CurrentItem));
+ y2milestone( "handleClient pos:%1 items:%2", edit_pos, items );
+ term ret = LUNDetailDialog( edit_pos, items );
+ y2milestone( "handleClient ret:%1 em:%2 eq:%3", ret, `Empty(),
ret!=`Empty() );
+ if( ret!=`Empty() )
+ {
+ items[edit_pos]=ret;
+ UI::ChangeWidget(`clnt_table, `Items, items);
+ UI::ChangeWidget(`clnt_table, `CurrentItem, edit_pos);
+ }
+ break;
+ case `add:
+ items = (list<term>)UI::QueryWidget(`clnt_table, `Items);
+ ret = LUNDetailDialog( -1, items );
+ if( ret!=`Empty() )
+ {
+ items = (list<term>)add( items, ret );
+ UI::ChangeWidget(`clnt_table, `Items, items);
+ UI::ChangeWidget(`clnt_table, `CurrentItem, size(items)-1);
+ }
+ break;
+ }
+ }
+ boolean enab = !isempty((list)UI::QueryWidget(`clnt_table, `Items));
+ UI::ChangeWidget(`edit_lun, `Enabled, enab);
+ UI::ChangeWidget(`edit_auth, `Enabled, enab);
+ UI::ChangeWidget(`delete, `Enabled, enab);
+ UI::ChangeWidget(`copy, `Enabled, enab);
+ }
+
+boolean validateClient(string key, map event)
+ {
+ boolean ret = true;
+ return( ret );
+ }
+
+void storeClient(string option_id, map option_map)
+ {
+ list target = uiTarget();
+ y2milestone( "storeAddTarget %1", target );
+ curr_target = sformat( "%1:%2", target[0]:"", target[1]:"" );
+ curr_tpg = target[2]:-1;
+ }
+
}

--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages