Mailinglist Archive: yast-commit (215 mails)
| < Previous | Next > |
[yast-commit] r67848 - in /branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src: IscsiLioData.ycp IscsiLioServer.ycp complex.ycp dialogs.ycp widgets.ycp
- From: fehr@xxxxxxxxxxxxxxxxx
- Date: Mon, 02 Apr 2012 16:41:37 -0000
- Message-id: <20120402164138.20C24322FA@svn2.opensuse.org>
Author: fehr
Date: Mon Apr 2 18:41:37 2012
New Revision: 67848
URL: http://svn.opensuse.org/viewcvs/yast?rev=67848&view=rev
Log:
update as 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/complex.ycp
branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/dialogs.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=67848&r1=67847&r2=67848&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 Mon
Apr 2 18:41:37 2012
@@ -224,7 +224,7 @@
});
}
-global void SetAuth( string tgt, integer tpg, list<string> incom, string outgo
)
+global void SetIetdAuth( string tgt, integer tpg, list<string> incom, string
outgo )
{
map<string,any> m = GetTgt(data,tgt,tpg);
foreach( string s, incom, ``{m=AddIncoming( m, s );});
@@ -258,6 +258,13 @@
return( HasIncomingAuth(tgt,tpg)||HasOutgoingAuth(tgt,tpg) );
}
+global map GetAuth( string tgt, integer tpg, string clnt )
+ {
+ map m = GetTgt(data,tgt,tpg);
+ return( $[ "incoming" : m["incoming",0]:[],
+ "outgoing" : m["outgoing"]:[] ] );
+ }
+
global map<integer,map> GetLun( string tgt, integer tpg )
{
map<integer,map> ret = data["tgt",tgt,tpg,"ep","lun"]:$[];
@@ -580,9 +587,9 @@
list<string> chap = [ "", "" ];
ParseAuthData( "", 0, "", chap, mutual );
if( size(mutual[0]:"")>0 && size(mutual[1]:"")>0 )
- tgmap["outgoing"] = mutual;
+ ret["outgoing"] = mutual;
if( size(chap[0]:"")>0 && size(chap[1]:"")>0 )
- tgmap["incoming"] = [ chap ];
+ ret["incoming"] = [ chap ];
foreach( string tgt, map m, endp,
{
tgmap[tgt] = $[];
@@ -786,6 +793,63 @@
return( ret );
}
+global boolean SetAuth( string tgt, integer tpg, string clnt, list inc, list
out )
+ {
+ y2milestone( "SetAuth tgt:%1 tpg:%2 clnt:%3 in:%4 out:%5",
+ tgt, tpg, clnt, inc, out );
+ string cmd = "";
+ boolean ret = true;
+ if( size(tgt)==0 )
+ {
+ if( size(inc)>0 )
+ {
+ cmd = "lio_node --setchapdiscauth ";
+ ret = LogExecCmd( cmd + inc[0]:"" + " " + inc[1]:"" ) && ret;
+ }
+ else if(HasIncomingAuth("",0))
+ {
+ ret = false;
+ y2error( "SetAuth: impossible to disable discovery auth" );
+ }
+ if( size(out)>0 )
+ {
+ cmd = "lio_node --setchapdiscmutualauth ";
+ ret = LogExecCmd( cmd + out[0]:"" + " " + out[1]:"" ) && ret;
+ }
+ else if(HasOutgoingAuth("",0))
+ {
+ ret = false;
+ y2error( "SetAuth: impossible to disable discovery mutual auth" );
+ }
+ }
+ else
+ {
+ string param = tgt + " " + tpg + " " + clnt;
+ if( size(inc)>0 )
+ {
+ cmd = "lio_node --setchapauth " + param;
+ ret = LogExecCmd( cmd + inc[0]:"" + " " + inc[1]:"" ) && ret;
+ }
+ else if(HasIncomingAuth(tgt,tpg))
+ {
+ ret = false;
+ y2error( "SetAuth: impossible to disable auth" );
+ }
+ if( size(out)>0 )
+ {
+ cmd = "lio_node --setchapmutualauth " + param;
+ ret = LogExecCmd( cmd + out[0]:"" + " " + out[1]:"" ) && ret;
+ }
+ else if(HasOutgoingAuth(tgt,tpg))
+ {
+ ret = false;
+ y2error( "SetAuth: impossible to disable mutual auth" );
+ }
+ }
+ y2milestone( "SetAuth 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=67848&r1=67847&r2=67848&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
Mon Apr 2 18:41:37 2012
@@ -172,69 +172,80 @@
}
// #157643 - reload server
-boolean reloadServer(){
-// ask user whether reload or restart server
-// #180205 - gettext problem - string wasn't marked to translate
-if (Popup::YesNo(_( "If changes have been made, the iSCSI target is not able
+boolean reloadServer()
+ {
+ return true;
+ // ask user whether reload or restart server
+ // #180205 - gettext problem - string wasn't marked to translate
+ if (Popup::YesNo(_( "If changes have been made, the iSCSI target is not
able
to reload current configuration. It can only restart.
When restarting, all sessions are aborted.
Restart the target service?
-"))) Service::Restart("target");
- else {
+")))
+ Service::Restart("target");
+ else
+ {
// get changes from perl module
- map<string, any> changes = IscsiLioData::GetChanges();
- list<string> connected = IscsiLioData::GetConnected();
+ map<string, any> changes = IscsiLioData::GetChanges();
+ list<string> connected = IscsiLioData::GetConnected();
// delete targets
- foreach(string row, changes["del"]:[], {
+ foreach(string row, changes["del"]:[],
+ {
if (!contains(connected, row)){
- y2milestone("row to delete %1", row);
- string target=((map<string, any>)SCR::Execute(.target.bash_output,
+ y2milestone("row to delete %1", row);
+ string target=((map<string, any>)SCR::Execute(.target.bash_output,
// get TID number for target
"cat /proc/net/iet/volume|grep $TARGET",
$["TARGET":row]))["stdout"]:"" ;
- string to_delete = splitstring( splitstring(target, " ")[0]:"",
":")[1]:"";
- y2milestone("to delete %1", to_delete);
- // delete record with that TID
- SCR::Execute(.target.bash_output, "ietadm --op delete --tid=$TID",
$["TID":to_delete]);
- } else y2error("Cannot remove target %1 - already connected", row);
- });
+ string to_delete = splitstring( splitstring(target, " ")[0]:"",
":")[1]:"";
+ y2milestone("to delete %1", to_delete);
+ // delete record with that TID
+ SCR::Execute(.target.bash_output, "ietadm --op delete --tid=$TID",
$["TID":to_delete]);
+ }
+ else
+ y2error("Cannot remove target %1 - already connected", row);
+ });
// add a new target
- foreach(string row, changes["add"]:[], {
+ foreach(string row, changes["add"]:[],
+ {
y2milestone("row to add %1", row);
- // create new target
- SCR::Execute(.target.bash_output, "ietadm --op new --tid=0 --params
Name=$NAME", $["NAME":row]);
- string target=((map<string, any>)SCR::Execute(.target.bash_output,
- "cat /proc/net/iet/volume|grep $TARGET",
$["TARGET":row]))["stdout"]:"" ;
- // get TID of that target
+ // create new target
+ SCR::Execute(.target.bash_output, "ietadm --op new --tid=0 --params
Name=$NAME", $["NAME":row]);
+ string target=((map<string, any>)SCR::Execute(.target.bash_output,
+ "cat /proc/net/iet/volume|grep $TARGET",
$["TARGET":row]))["stdout"]:"" ;
+ // get TID of that target
string to_add = splitstring( splitstring(target, " ")[0]:"",
":")[1]:"";
y2milestone("to add %1", to_add);
- list<string> lun = [];
- list <string> secret = [];
- // add authentication to target
- foreach( map<string, any> conf_row, (list<map<string, any> >)
IscsiLioData::GetConfig()[row]:[], {
- switch (conf_row["KEY"]:""){
- case("Lun") : lun = splitstring(conf_row["VALUE"]:"", " ");
- break;
- case("IncomingUser") : secret =
splitstring(conf_row["VALUE"]:"", " ");
- y2milestone("params %1 %2 %3", to_add, secret[0]:"", secret[1]:"");
- SCR::Execute(.target.bash_output,
"ietadm --op new --tid=$TID --user --params=IncomingUser=$US,Password=$PASS",
$["TID":to_add, "US":secret[0]:"", "PASS":secret[1]:""]);
- break;
- case("OutgoingUser") : secret =
splitstring(conf_row["VALUE"]:"", " ");
- SCR::Execute(.target.bash_output,
"ietadm --op new --tid=$TID --user --params=OutgoingUser=$US,Password=$PASS",
$["TID":to_add, "US":secret[0]:"", "PASS":secret[1]:""]);
- break;
- }
- });
- string lun_num = lun[0]:"";
- string lun_path = splitstring(lun[1]:"", ",")[0]:"";
- // add LUN for target
- string command = sformat("ietadm --op new --tid=%1 --lun=%2 --params
%3", to_add, lun_num, lun_path);
- SCR::Execute(.target.bash_output, command, $[]);
- y2milestone("lun %1,%2", lun_num, lun_path);
- });
-
- }
- return true;
-}
+ list<string> lun = [];
+ list <string> secret = [];
+ // add authentication to target
+ foreach( map<string, any> conf_row, (list<map<string, any> >)
IscsiLioData::GetConfig()[row]:[],
+ {
+ switch (conf_row["KEY"]:"")
+ {
+ case("Lun") : lun = splitstring(conf_row["VALUE"]:"", " ");
+ break;
+ case("IncomingUser") :
+ secret = splitstring(conf_row["VALUE"]:"", " ");
+ y2milestone("params %1 %2 %3", to_add, secret[0]:"",
secret[1]:"");
+ SCR::Execute(.target.bash_output, "ietadm --op new
--tid=$TID --user --params=IncomingUser=$US,Password=$PASS", $["TID":to_add,
"US":secret[0]:"", "PASS":secret[1]:""]);
+ break;
+ case("OutgoingUser") :
+ secret = splitstring(conf_row["VALUE"]:"", " ");
+ SCR::Execute(.target.bash_output, "ietadm --op new --tid=$TID
--user --params=OutgoingUser=$US,Password=$PASS", $["TID":to_add,
"US":secret[0]:"", "PASS":secret[1]:""]);
+ break;
+ }
+ });
+ string lun_num = lun[0]:"";
+ string lun_path = splitstring(lun[1]:"", ",")[0]:"";
+ // add LUN for target
+ string command = sformat("ietadm --op new --tid=%1 --lun=%2 --params
%3", to_add, lun_num, lun_path);
+ SCR::Execute(.target.bash_output, command, $[]);
+ y2milestone("lun %1,%2", lun_num, lun_path);
+ });
+ }
+ return true;
+ }
/**
@@ -409,7 +420,7 @@
if (row["KEY"]:""=="IncomingUser") incom = add(incom, row["VALUE"]:"");
else outgoin = row["VALUE"]:"";
});
- IscsiLioData::SetAuth("",0,incom, outgoin);
+ IscsiLioData::SetIetdAuth("",0,incom, outgoin);
break;
case("targets") :
string name = "";
@@ -444,7 +455,7 @@
}
});
IscsiLioData::AddNewTarget(name, tpg, lun);
- IscsiLioData::SetAuth(name, tpg, inc, out);
+ IscsiLioData::SetIetdAuth(name, tpg, inc, out);
});
break;
}
Modified: branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/complex.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/complex.ycp?rev=67848&r1=67847&r2=67848&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/complex.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/complex.ycp Mon Apr
2 18:41:37 2012
@@ -51,6 +51,7 @@
* @return `abort if aborted and `next otherwise
*/
symbol WriteDialog() {
+ y2milestone( "WriteDialog" );
Wizard::RestoreHelp(HELPS["write"]:"");
// IscsiLioServer::AbortFunction = PollAbort;
boolean ret = IscsiLioServer::Write();
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=67848&r1=67847&r2=67848&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 Mon Apr
2 18:41:37 2012
@@ -42,8 +42,6 @@
"auto_start_up",
`VSpacing (2),
"firewall",
- `VSpacing (2),
- "save",
`VSpacing (2)
),
`HSpacing (1),
@@ -51,7 +49,7 @@
),
`VStretch()
),
- "widget_names" : [ "auto_start_up", "firewall", "save" ]
+ "widget_names" : [ "auto_start_up", "firewall" ]
],
// second tab - global authentication
"global":$[
@@ -153,53 +151,66 @@
-map<string, map <string, any> > widgets = $[
- "auto_start_up" : CWMServiceStart::CreateAutoStartWidget ($[
- "get_service_auto_start" : IscsiLioServer::GetStartService,
- "set_service_auto_start" : IscsiLioServer::SetStartService,
- // radio button (starting iscsitarget service - option 1)
- "start_auto_button" : _("When &Booting"),
- // radio button (starting LIO target service - option 2)
- "start_manual_button" : _("&Manually"),
- "help" : sformat (CWMServiceStart::AutoStartHelpTemplate (),
- // part of help text, used to describe radiobuttons
(matching starting LIO target service but without "&")
- _("When Booting"),
- // part of help text, used to describe radiobuttons
(matching starting LIO target service but without "&")
- _("Manually")
+map<string, map <string, any> > widgets =
+ $[
+ "auto_start_up" :
+ CWMServiceStart::CreateAutoStartWidget ($[
+ "get_service_auto_start" : IscsiLioServer::GetStartService,
+ "set_service_auto_start" : IscsiLioServer::SetStartService,
+ // radio button (starting iscsitarget service - option 1)
+ "start_auto_button" : _("When &Booting"),
+ // radio button (starting LIO target service - option 2)
+ "start_manual_button" : _("&Manually"),
+ "help" : sformat (CWMServiceStart::AutoStartHelpTemplate (),
+ // part of help text, used to describe radiobuttons (matching
starting LIO target service but without "&")
+ _("When Booting"),
+ // part of help text, used to describe radiobuttons (matching
starting LIO target service but without "&")
+ _("Manually")
),
]),
- // firewall
- "firewall" : CWMFirewallInterfaces::CreateOpenFirewallWidget ($[
- "services" : [ "service:iscsitarget" ],
- "display_details" : true,
+ // firewall
+ "firewall" : CWMFirewallInterfaces::CreateOpenFirewallWidget ($[
+ "services" : [ "service:iscsitarget" ],
+ "display_details" : true,
]),
- "save" : $[
+ "save" : $[
"widget" : `push_button,
"label" : Label::SaveButton(),
"handle" : saveConfiguration,
"opt": [],
"help": HELPS["save_configuration"]:""
- ],
- "isns" : $[
+ ],
+ "isns" : $[
"widget" : `custom,
"custom_widget" :
`HBox(
- `CheckBoxFrame(`id(`isns_ac), _("iSNS Access Control"), true,
- `VBox(
- `InputField(`id(`isns_ip), `opt(`hstretch), _("iSNS
Server"))
- ))
- ),
+ `CheckBoxFrame(`id(`isns_ac), _("iSNS Access Control"), true,
+ `VBox(`InputField(`id(`isns_ip), `opt(`hstretch), _("iSNS
Server"))))
+ ),
"init" : initiSNS,
"validate_type" : `function,
"validate_function" : validateiSNS,
"store" : storeiSNS
],
- // discovery authentication dialog
- "global_config" : $[
+ // discovery authentication dialog
+ "global_config" : $[
"widget" : `custom,
- "custom_widget" : tabs_descr["auth", "contents"]:nil,
+ "custom_widget" :
+ `VBox(
+ `Left( `CheckBox(`id(`auth_none),`opt(`notify), _("No
Authentication"), true) ),
+ `VSpacing(2),
+ `Left( `CheckBox(`id(`auth_in),`opt(`notify), _("Incoming
Authentication"), false) ),
+ `HBox(
+ `InputField(`id(`user_in), `opt(`hstretch),
_("Username")),
+ `Password(`id(`pass_in), _("Password"))),
+ `VSpacing(2),
+ `Left( `CheckBox(`id(`auth_out),`opt(`notify), _("Outgoing
Authentication"), false) ),
+ `HBox(
+ `InputField(`id(`user_out), `opt(`hstretch),
_("Username")),
+ `Password(`id(`pass_out), _("Password")))
+ ),
"init" : initGlobal,
"handle" : handleAuth,
"store" : storeGlobal,
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=67848&r1=67847&r2=67848&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 Mon Apr
2 18:41:37 2012
@@ -119,13 +119,9 @@
// set incoming authentication enabled/disabled status
void setAuthIn(boolean status){
y2milestone("Status of AuthIncoming %1", status);
- UI::ChangeWidget(`id(`incoming_table),`Enabled, status );
+ UI::ChangeWidget(`id(`user_in),`Enabled, status );
+ UI::ChangeWidget(`id(`pass_in),`Enabled, status );
UI::ChangeWidget(`id(`auth_in),`Value, status );
-
- UI::ChangeWidget(`id(`add),`Enabled, status );
- UI::ChangeWidget(`id(`edit),`Enabled, status );
- UI::ChangeWidget(`id(`delete),`Enabled, status );
-
if(status) UI::ChangeWidget(`id(`auth_none),`Value, !status );
}
@@ -139,25 +135,24 @@
}
// get values for incoming authentication
-list<string> getIncomingValues(){
- list <string> values = [];
- if ((boolean)UI::QueryWidget(`id(`auth_in), `Value) == true){
- integer count = -1;
- while (count<size(inc_auth)-1){
- count = count+1;
- values=add(values, sformat("%1 %2", inc_auth[count, "USER"]:"",
inc_auth[count, "PASS"]:""));
- }
- return values;
- } else return [];
-}
+list<string> getIncomingValues()
+ {
+ list<string> values = [];
+ if ((boolean)UI::QueryWidget(`id(`auth_in), `Value) == true)
+ values = [ (string)UI::QueryWidget(`id(`user_in), `Value),
+ (string)UI::QueryWidget(`id(`pass_in), `Value) ];
+ return values;
+ }
// get values for outgoing authentication
-string getOutgoingValues(){
- if ((boolean)UI::QueryWidget(`id(`auth_out), `Value) == true){
- string values = sformat("%1 %2", UI::QueryWidget(`id(`user_out), `Value),
UI::QueryWidget(`id(`pass_out), `Value) );
- return values;
- } else return "";
-}
+list<string> getOutgoingValues()
+ {
+ list<string> values = [];
+ if ((boolean)UI::QueryWidget(`id(`auth_out), `Value) == true)
+ values = [ (string)UI::QueryWidget(`id(`user_out), `Value),
+ (string)UI::QueryWidget(`id(`pass_out), `Value) ];
+ return values;
+ }
// dialog to add/modify user and password
list <string> getDialogValues(string user, string pass){
@@ -189,29 +184,29 @@
}
-symbol saveConfiguration(string key, map event){
- if (is(event["ID"]:nil, string) && event["ID"]:"" == "save"){
+symbol saveConfiguration(string key, map event)
+ {
+ y2milestone( "saveConfiguration key:%1 event:%2", key, event );
+ if( is(event["ID"]:nil, string) && event["ID"]:"" == "save")
+ {
any filename = UI::AskForSaveFileName("/", "*", _("Save as..."));
if ( filename != nil && (string)filename!="")
- {
- if ( IscsiServerFunctions::SaveIntoFile( (string)filename ))
{
+ if( IscsiServerFunctions::SaveIntoFile( (string)filename ))
+ {
Popup::Message(sformat(_("File %1 was saved successfully."),
filename));
list pathComponents = splitstring( (string)filename, "/");
integer s = size(pathComponents) - 1;
string base = pathComponents[s]:"default";
- }
+ }
else
- {
+ {
Popup::Warning(_("An error occurred while saving the file."));
+ }
}
}
- }
- return nil;
-}
-
-
-
+ return nil;
+ }
// **************** Server Dialog *********************
// dialog with targets
@@ -331,150 +326,95 @@
// **************** Global Dialog *********************
-void initGlobalValues(list<map<string, any> > values){
- setAuthIn(false);
- setAuthOut(false);
- string user = "";
- string pass = "";
- // incoming authentication
- inc_auth = $[];
- integer count = 0;
- foreach(map<string,any> auth, values, {
- if (auth["KEY"]:"" == "IncomingUser") {
- user = splitstring(auth["VALUE"]:"", " ")[0]:"";
- pass = splitstring(auth["VALUE"]:"", " ")[1]:"";
- inc_auth[count] = $["USER":user, "PASS":pass];
- count = count + 1;
- setAuthIn(true);
- }
- if (auth["KEY"]:"" == "OutgoingUser") {
- UI::ChangeWidget(`id(`user_out), `Value, splitstring(auth["VALUE"]:"",
" ")[0]:"");
- UI::ChangeWidget(`id(`pass_out), `Value, splitstring(auth["VALUE"]:"",
" ")[1]:"");
- setAuthOut(true);
+void initGlobalValues(map auth)
+ {
+ string user = "";
+ string pass = "";
+ // incoming authentication
+ if( size(auth["incoming"]:[])>0 );
+ {
+ 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);
+ // outgoing authentication
+ user = "";
+ pass = "";
+ if( size(auth["outgoing"]:[])>0 );
+ {
+ 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);
}
- });
- UI::ChangeWidget(`id(`incoming_table), `Items, getAuthItems() );
-}
// initialize discovery authentication or authentication for given target
void initGlobal (string key)
{
if (size(curr_target)>0)
- initGlobalValues(IscsiServerFunctions::getConfig()[curr_target]:[]);
+ initGlobalValues(IscsiLioData::GetAuth(curr_target,curr_tpg,""));
else
- initGlobalValues(IscsiServerFunctions::getConfig()["auth"]:[]);
+ initGlobalValues(IscsiLioData::GetAuth("",0,""));
}
// save discovery authentication or authentication for given target
-void storeGlobal(string option_id, map option_map){
- if (size(curr_target)>0){
-
- IscsiServerFunctions::setTargetAuth( curr_target, getIncomingValues(),
getOutgoingValues() );
- IscsiServerFunctions::saveNewTarget(curr_target);
-
- } else{
- IscsiServerFunctions::setAuth( getIncomingValues(), getOutgoingValues()
);
- }
-}
+void storeGlobal(string option_id, map option_map)
+ {
+ y2milestone( "storeGlobal id:%1 map:%2", option_id, option_map );
+ boolean ret = false;
+ if(size(curr_target)>0)
+ {
+ ret = IscsiLioData::SetAuth( curr_target, curr_tpg, "",
getIncomingValues(), getOutgoingValues() );
+ }
+ else
+ {
+ ret = IscsiLioData::SetAuth( "", 0, "", getIncomingValues(),
getOutgoingValues() );
+ }
+ if( !ret )
+ {
+ Popup::Error( _("Problem changing authentication"));
+ }
+ IscsiLioData::UpdateConfig();
+ }
// validate functions checks the secret for incoming and outgoing cannot be
same
-boolean validateGlobal(string key, map event){
- boolean ret=false;
- if (!contains(getIncomingValues(), getOutgoingValues())) ret=true;
- else Popup::Error(_("Cannot use the same secret for incoming and
outgoing authentication."));
- return ret;
-}
+boolean validateGlobal(string key, map event)
+ {
+ boolean ret=true;
+ return ret;
+ }
// **************** Target Auth *******************
// handle authentication dialog
-symbol handleAuth(string key, map event){
- if (event["EventReason"]:"" == "ValueChanged"){
- boolean status = false;
-// enable/disable none/incoming/outgoing authentication
- switch((symbol)event["ID"]:nil){
- case(`auth_none):
+symbol handleAuth(string key, map event)
+ {
+ if (event["EventReason"]:"" == "ValueChanged")
+ {
+ boolean status = false;
+ // enable/disable none/incoming/outgoing authentication
+ switch((symbol)event["ID"]:nil)
+ {
+ case(`auth_none):
status = (boolean)UI::QueryWidget(`id(`auth_none), `Value);
setAuthIn(!status);
setAuthOut(!status);
break;
- case(`auth_in):
+ case(`auth_in):
status = (boolean)UI::QueryWidget(`id(`auth_in), `Value);
setAuthIn(status);
break;
- case(`auth_out):
+ case(`auth_out):
status = (boolean)UI::QueryWidget(`id(`auth_out), `Value);
setAuthOut(status);
break;
- }
- }
-// add/edit/delete incoming authentication
- if (event["EventReason"]:"" == "Activated"){
- switch((symbol)event["ID"]:nil){
- case(`add) :
- list<string> values = getDialogValues("", "");
- y2milestone("Add authentication values");
- if (size(values)==2 ){
- string user = values[0]:"";
- string pass = values[1]:"";
- integer count = size((list)UI::QueryWidget(`id
(`incoming_table),`Items));
-
- inc_auth[size(inc_auth)]= $["USER":user, "PASS":pass];
- UI::ChangeWidget (`id (`incoming_table), `Items,
getAuthItems());
- }
-
- break;
- case(`edit) :
- integer curr = tointeger( UI::QueryWidget(`id
(`incoming_table),`CurrentItem) );
- y2milestone("Modify authentication values");
- if (curr!=nil){
- string user = inc_auth[curr, "USER"]:"";
- string pass = inc_auth[curr, "PASS"]:"";
- list<string> values = getDialogValues(user, pass);
-
- if (size(values)==2 ){
- string user = values[0]:"";
- string pass = values[1]:"";
-
- list<term> rows = (list<term>)UI::QueryWidget(`id
(`incoming_table),`Items);
- inc_auth[curr] = $["USER":user, "PASS":pass];
- UI::ChangeWidget (`id (`incoming_table), `Items,
getAuthItems());
- }
-
- }
- break;
- case(`delete) :
- any del = UI::QueryWidget(`id (`incoming_table),`CurrentItem);
- y2milestone("Delete authentication value");
- if (del != nil){
- if (Popup::ContinueCancel(_("Really delete the selected
item?")))
- {
- integer count = 0;
- map<integer, any> temp_map = $[];
- while(count<size(inc_auth))
- {
- if (count<del)
- temp_map[count]=inc_auth[count]:nil;
- else if (count>del)
- temp_map[count-1]=inc_auth[count]:nil;
- count = count+1;
- }
- inc_auth = temp_map;
- UI::ChangeWidget(`id(`incoming_table), `Items,
getAuthItems());
- } else y2milestone("Delete canceled");
- }
- break;
- }
- }
- if (size((list)UI::QueryWidget(`incoming_table, `Items))==0){
- UI::ChangeWidget(`edit, `Enabled, false);
- UI::ChangeWidget(`delete, `Enabled, false);
- } else {
- UI::ChangeWidget(`edit, `Enabled, true);
- UI::ChangeWidget(`delete, `Enabled, true);
- }
-
- return nil;
-}
+ }
+ }
+ return nil;
+ }
// **************** Edit Dialog *****************************
--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx
Date: Mon Apr 2 18:41:37 2012
New Revision: 67848
URL: http://svn.opensuse.org/viewcvs/yast?rev=67848&view=rev
Log:
update as 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/complex.ycp
branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/dialogs.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=67848&r1=67847&r2=67848&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 Mon
Apr 2 18:41:37 2012
@@ -224,7 +224,7 @@
});
}
-global void SetAuth( string tgt, integer tpg, list<string> incom, string outgo
)
+global void SetIetdAuth( string tgt, integer tpg, list<string> incom, string
outgo )
{
map<string,any> m = GetTgt(data,tgt,tpg);
foreach( string s, incom, ``{m=AddIncoming( m, s );});
@@ -258,6 +258,13 @@
return( HasIncomingAuth(tgt,tpg)||HasOutgoingAuth(tgt,tpg) );
}
+global map GetAuth( string tgt, integer tpg, string clnt )
+ {
+ map m = GetTgt(data,tgt,tpg);
+ return( $[ "incoming" : m["incoming",0]:[],
+ "outgoing" : m["outgoing"]:[] ] );
+ }
+
global map<integer,map> GetLun( string tgt, integer tpg )
{
map<integer,map> ret = data["tgt",tgt,tpg,"ep","lun"]:$[];
@@ -580,9 +587,9 @@
list<string> chap = [ "", "" ];
ParseAuthData( "", 0, "", chap, mutual );
if( size(mutual[0]:"")>0 && size(mutual[1]:"")>0 )
- tgmap["outgoing"] = mutual;
+ ret["outgoing"] = mutual;
if( size(chap[0]:"")>0 && size(chap[1]:"")>0 )
- tgmap["incoming"] = [ chap ];
+ ret["incoming"] = [ chap ];
foreach( string tgt, map m, endp,
{
tgmap[tgt] = $[];
@@ -786,6 +793,63 @@
return( ret );
}
+global boolean SetAuth( string tgt, integer tpg, string clnt, list inc, list
out )
+ {
+ y2milestone( "SetAuth tgt:%1 tpg:%2 clnt:%3 in:%4 out:%5",
+ tgt, tpg, clnt, inc, out );
+ string cmd = "";
+ boolean ret = true;
+ if( size(tgt)==0 )
+ {
+ if( size(inc)>0 )
+ {
+ cmd = "lio_node --setchapdiscauth ";
+ ret = LogExecCmd( cmd + inc[0]:"" + " " + inc[1]:"" ) && ret;
+ }
+ else if(HasIncomingAuth("",0))
+ {
+ ret = false;
+ y2error( "SetAuth: impossible to disable discovery auth" );
+ }
+ if( size(out)>0 )
+ {
+ cmd = "lio_node --setchapdiscmutualauth ";
+ ret = LogExecCmd( cmd + out[0]:"" + " " + out[1]:"" ) && ret;
+ }
+ else if(HasOutgoingAuth("",0))
+ {
+ ret = false;
+ y2error( "SetAuth: impossible to disable discovery mutual auth" );
+ }
+ }
+ else
+ {
+ string param = tgt + " " + tpg + " " + clnt;
+ if( size(inc)>0 )
+ {
+ cmd = "lio_node --setchapauth " + param;
+ ret = LogExecCmd( cmd + inc[0]:"" + " " + inc[1]:"" ) && ret;
+ }
+ else if(HasIncomingAuth(tgt,tpg))
+ {
+ ret = false;
+ y2error( "SetAuth: impossible to disable auth" );
+ }
+ if( size(out)>0 )
+ {
+ cmd = "lio_node --setchapmutualauth " + param;
+ ret = LogExecCmd( cmd + out[0]:"" + " " + out[1]:"" ) && ret;
+ }
+ else if(HasOutgoingAuth(tgt,tpg))
+ {
+ ret = false;
+ y2error( "SetAuth: impossible to disable mutual auth" );
+ }
+ }
+ y2milestone( "SetAuth 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=67848&r1=67847&r2=67848&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
Mon Apr 2 18:41:37 2012
@@ -172,69 +172,80 @@
}
// #157643 - reload server
-boolean reloadServer(){
-// ask user whether reload or restart server
-// #180205 - gettext problem - string wasn't marked to translate
-if (Popup::YesNo(_( "If changes have been made, the iSCSI target is not able
+boolean reloadServer()
+ {
+ return true;
+ // ask user whether reload or restart server
+ // #180205 - gettext problem - string wasn't marked to translate
+ if (Popup::YesNo(_( "If changes have been made, the iSCSI target is not
able
to reload current configuration. It can only restart.
When restarting, all sessions are aborted.
Restart the target service?
-"))) Service::Restart("target");
- else {
+")))
+ Service::Restart("target");
+ else
+ {
// get changes from perl module
- map<string, any> changes = IscsiLioData::GetChanges();
- list<string> connected = IscsiLioData::GetConnected();
+ map<string, any> changes = IscsiLioData::GetChanges();
+ list<string> connected = IscsiLioData::GetConnected();
// delete targets
- foreach(string row, changes["del"]:[], {
+ foreach(string row, changes["del"]:[],
+ {
if (!contains(connected, row)){
- y2milestone("row to delete %1", row);
- string target=((map<string, any>)SCR::Execute(.target.bash_output,
+ y2milestone("row to delete %1", row);
+ string target=((map<string, any>)SCR::Execute(.target.bash_output,
// get TID number for target
"cat /proc/net/iet/volume|grep $TARGET",
$["TARGET":row]))["stdout"]:"" ;
- string to_delete = splitstring( splitstring(target, " ")[0]:"",
":")[1]:"";
- y2milestone("to delete %1", to_delete);
- // delete record with that TID
- SCR::Execute(.target.bash_output, "ietadm --op delete --tid=$TID",
$["TID":to_delete]);
- } else y2error("Cannot remove target %1 - already connected", row);
- });
+ string to_delete = splitstring( splitstring(target, " ")[0]:"",
":")[1]:"";
+ y2milestone("to delete %1", to_delete);
+ // delete record with that TID
+ SCR::Execute(.target.bash_output, "ietadm --op delete --tid=$TID",
$["TID":to_delete]);
+ }
+ else
+ y2error("Cannot remove target %1 - already connected", row);
+ });
// add a new target
- foreach(string row, changes["add"]:[], {
+ foreach(string row, changes["add"]:[],
+ {
y2milestone("row to add %1", row);
- // create new target
- SCR::Execute(.target.bash_output, "ietadm --op new --tid=0 --params
Name=$NAME", $["NAME":row]);
- string target=((map<string, any>)SCR::Execute(.target.bash_output,
- "cat /proc/net/iet/volume|grep $TARGET",
$["TARGET":row]))["stdout"]:"" ;
- // get TID of that target
+ // create new target
+ SCR::Execute(.target.bash_output, "ietadm --op new --tid=0 --params
Name=$NAME", $["NAME":row]);
+ string target=((map<string, any>)SCR::Execute(.target.bash_output,
+ "cat /proc/net/iet/volume|grep $TARGET",
$["TARGET":row]))["stdout"]:"" ;
+ // get TID of that target
string to_add = splitstring( splitstring(target, " ")[0]:"",
":")[1]:"";
y2milestone("to add %1", to_add);
- list<string> lun = [];
- list <string> secret = [];
- // add authentication to target
- foreach( map<string, any> conf_row, (list<map<string, any> >)
IscsiLioData::GetConfig()[row]:[], {
- switch (conf_row["KEY"]:""){
- case("Lun") : lun = splitstring(conf_row["VALUE"]:"", " ");
- break;
- case("IncomingUser") : secret =
splitstring(conf_row["VALUE"]:"", " ");
- y2milestone("params %1 %2 %3", to_add, secret[0]:"", secret[1]:"");
- SCR::Execute(.target.bash_output,
"ietadm --op new --tid=$TID --user --params=IncomingUser=$US,Password=$PASS",
$["TID":to_add, "US":secret[0]:"", "PASS":secret[1]:""]);
- break;
- case("OutgoingUser") : secret =
splitstring(conf_row["VALUE"]:"", " ");
- SCR::Execute(.target.bash_output,
"ietadm --op new --tid=$TID --user --params=OutgoingUser=$US,Password=$PASS",
$["TID":to_add, "US":secret[0]:"", "PASS":secret[1]:""]);
- break;
- }
- });
- string lun_num = lun[0]:"";
- string lun_path = splitstring(lun[1]:"", ",")[0]:"";
- // add LUN for target
- string command = sformat("ietadm --op new --tid=%1 --lun=%2 --params
%3", to_add, lun_num, lun_path);
- SCR::Execute(.target.bash_output, command, $[]);
- y2milestone("lun %1,%2", lun_num, lun_path);
- });
-
- }
- return true;
-}
+ list<string> lun = [];
+ list <string> secret = [];
+ // add authentication to target
+ foreach( map<string, any> conf_row, (list<map<string, any> >)
IscsiLioData::GetConfig()[row]:[],
+ {
+ switch (conf_row["KEY"]:"")
+ {
+ case("Lun") : lun = splitstring(conf_row["VALUE"]:"", " ");
+ break;
+ case("IncomingUser") :
+ secret = splitstring(conf_row["VALUE"]:"", " ");
+ y2milestone("params %1 %2 %3", to_add, secret[0]:"",
secret[1]:"");
+ SCR::Execute(.target.bash_output, "ietadm --op new
--tid=$TID --user --params=IncomingUser=$US,Password=$PASS", $["TID":to_add,
"US":secret[0]:"", "PASS":secret[1]:""]);
+ break;
+ case("OutgoingUser") :
+ secret = splitstring(conf_row["VALUE"]:"", " ");
+ SCR::Execute(.target.bash_output, "ietadm --op new --tid=$TID
--user --params=OutgoingUser=$US,Password=$PASS", $["TID":to_add,
"US":secret[0]:"", "PASS":secret[1]:""]);
+ break;
+ }
+ });
+ string lun_num = lun[0]:"";
+ string lun_path = splitstring(lun[1]:"", ",")[0]:"";
+ // add LUN for target
+ string command = sformat("ietadm --op new --tid=%1 --lun=%2 --params
%3", to_add, lun_num, lun_path);
+ SCR::Execute(.target.bash_output, command, $[]);
+ y2milestone("lun %1,%2", lun_num, lun_path);
+ });
+ }
+ return true;
+ }
/**
@@ -409,7 +420,7 @@
if (row["KEY"]:""=="IncomingUser") incom = add(incom, row["VALUE"]:"");
else outgoin = row["VALUE"]:"";
});
- IscsiLioData::SetAuth("",0,incom, outgoin);
+ IscsiLioData::SetIetdAuth("",0,incom, outgoin);
break;
case("targets") :
string name = "";
@@ -444,7 +455,7 @@
}
});
IscsiLioData::AddNewTarget(name, tpg, lun);
- IscsiLioData::SetAuth(name, tpg, inc, out);
+ IscsiLioData::SetIetdAuth(name, tpg, inc, out);
});
break;
}
Modified: branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/complex.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/complex.ycp?rev=67848&r1=67847&r2=67848&view=diff
==============================================================================
--- branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/complex.ycp (original)
+++ branches/SuSE-Code-11-SP2-Branch/iscsi-lio-server/src/complex.ycp Mon Apr
2 18:41:37 2012
@@ -51,6 +51,7 @@
* @return `abort if aborted and `next otherwise
*/
symbol WriteDialog() {
+ y2milestone( "WriteDialog" );
Wizard::RestoreHelp(HELPS["write"]:"");
// IscsiLioServer::AbortFunction = PollAbort;
boolean ret = IscsiLioServer::Write();
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=67848&r1=67847&r2=67848&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 Mon Apr
2 18:41:37 2012
@@ -42,8 +42,6 @@
"auto_start_up",
`VSpacing (2),
"firewall",
- `VSpacing (2),
- "save",
`VSpacing (2)
),
`HSpacing (1),
@@ -51,7 +49,7 @@
),
`VStretch()
),
- "widget_names" : [ "auto_start_up", "firewall", "save" ]
+ "widget_names" : [ "auto_start_up", "firewall" ]
],
// second tab - global authentication
"global":$[
@@ -153,53 +151,66 @@
-map<string, map <string, any> > widgets = $[
- "auto_start_up" : CWMServiceStart::CreateAutoStartWidget ($[
- "get_service_auto_start" : IscsiLioServer::GetStartService,
- "set_service_auto_start" : IscsiLioServer::SetStartService,
- // radio button (starting iscsitarget service - option 1)
- "start_auto_button" : _("When &Booting"),
- // radio button (starting LIO target service - option 2)
- "start_manual_button" : _("&Manually"),
- "help" : sformat (CWMServiceStart::AutoStartHelpTemplate (),
- // part of help text, used to describe radiobuttons
(matching starting LIO target service but without "&")
- _("When Booting"),
- // part of help text, used to describe radiobuttons
(matching starting LIO target service but without "&")
- _("Manually")
+map<string, map <string, any> > widgets =
+ $[
+ "auto_start_up" :
+ CWMServiceStart::CreateAutoStartWidget ($[
+ "get_service_auto_start" : IscsiLioServer::GetStartService,
+ "set_service_auto_start" : IscsiLioServer::SetStartService,
+ // radio button (starting iscsitarget service - option 1)
+ "start_auto_button" : _("When &Booting"),
+ // radio button (starting LIO target service - option 2)
+ "start_manual_button" : _("&Manually"),
+ "help" : sformat (CWMServiceStart::AutoStartHelpTemplate (),
+ // part of help text, used to describe radiobuttons (matching
starting LIO target service but without "&")
+ _("When Booting"),
+ // part of help text, used to describe radiobuttons (matching
starting LIO target service but without "&")
+ _("Manually")
),
]),
- // firewall
- "firewall" : CWMFirewallInterfaces::CreateOpenFirewallWidget ($[
- "services" : [ "service:iscsitarget" ],
- "display_details" : true,
+ // firewall
+ "firewall" : CWMFirewallInterfaces::CreateOpenFirewallWidget ($[
+ "services" : [ "service:iscsitarget" ],
+ "display_details" : true,
]),
- "save" : $[
+ "save" : $[
"widget" : `push_button,
"label" : Label::SaveButton(),
"handle" : saveConfiguration,
"opt": [],
"help": HELPS["save_configuration"]:""
- ],
- "isns" : $[
+ ],
+ "isns" : $[
"widget" : `custom,
"custom_widget" :
`HBox(
- `CheckBoxFrame(`id(`isns_ac), _("iSNS Access Control"), true,
- `VBox(
- `InputField(`id(`isns_ip), `opt(`hstretch), _("iSNS
Server"))
- ))
- ),
+ `CheckBoxFrame(`id(`isns_ac), _("iSNS Access Control"), true,
+ `VBox(`InputField(`id(`isns_ip), `opt(`hstretch), _("iSNS
Server"))))
+ ),
"init" : initiSNS,
"validate_type" : `function,
"validate_function" : validateiSNS,
"store" : storeiSNS
],
- // discovery authentication dialog
- "global_config" : $[
+ // discovery authentication dialog
+ "global_config" : $[
"widget" : `custom,
- "custom_widget" : tabs_descr["auth", "contents"]:nil,
+ "custom_widget" :
+ `VBox(
+ `Left( `CheckBox(`id(`auth_none),`opt(`notify), _("No
Authentication"), true) ),
+ `VSpacing(2),
+ `Left( `CheckBox(`id(`auth_in),`opt(`notify), _("Incoming
Authentication"), false) ),
+ `HBox(
+ `InputField(`id(`user_in), `opt(`hstretch),
_("Username")),
+ `Password(`id(`pass_in), _("Password"))),
+ `VSpacing(2),
+ `Left( `CheckBox(`id(`auth_out),`opt(`notify), _("Outgoing
Authentication"), false) ),
+ `HBox(
+ `InputField(`id(`user_out), `opt(`hstretch),
_("Username")),
+ `Password(`id(`pass_out), _("Password")))
+ ),
"init" : initGlobal,
"handle" : handleAuth,
"store" : storeGlobal,
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=67848&r1=67847&r2=67848&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 Mon Apr
2 18:41:37 2012
@@ -119,13 +119,9 @@
// set incoming authentication enabled/disabled status
void setAuthIn(boolean status){
y2milestone("Status of AuthIncoming %1", status);
- UI::ChangeWidget(`id(`incoming_table),`Enabled, status );
+ UI::ChangeWidget(`id(`user_in),`Enabled, status );
+ UI::ChangeWidget(`id(`pass_in),`Enabled, status );
UI::ChangeWidget(`id(`auth_in),`Value, status );
-
- UI::ChangeWidget(`id(`add),`Enabled, status );
- UI::ChangeWidget(`id(`edit),`Enabled, status );
- UI::ChangeWidget(`id(`delete),`Enabled, status );
-
if(status) UI::ChangeWidget(`id(`auth_none),`Value, !status );
}
@@ -139,25 +135,24 @@
}
// get values for incoming authentication
-list<string> getIncomingValues(){
- list <string> values = [];
- if ((boolean)UI::QueryWidget(`id(`auth_in), `Value) == true){
- integer count = -1;
- while (count<size(inc_auth)-1){
- count = count+1;
- values=add(values, sformat("%1 %2", inc_auth[count, "USER"]:"",
inc_auth[count, "PASS"]:""));
- }
- return values;
- } else return [];
-}
+list<string> getIncomingValues()
+ {
+ list<string> values = [];
+ if ((boolean)UI::QueryWidget(`id(`auth_in), `Value) == true)
+ values = [ (string)UI::QueryWidget(`id(`user_in), `Value),
+ (string)UI::QueryWidget(`id(`pass_in), `Value) ];
+ return values;
+ }
// get values for outgoing authentication
-string getOutgoingValues(){
- if ((boolean)UI::QueryWidget(`id(`auth_out), `Value) == true){
- string values = sformat("%1 %2", UI::QueryWidget(`id(`user_out), `Value),
UI::QueryWidget(`id(`pass_out), `Value) );
- return values;
- } else return "";
-}
+list<string> getOutgoingValues()
+ {
+ list<string> values = [];
+ if ((boolean)UI::QueryWidget(`id(`auth_out), `Value) == true)
+ values = [ (string)UI::QueryWidget(`id(`user_out), `Value),
+ (string)UI::QueryWidget(`id(`pass_out), `Value) ];
+ return values;
+ }
// dialog to add/modify user and password
list <string> getDialogValues(string user, string pass){
@@ -189,29 +184,29 @@
}
-symbol saveConfiguration(string key, map event){
- if (is(event["ID"]:nil, string) && event["ID"]:"" == "save"){
+symbol saveConfiguration(string key, map event)
+ {
+ y2milestone( "saveConfiguration key:%1 event:%2", key, event );
+ if( is(event["ID"]:nil, string) && event["ID"]:"" == "save")
+ {
any filename = UI::AskForSaveFileName("/", "*", _("Save as..."));
if ( filename != nil && (string)filename!="")
- {
- if ( IscsiServerFunctions::SaveIntoFile( (string)filename ))
{
+ if( IscsiServerFunctions::SaveIntoFile( (string)filename ))
+ {
Popup::Message(sformat(_("File %1 was saved successfully."),
filename));
list pathComponents = splitstring( (string)filename, "/");
integer s = size(pathComponents) - 1;
string base = pathComponents[s]:"default";
- }
+ }
else
- {
+ {
Popup::Warning(_("An error occurred while saving the file."));
+ }
}
}
- }
- return nil;
-}
-
-
-
+ return nil;
+ }
// **************** Server Dialog *********************
// dialog with targets
@@ -331,150 +326,95 @@
// **************** Global Dialog *********************
-void initGlobalValues(list<map<string, any> > values){
- setAuthIn(false);
- setAuthOut(false);
- string user = "";
- string pass = "";
- // incoming authentication
- inc_auth = $[];
- integer count = 0;
- foreach(map<string,any> auth, values, {
- if (auth["KEY"]:"" == "IncomingUser") {
- user = splitstring(auth["VALUE"]:"", " ")[0]:"";
- pass = splitstring(auth["VALUE"]:"", " ")[1]:"";
- inc_auth[count] = $["USER":user, "PASS":pass];
- count = count + 1;
- setAuthIn(true);
- }
- if (auth["KEY"]:"" == "OutgoingUser") {
- UI::ChangeWidget(`id(`user_out), `Value, splitstring(auth["VALUE"]:"",
" ")[0]:"");
- UI::ChangeWidget(`id(`pass_out), `Value, splitstring(auth["VALUE"]:"",
" ")[1]:"");
- setAuthOut(true);
+void initGlobalValues(map auth)
+ {
+ string user = "";
+ string pass = "";
+ // incoming authentication
+ if( size(auth["incoming"]:[])>0 );
+ {
+ 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);
+ // outgoing authentication
+ user = "";
+ pass = "";
+ if( size(auth["outgoing"]:[])>0 );
+ {
+ 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);
}
- });
- UI::ChangeWidget(`id(`incoming_table), `Items, getAuthItems() );
-}
// initialize discovery authentication or authentication for given target
void initGlobal (string key)
{
if (size(curr_target)>0)
- initGlobalValues(IscsiServerFunctions::getConfig()[curr_target]:[]);
+ initGlobalValues(IscsiLioData::GetAuth(curr_target,curr_tpg,""));
else
- initGlobalValues(IscsiServerFunctions::getConfig()["auth"]:[]);
+ initGlobalValues(IscsiLioData::GetAuth("",0,""));
}
// save discovery authentication or authentication for given target
-void storeGlobal(string option_id, map option_map){
- if (size(curr_target)>0){
-
- IscsiServerFunctions::setTargetAuth( curr_target, getIncomingValues(),
getOutgoingValues() );
- IscsiServerFunctions::saveNewTarget(curr_target);
-
- } else{
- IscsiServerFunctions::setAuth( getIncomingValues(), getOutgoingValues()
);
- }
-}
+void storeGlobal(string option_id, map option_map)
+ {
+ y2milestone( "storeGlobal id:%1 map:%2", option_id, option_map );
+ boolean ret = false;
+ if(size(curr_target)>0)
+ {
+ ret = IscsiLioData::SetAuth( curr_target, curr_tpg, "",
getIncomingValues(), getOutgoingValues() );
+ }
+ else
+ {
+ ret = IscsiLioData::SetAuth( "", 0, "", getIncomingValues(),
getOutgoingValues() );
+ }
+ if( !ret )
+ {
+ Popup::Error( _("Problem changing authentication"));
+ }
+ IscsiLioData::UpdateConfig();
+ }
// validate functions checks the secret for incoming and outgoing cannot be
same
-boolean validateGlobal(string key, map event){
- boolean ret=false;
- if (!contains(getIncomingValues(), getOutgoingValues())) ret=true;
- else Popup::Error(_("Cannot use the same secret for incoming and
outgoing authentication."));
- return ret;
-}
+boolean validateGlobal(string key, map event)
+ {
+ boolean ret=true;
+ return ret;
+ }
// **************** Target Auth *******************
// handle authentication dialog
-symbol handleAuth(string key, map event){
- if (event["EventReason"]:"" == "ValueChanged"){
- boolean status = false;
-// enable/disable none/incoming/outgoing authentication
- switch((symbol)event["ID"]:nil){
- case(`auth_none):
+symbol handleAuth(string key, map event)
+ {
+ if (event["EventReason"]:"" == "ValueChanged")
+ {
+ boolean status = false;
+ // enable/disable none/incoming/outgoing authentication
+ switch((symbol)event["ID"]:nil)
+ {
+ case(`auth_none):
status = (boolean)UI::QueryWidget(`id(`auth_none), `Value);
setAuthIn(!status);
setAuthOut(!status);
break;
- case(`auth_in):
+ case(`auth_in):
status = (boolean)UI::QueryWidget(`id(`auth_in), `Value);
setAuthIn(status);
break;
- case(`auth_out):
+ case(`auth_out):
status = (boolean)UI::QueryWidget(`id(`auth_out), `Value);
setAuthOut(status);
break;
- }
- }
-// add/edit/delete incoming authentication
- if (event["EventReason"]:"" == "Activated"){
- switch((symbol)event["ID"]:nil){
- case(`add) :
- list<string> values = getDialogValues("", "");
- y2milestone("Add authentication values");
- if (size(values)==2 ){
- string user = values[0]:"";
- string pass = values[1]:"";
- integer count = size((list)UI::QueryWidget(`id
(`incoming_table),`Items));
-
- inc_auth[size(inc_auth)]= $["USER":user, "PASS":pass];
- UI::ChangeWidget (`id (`incoming_table), `Items,
getAuthItems());
- }
-
- break;
- case(`edit) :
- integer curr = tointeger( UI::QueryWidget(`id
(`incoming_table),`CurrentItem) );
- y2milestone("Modify authentication values");
- if (curr!=nil){
- string user = inc_auth[curr, "USER"]:"";
- string pass = inc_auth[curr, "PASS"]:"";
- list<string> values = getDialogValues(user, pass);
-
- if (size(values)==2 ){
- string user = values[0]:"";
- string pass = values[1]:"";
-
- list<term> rows = (list<term>)UI::QueryWidget(`id
(`incoming_table),`Items);
- inc_auth[curr] = $["USER":user, "PASS":pass];
- UI::ChangeWidget (`id (`incoming_table), `Items,
getAuthItems());
- }
-
- }
- break;
- case(`delete) :
- any del = UI::QueryWidget(`id (`incoming_table),`CurrentItem);
- y2milestone("Delete authentication value");
- if (del != nil){
- if (Popup::ContinueCancel(_("Really delete the selected
item?")))
- {
- integer count = 0;
- map<integer, any> temp_map = $[];
- while(count<size(inc_auth))
- {
- if (count<del)
- temp_map[count]=inc_auth[count]:nil;
- else if (count>del)
- temp_map[count-1]=inc_auth[count]:nil;
- count = count+1;
- }
- inc_auth = temp_map;
- UI::ChangeWidget(`id(`incoming_table), `Items,
getAuthItems());
- } else y2milestone("Delete canceled");
- }
- break;
- }
- }
- if (size((list)UI::QueryWidget(`incoming_table, `Items))==0){
- UI::ChangeWidget(`edit, `Enabled, false);
- UI::ChangeWidget(`delete, `Enabled, false);
- } else {
- UI::ChangeWidget(`edit, `Enabled, true);
- UI::ChangeWidget(`delete, `Enabled, true);
- }
-
- return nil;
-}
+ }
+ }
+ return nil;
+ }
// **************** Edit Dialog *****************************
--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx
| < Previous | Next > |