Mailinglist Archive: yast-commit (275 mails)

< Previous Next >
[yast-commit] r67733 - in /branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src: IscsiLioData.ycp IscsiLioServer.ycp widgets.ycp
Author: fehr
Date: Wed Mar 28 19:39:55 2012
New Revision: 67733

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

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/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=67733&r1=67732&r2=67733&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 Wed
Mar 28 19:39:55 2012
@@ -78,7 +78,7 @@
while( size(filter( string s, used, ``(s==ret)))>0 )
{
count = count+1;
- ret = base + "_" + tostring(count);
+ ret = base + "_" + count;
}
y2milestone( "CreateLunName p:%1 ret:%2", p, ret );
return( ret );
@@ -92,7 +92,7 @@
while( haskey( tcm, ret ))
{
count = count+1;
- ret = base + "_" + tostring(count);
+ ret = base + "_" + count;
}
y2milestone( "CreateTcmKey base:%1 p:%2 ret:%3", base, p, ret );
return( ret );
@@ -233,6 +233,12 @@
SetTgt(data,tgt,tpg,m);
}

+global boolean HasTarget( string tgt, integer tpg )
+ {
+ return( haskey( data["tgt"]:$[], tgt ) &&
+ haskey( data["tgt",tgt]:$[], tpg ));
+ }
+
global boolean HasIncomingAuth( string tgt, integer tpg )
{
map m = GetTgt(data,tgt,tpg);
@@ -276,6 +282,18 @@
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 )
+ 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
));
+ boolean ret = LogExecCmd( "lio_node --addnp " + kt + np );
+ return( ret );
+ }
+
global list<list> GetTargets()
{
list<list> ret = [];
@@ -418,8 +436,7 @@
y2milestone( "ParseAuthData tgt:%1 tpg:%2 clnt:%3", tgt, tpg, clnt );
string cmd = "";
if( size(tgt)>0 )
- cmd = "lio_node --showchapauth " + tgt + " " + tostring(tpg) +
- " " + clnt;
+ cmd = "lio_node --showchapauth " + tgt + " " + tpg + " " + clnt;
else
cmd = "lio_node --showchapdiscauth";
map out = (map)SCR::Execute(.target.bash_output, cmd );
@@ -574,7 +591,7 @@
tgmap[tgt,tpg] = $[ "ep" : endp[tgt,tpg]:$[],
"clnt" : $[] ];
y2milestone( "ParseConfigLio tgt:%1 tpg:%2", tgt, tpg );
- string cmd = "lio_node --listlunacls " + tgt + " " + tostring(tpg);
+ string cmd = "lio_node --listlunacls " + tgt + " " + tpg;
out = (map)SCR::Execute(.target.bash_output, cmd );
ls = SplitStringNE( out["stdout"]:"", "\n" );
i=0;
@@ -648,7 +665,7 @@
ret = CreateTcmKey( data["tcm"]:$[], ret, p );
cmd = cmd + ret + " " + p;
if( file )
- cmd = cmd + " " + tostring(bl[2]:1);
+ cmd = cmd + " " + bl[2]:1;
}
if( size(ret)>0 && !LogExecCmd( cmd ) )
ret = "";
@@ -660,17 +677,25 @@
return( ret );
}

+global boolean DoRemoveLun( string tgt, integer tpg, integer l )
+ {
+ string kt = tgt + " " + tpg + " " + l;
+ boolean ret = LogExecCmd( "lio_node --dellun " + kt );
+ y2milestone( "DoRemoveLun tgt:%1 tpg:%2 l:%3 ret:%4", tgt, tpg, l, ret );
+ return( ret );
+ }
+
boolean ActivateLun( string tgt, integer tpg, integer lun, map lm )
{
y2milestone( "ActivateLun tgt:%1 tpg:%2 lun:%3", tgt, tpg, lun );
- string kt = tgt + " " + tostring(tpg) + " " + tostring(lun);
+ string kt = tgt + " " + tpg + " " + lun;
boolean ok = true;
boolean done = false;
if( haskey( data["tgt",tgt,tpg,"ep","lun"]:$[], lun ) )
{
if( data["tgt",tgt,tpg,"ep","lun",lun,"tcm_key"]:"" !=
lm["tcm_key"]:"" ||
data["tgt",tgt,tpg,"ep","lun",lun,"nm"]:"" != lm["nm"]:"" )
- ok = LogExecCmd( "lio_node --dellun " + kt );
+ ok = DoRemoveLun( tgt, tpg, lun );
else
done = true;
}
@@ -689,6 +714,12 @@
return( ok );
}

+global boolean EnableTpg( string tgt, integer tpg )
+ {
+ boolean ret = LogExecCmd( "lio_node --enabletpg " + tgt + " " + tpg );
+ return( ret );
+ }
+
global boolean ActivateConfigIetd( map dat )
{
string cmd = "";
@@ -698,13 +729,13 @@
{
foreach( integer tpg, map d, m,
{
- string kt = key + " " + tostring(tpg);
+ string kt = key + " " + tpg;
foreach( integer l, map lun, d["ep","lun"]:$[],
{
ok = ActivateLun( key, tpg, l, lun ) && ok;
});
if( !IsTpgActive( key, tpg ))
- ok = LogExecCmd( "lio_node --enabletpg " + kt ) && ok;
+ ok = EnableTpg( key, tpg ) && ok;
});
});
y2milestone( "ActivateConfigIetd ok:%1", ok );
@@ -737,6 +768,24 @@
return( ret );
}

+global boolean AddTarget( string tgt, integer tpg )
+ {
+ boolean ret = LogExecCmd( "lio_node --addtpg " + tgt + " " + tpg );
+ if( ret )
+ ret = EnableTpg( tgt, tpg );
+ y2milestone( "AddTarget tgt:%1 tpg:%2 ret:%3", tgt, tpg, ret );
+ return( ret );
+ }
+
+global boolean DelTarget( string tgt, integer tpg )
+ {
+ boolean ret = LogExecCmd( "lio_node --deltpg " + tgt + " " + tpg );
+ if( ret && size( data["tgt",tgt]:$[] )<=1 )
+ ret = LogExecCmd( "lio_node --deliqn " + tgt );
+ y2milestone( "DelTarget tgt:%1 tpg:%2 ret:%3", tgt, tpg, 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=67733&r1=67732&r2=67733&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
Wed Mar 28 19:39:55 2012
@@ -184,16 +184,6 @@
// get changes from perl module
map<string, any> changes = IscsiLioData::GetChanges();
list<string> connected = IscsiLioData::GetConnected();
- // plus add there all targets except with active sessions (it means
delete and create as new each target)
-/*
- foreach(string key,any value, IscsiServerFunctions::getTargets(), {
- if ((!contains(connected, key))&&(!contains(changes["add"]:[],
key))&&(!contains(changes["del"]:[], key))){
- changes["del"] = add (changes["del"]:[], key);
- changes["add"] = add (changes["add"]:[], key);
- y2milestone("modified key %1", key);
- }
- });
-*/
// delete targets
foreach(string row, changes["del"]:[], {
if (!contains(connected, row)){

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=67733&r1=67732&r2=67733&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 Wed Mar
28 19:39:55 2012
@@ -243,14 +243,25 @@
ret = `add;
break;
case(`delete):
- // add a new item
- if (Popup::ContinueCancel(_("Really delete this item?")))
+ // remove a item
+ any del = UI::QueryWidget(`id(`server),`CurrentItem);
+ y2milestone("handleTable del:%1",del);
+ if (del != nil)
{
- integer del=tointeger( UI::QueryWidget(`id(`server),
`CurrentItem) );
- string target = ((term)UI::QueryWidget(`id(`server),
`Item(del)))[1]:"";
- IscsiServerFunctions::setDelChanges( target );
- IscsiServerFunctions::removeTarget(
((term)UI::QueryWidget(`id(`server), `Item(del)))[1]:"" );
- initTable("");
+ if(Popup::ContinueCancel(_("Really delete the selected
item?")))
+ {
+ list it=(list)UI::QueryWidget(`id(`server), `Items);
+ term i = it[(integer)del]:`Empty();
+ y2milestone("handleTable item:%1",i);
+ if( IscsiLioData::DelTarget( i[1]:"",
tointeger(i[2]:"-1") ))
+ {
+ it = remove( it, (integer)del );
+ UI::ChangeWidget(`id(`server), `Items, it);
+ IscsiLioData::UpdateConfig();
+ }
+ }
+ else
+ y2milestone("handleTable Delete canceled");
}
break;
case(`edit):
@@ -373,87 +384,6 @@
else Popup::Error(_("Cannot use the same secret for incoming and
outgoing authentication."));
return ret;
}
-// ************** Add Target Dialog ******************
-// initialize function for create new target
-void initAddTarget(string key){
-// some proposed values
- string target = "iqn";
- string date = ((map<string, any>)SCR::Execute(.target.bash_output, "date
+%Y-%m"))["stdout"]:"";
- 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){
- domain = (splitstring(domain, "\n"))[0]:"";
- list<string> tmp_list=splitstring(domain, ".");
- domain = sformat("%1.%2", tmp_list[1]:"", tmp_list[0]:"");
- } else domain="com.example";
- target = deletechars(sformat("%1.%2.%3", target, date, domain), "\n");
- y2milestone("init values for add_target %1", target);
- UI::ChangeWidget(`id(`target), `Value, target);
- UI::ChangeWidget(`id(`identifier), `Value, uuid);
- UI::ChangeWidget(`id(`tpg), `ValidChars, String::CDigit());
- UI::ChangeWidget(`id(`tpg), `Value, "1");
- list<term> ip = (list<term>)UI::QueryWidget(`id(`ipaddr), `Items);
- string s =ip[0,1]:"";
- y2milestone("initAddTarget ip:%1", s );
- UI::ChangeWidget(`id(`ipaddr), `Value, s);
- UI::ChangeWidget(`id(`port), `ValidChars, String::CDigit());
- UI::ChangeWidget(`id(`port), `Value, "3260");
-}
-
-/*
-symbol handleAddTarget (string table, map event){
- symbol ret = nil;
- if(event["EventReason"]:"" == "Activated"){
- switch((symbol)event["ID"]:nil){
- case(`add) : y2internal("add");
- return `lun_add;
- case(`edit) : y2internal("edit");
- break;
- case(`delete) : y2internal("delete");
- break;
- case(`expert) : y2internal("expert");
- return `expert;
-
- }
- }
-}
-*/
-
-// save values
-void storeAddTarget(string option_id, map option_map){
- list<map<string, any> > old = [];
- string target = tostring( sformat("%1:%2",UI::QueryWidget(`id(`target),
`Value), UI::QueryWidget(`id(`identifier), `Value)) );
-// string lun = sformat("%1 Path=%2,Type=fileio",UI::QueryWidget(`id(`lun),
`Value), UI::QueryWidget(`id(`path), `Value) );
-// add/modify that values
- list<map<string, any> > items = [];
- foreach(term row, (list<term>)UI::QueryWidget(`lun_table, `Items), {
- items = add(items, $["KEY":row[1]:"", "VALUE":row[2]:""]);
- });
- y2milestone("Add target %1", target);
- IscsiServerFunctions::addNewTarget(target, items);
- curr_target = target;
-}
-
-// validate function checks if target/lun are unique and not empty
-boolean validateAddTarget(string key, map event){
- string target = tostring( UI::QueryWidget(`id(`target), `Value) );
-// string lun = tostring( UI::QueryWidget(`id(`lun), `Value) );
- string type = "no";
- if (( size(target)==0 && (Popup::Error(_("The target cannot be
empty."))==nil) ) ||
- ( IscsiServerFunctions::ifExists("Target", target) &&
(Popup::Error(_("The target already exists."))==nil) )){
- UI::SetFocus(`id(`target));
- return false;
- }
-/*
- if ((size(lun)==0 && (Popup::Error(_("The logical unit definition cannot be
empty."))==nil))||
- ( IscsiServerFunctions::ifExists("Lun", lun) && (Popup::Error(_("The
logical unit already exists."))==nil))){
- UI::SetFocus(`id(`lun));
- return false;
- }
-*/
- return true;
-}

// **************** Target Auth *******************
// handle authentication dialog
@@ -587,17 +517,9 @@
if(Popup::ContinueCancel(_("Really delete the selected
item?")))
{
y2milestone("Delete LUN %1 from table", del);
- list items=[];
- integer count=0;
- foreach(term row,
(list<term>)UI::QueryWidget(`lun_table, `Items),
- {
- if (count!=del)
- {
- items=add(items,
`item(`id(size(items)),row[1]:"", row[2]:""));
- }
- count = count + 1;
- });
- UI::ChangeWidget(`id(`lun_table), `Items, items);
+ list it=(list)UI::QueryWidget(`lun_table, `Items);
+ it = remove( it, (integer)del );
+ UI::ChangeWidget(`id(`lun_table), `Items, it);
}
else
y2milestone("Delete canceled");
@@ -636,7 +558,50 @@
void storeModify(string option_id, map option_map)
{
boolean chg = false;
- foreach(term row, (list<term>)UI::QueryWidget(`lun_table, `Items),
+ if( !IscsiLioData::HasTarget( curr_target, curr_tpg ) )
+ {
+ chg = true;
+ if( !IscsiLioData::AddTarget( curr_target, curr_tpg ))
+ {
+ string txt = sformat( _("Problem creating target %1 with tpg %2"),
+ curr_target, curr_tpg );
+ Popup::Error( txt );
+ }
+ }
+ string ipp = IscsiLioData::GetNetworkPortal( curr_target, curr_tpg )[0]:"";
+ string ip = (string)UI::QueryWidget(`ipaddr, `Value );
+ 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 )
+ {
+ chg = true;
+ if( !IscsiLioData::SetNetworkPortal( curr_target, curr_tpg, np ))
+ {
+ string txt = sformat( _("Problem setting network portal to %1"),
np );
+ Popup::Error( txt );
+ }
+ }
+ list<term> it = (list<term>)UI::QueryWidget(`lun_table, `Items);
+ list<integer> nll = maplist( term t, it, ``(tointeger(t[1]:"-1")));
+ list<integer> oll = maplist( list lli,
+ IscsiLioData::GetLunList( curr_target,
curr_tpg ),
+ ``(lli[0]:-1));
+ y2milestone( "storeModify oll:%1", oll );
+ y2milestone( "storeModify nll:%1", nll );
+ foreach( integer l, oll,
+ {
+ if( !contains( nll, l ))
+ {
+ chg = true;
+ if( !IscsiLioData::DoRemoveLun( curr_target, curr_tpg, l ))
+ {
+ string txt = sformat( _("Problem removing lun %1"), l );
+ Popup::Error( txt );
+ }
+ }
+ });
+ foreach(term row, it,
{
map lun = $[ "lun" : tointeger(row[1]:"-1"),
"nm" : row[2]:"",
@@ -647,7 +612,7 @@
chg = true;
if( !IscsiLioData::DoUpdateLun( curr_target, curr_tpg, lun ))
{
- string txt = sformat( _("Problem seting lun %1 (name:%2) to
path %3"),
+ string txt = sformat( _("Problem setting lun %1 (name:%2) to
path %3"),
lun["lun"]:-1, lun["nm"]:"",
lun["path"]:"" );
Popup::Error( txt );
}
@@ -660,4 +625,82 @@
}
}

+// ************** Add Target Dialog ******************
+// initialize function for create new target
+void initAddTarget(string key)
+ {
+ // some proposed values
+ string target = "iqn";
+ string date = ((map<string, any>)SCR::Execute(.target.bash_output, "date
+%Y-%m"))["stdout"]:"";
+ 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)
+ {
+ domain = (splitstring(domain, "\n"))[0]:"";
+ list<string> tmp_list=splitstring(domain, ".");
+ domain = sformat("%1.%2", tmp_list[1]:"", tmp_list[0]:"");
+ }
+ else
+ domain="com.example";
+ target = deletechars(sformat("%1.%2.%3", target, date, domain), "\n");
+ y2milestone("init values for add_target %1", target);
+ UI::ChangeWidget(`id(`target), `Value, target);
+ UI::ChangeWidget(`id(`identifier), `Value, uuid);
+ UI::ChangeWidget(`id(`tpg), `ValidChars, String::CDigit());
+ UI::ChangeWidget(`id(`tpg), `Value, "1");
+ list<term> ip = (list<term>)UI::QueryWidget(`id(`ipaddr), `Items);
+ string s =ip[0,1]:"";
+ y2milestone("initAddTarget ip:%1", s );
+ UI::ChangeWidget(`id(`ipaddr), `Value, s);
+ UI::ChangeWidget(`id(`port), `ValidChars, String::CDigit());
+ UI::ChangeWidget(`id(`port), `Value, "3260");
+ }
+
+list uiTarget()
+ {
+ integer tpg = nil;
+ tpg = tointeger(UI::QueryWidget(`id(`tpg),`Value));
+ return( [ (string)UI::QueryWidget(`id(`target), `Value),
+ (string)UI::QueryWidget(`id(`identifier), `Value),
+ tpg ] );
+ }
+
+void storeAddTarget(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;
+ storeModify(option_id,option_map);
+ }
+
+
+// validate function checks if target/tpg are unique and not empty
+boolean validateAddTarget(string key, map event)
+ {
+ list target = uiTarget();
+ y2milestone( "validateAddTarget %1", target );
+ boolean ret = true;
+ if( size(target[0]:"")==0 )
+ {
+ Popup::Error(_("The target cannot be empty."));
+ UI::SetFocus(`id(`target));
+ ret = false;
+ }
+ else if( target[2]:nil==nil )
+ {
+ Popup::Error(_("The target portal group cannot be empty."));
+ UI::SetFocus(`id(`tpg));
+ ret = false;
+ }
+ else if( IscsiLioData::HasTarget(sformat( "%1:%2", target[0]:"",
target[1]:"" ), target[2]:-1 ))
+ {
+ Popup::Error(_("The target already exists."));
+ UI::SetFocus(`id(`target));
+ ret = false;
+ }
+ return ret;
+ }
+
}

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

< Previous Next >
This Thread
  • No further messages