Mailinglist Archive: yast-commit (883 mails)

< Previous Next >
[yast-commit] r57863 - /trunk/isns/src/widgets.ycp
  • From: mzugec@xxxxxxxxxxxxxxxx
  • Date: Fri, 03 Jul 2009 10:55:34 -0000
  • Message-id: <E1MMgQY-0001ZO-2d@xxxxxxxxxxxxxxxx>
Author: mzugec
Date: Fri Jul 3 12:55:33 2009
New Revision: 57863

URL: http://svn.opensuse.org/viewcvs/yast?rev=57863&view=rev
Log:
added widgets.ycp

Added:
trunk/isns/src/widgets.ycp

Added: trunk/isns/src/widgets.ycp
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/isns/src/widgets.ycp?rev=57863&view=auto
==============================================================================
--- trunk/isns/src/widgets.ycp (added)
+++ trunk/isns/src/widgets.ycp Fri Jul 3 12:55:33 2009
@@ -0,0 +1,625 @@
+{
+
+textdomain "isns";
+import "Label";
+import "IsnsServer";
+import "String";
+import "Report";
+
+string address = ""; //global
+
+void initDiscoveryDomainSetMembers (string key);
+void initDiscoveryDomain (string key);
+void initDDISCSIMembers (string key);
+void initISCSI (string key);
+void initDiscoveryDomainPotentialISCSI (string dd_id);
+void initDiscoveryDomainPotential (string key);
+void getInputX1 (string dd_name, string dd_id);
+integer checkISNS();
+
+// **************** global funcions and variables *****
+map <string, any> DiscoveryDomainDetailDialog(map<string, any> values_before){
+ map <string, any> ret_map = $[];
+ term dd_dialog =
+ `VBox(
+ `Heading("Create New Discovery Domain"),
+ `HSpacing(50),
+ `HWeight(3,`TextEntry( `id( `ddentry ), _("Discovery Domain Name" ))) ,
+ `VSpacing(1),
+ `HBox(
+ `HSpacing(3),
+ `VBox(
+ `Label(_("Select Discovery Domain Set to which Discovery Domain
will be added.")),
+ `SelectionBox( `id( `ddsentries), _("Discovery Domain Name Set") )
+ ),
+ `HSpacing(3)
+ ),
+ `VSpacing(1),
+ `HBox( `PushButton(`id(`ok), Label::OKButton() ),
`PushButton(`id(`cancel), Label::CancelButton() )),
+ `VSpacing(1)
+ );
+ UI::OpenDialog(dd_dialog);
+
+ list <term> inc_items = [];
+ integer count = 0;
+ string index = "";
+ string first = "";
+ foreach(string ddsentry, IsnsServer::readDDS(address), {
+ if (count == 0)
+ {
+ index = ddsentry;
+ count = 1;
+ }
+ else
+ {
+ inc_items = add(inc_items, `item(`id(index), ddsentry) );
+ count = 0;
+ if (first == "")
+ first = ddsentry;
+ }
+ });
+
+ UI::ChangeWidget(`id(`ddsentries), `Items, inc_items);
+ UI::ChangeWidget(`id(`ddsentries), `CurrentItem, first);
+
+ symbol ret = `nil;
+ while(ret != `ok && ret !=`cancel){
+ boolean enable=false;
+ ret = (symbol)UI::UserInput();
+ }
+
+ if (ret == `cancel) ret_map = $[];
+ else {
+ string dd_name = (string)UI::QueryWidget(`ddentry,`Value);
+
+ string dds_id = (string)UI::QueryWidget(`id
(`ddsentries),`CurrentItem);
+ y2milestone ("creating dd add to dds: %1",dds_id);
+ IsnsServer::addDD(address, dd_name );
+
+ integer count = 0;
+ string dd_index = "";
+ foreach(string dd, IsnsServer::readDD(address), {
+ if (count == 0)
+ {
+ dd_index = dd;
+ count = 1;
+ }
+ else
+ {
+ if ( dd == dd_name)
+ {
+ IsnsServer::addDDSMember(address, dds_id, dd_index);
+ }
+ count = 0;
+ }
+ });
+
+ ret_map = $["VALUE":dd_name];
+ }
+ UI::CloseDialog();
+ return ret_map;
+}
+
+map <string, any> DiscoveryDomainSetDetailDialog(map<string, any>
values_before){
+ map <string, any> ret_map = $[];
+ term dds_dialog =
+ `HBox(
+ `HSpacing(5),
+ `VBox(
+ `VSpacing(1),
+ `Left( `HWeight(3,`TextEntry( `id( `ddsentry ), _("Discovery Domain Set
Name") )) ),
+ `Left( `HBox( `PushButton(`id(`ok), Label::OKButton() ),
`PushButton(`id(`cancel), Label::CancelButton() ))),
+ `VSpacing(1)
+ ),
+ `HSpacing(5)
+ );
+ UI::OpenDialog(dds_dialog);
+
+ symbol ret = `nil;
+ while(ret != `ok && ret !=`cancel){
+ boolean enable=false;
+ ret = (symbol)UI::UserInput();
+ }
+
+ if (ret == `cancel) ret_map = $[];
+ else {
+ string value=(string)UI::QueryWidget(`ddsentry,`Value);
+ ret_map = $["VALUE":value];
+ }
+ UI::CloseDialog();
+ return ret_map;
+}
+
+map <string, any> CreateNode(map<string, any> values_before){
+ map <string, any> ret_map = $[];
+ term node_dialog =
+ `HBox(
+ `HSpacing(5),
+ `VBox(
+ `VSpacing(1),
+ `Left( `HWeight(3,`TextEntry( `id( `nodeentry ), `opt(`hstretch),
_("iSCSI Node Name"))) ),
+ `Left( `HBox( `PushButton(`id(`ok), Label::OKButton() ),
`PushButton(`id(`cancel), Label::CancelButton() ))),
+ `VSpacing(1)
+ ),
+ `HSpacing(5)
+ );
+
+ UI::OpenDialog(node_dialog);
+
+ symbol ret = `nil;
+ while(ret != `ok && ret !=`cancel){
+ boolean enable=false;
+ ret = (symbol)UI::UserInput();
+ }
+
+ if (ret == `cancel) ret_map = $[];
+ else {
+ string value=(string)UI::QueryWidget(`nodeentry,`Value);
+ ret_map = $["VALUE":value];
+ }
+ UI::CloseDialog();
+ return ret_map;
+}
+
+
+map <string, any> DisplayAllMembersDialog(string dd_name, string dd_id){
+ map <string, any> ret_map = $[];
+ term iscsi_member_dialog =
+ `VBox(
+ `Heading(_("Add iSCSI node to Discovery Domain")),
+ `Label(dd_name),
+ `HSpacing(100),
+ `Heading (_("Available Nodes to Add")),
+ `HBox(
+ `VSpacing(10),
+ `Table(`id(`members_table),
+ `header(_("Name"),_("Node Type")),
+ [])
+ ),
+ `Left(
+ `HBox(
+ `PushButton(`id(`add), _("Add Node")),
+ `PushButton(`id(`exit), _("Done"))
+ )
+ )
+ );
+ UI::OpenDialog(iscsi_member_dialog);
+
+ initDiscoveryDomainPotentialISCSI (dd_id);
+
+ symbol ret = `nil;
+ while(ret != `exit ) {
+ boolean enable=false;
+ ret = (symbol)UI::UserInput();
+ if (ret == `add)
+ {
+ y2milestone("Add a node");
+ any index = UI::QueryWidget(`id (`members_table),`CurrentItem);
+ string iqn =
((term)UI::QueryWidget(`id(`members_table),`Item(index)))[1]:"";
+ IsnsServer::addDDMember(address,dd_id,iqn);
+ initDiscoveryDomainPotentialISCSI (dd_id);
+ }
+ }
+
+ UI::CloseDialog();
+ return ret_map;
+}
+
+map <string, any> DisplayAllDiscoveryDomainsDialog(string dds_name, string
dds_id){
+ map <string, any> ret_map = $[];
+ term dds_dialog =
+ `VBox(
+ `Heading(_("Add Discovery Domain to Set")),
+ `Label(dds_name),
+ `HSpacing(50),
+ `Heading (_("Avaliable Discovery Domains")),
+ `HBox(
+ `VSpacing(10),
+ `Table(`id(`dd_table),
+ `header(_("Name")),
+ [])
+ ),
+ `Left(
+ `HBox(
+ `PushButton(`id(`add), _("Add Discovery Domain")),
+ `PushButton(`id(`exit), _("Done"))
+ )
+ )
+ );
+ UI::OpenDialog(dds_dialog);
+
+ initDiscoveryDomainPotential (dds_id);
+
+ symbol ret = `nil;
+ while(ret != `exit) {
+ boolean enable=false;
+ ret = (symbol)UI::UserInput();
+ if (ret == `add)
+ {
+ y2milestone("Add a dds member");
+ string dd_id = (string)UI::QueryWidget(`id
(`dd_table),`CurrentItem);
+ IsnsServer::addDDSMember(address,dds_id,dd_id);
+ initDiscoveryDomainPotential (dds_id);
+ }
+ }
+
+ UI::CloseDialog();
+ return ret_map;
+}
+
+
+void initAddress (string key){
+ address = ((map<string, any>)SCR::Execute(.target.bash_output,"cat
/etc/isns.conf|cut -d'=' -f2|tr -d '\n'"))["stdout"]:"";
+ UI::ChangeWidget(`isnsaddress, `Value, address);
+}
+
+void initISCSI (string key){
+ integer count = 0;
+ string type = _("Target or Initiator");
+ list <term> inc_items = [];
+
+ checkISNS();
+
+ foreach(map <string,any> key, IsnsServer::readISCSI(address), {
+ inc_items = add(inc_items, `item(`id(count),
key["NODE"]:"",key["TYPE"]:""));
+ count = count + 1;
+ });
+
+ UI::ChangeWidget(`id(`members_table), `Items, inc_items);
+}
+
+void initDiscoveryDomainPotentialISCSI (string key){
+ integer count = 0;
+ string type = _("Target or Initiator");
+ list <term> inc_items = [];
+ string iscsinode="";
+ list <map <string,any> > ddmembers= [];
+ string found="FALSE";
+
+ ddmembers = IsnsServer::readDDMembers(address, key);
+
+ foreach(map <string,any> iscsinode, IsnsServer::readISCSI(address), {
+ found = "FALSE";
+ foreach(map <string,any> ddmember, ddmembers, {
+ if ( ddmember["NODE"]:"" == iscsinode["NODE"]:"" )
+ found = "TRUE";
+ });
+
+ if ( found == "FALSE" )
+ {
+ inc_items = add(inc_items, `item(`id(count),
iscsinode["NODE"]:"",iscsinode["TYPE"]:""));
+ count = count + 1;
+ }
+ });
+
+ UI::ChangeWidget(`id(`members_table), `Items, inc_items);
+}
+
+void initDDISCSIMembers (string key) ``{
+ integer count = 0;
+ string index="";
+ string ddid="";
+ list <term> inc_items = [];
+
+ y2milestone("initDDISCSIMembers key is:%1",key);
+ if ( key == "dd_display_members" )
+ key = (string)UI::QueryWidget(`id(`dd_table),`CurrentItem);
+
+ ddid=key;
+ foreach(map <string,any> result, IsnsServer::readDDMembers(address,ddid), {
+ y2milestone("iscsiMembers: %1",key);
+ inc_items = add(inc_items, `item(`id(count),
result["NODE"]:"",result["TYPE"]:""));
+ count = count +1;
+ });
+
+ UI::ChangeWidget(`id(`dd_members_table), `Items, inc_items);
+}
+
+void initDiscoveryDomain (string key) ``{
+ integer count = 0;
+ string index="";
+ list <term> inc_items = [];
+
+ checkISNS();
+
+ foreach(string dd, IsnsServer::readDD(address), {
+ if (count == 0)
+ {
+ index = dd;
+ count = 1;
+ }
+ else
+ {
+ inc_items = add(inc_items, `item(`id(index), dd));
+ count = 0;
+ }
+ });
+
+ UI::ChangeWidget(`id(`dd_table), `Items, inc_items);
+}
+
+void initDiscoveryDomainPotential (string key) ``{
+ integer count = 0;
+ string index="";
+ list <term> inc_items = [];
+ list <string> ddsmembers= [];
+ string found = "FALSE";
+
+ ddsmembers = IsnsServer::readDDSMembers(address, key);
+
+ foreach(string dd, IsnsServer::readDD(address), {
+ if (count == 0)
+ {
+ index = dd;
+ count = 1;
+ }
+ else
+ {
+ found = "FALSE";
+ foreach(string ddsmember, ddsmembers, {
+ if ( ddsmember == dd )
+ found = "TRUE";
+ });
+
+ if ( found == "FALSE" )
+ {
+ inc_items = add(inc_items, `item(`id(index), dd));
+ }
+ count = 0;
+ }
+ });
+
+ UI::ChangeWidget(`id(`dd_table), `Items, inc_items);
+}
+
+void initDiscoveryDomainSet (string key) ``{
+ integer count = 0;
+ string index="";
+
+ list <term> inc_items = [];
+
+ y2milestone("isnsaddress is %1",address);
+
+ checkISNS();
+
+ foreach(string key, IsnsServer::readDDS(address), {
+ if (count == 0)
+ {
+ index = key;
+ count = 1;
+ }
+ else
+ {
+ inc_items = add(inc_items, `item(`id(index), key));
+ count = 0;
+ }
+ });
+
+ UI::ChangeWidget(`id(`dds_table), `Items, inc_items);
+
+}
+
+void initDiscoveryDomainSetMembers (string key) {
+ integer count = 0;
+ string index="";
+ list <term> inc_items = [];
+ string dds_id = "";
+
+ if ( key == "dds_display_members" )
+ key = (string)UI::QueryWidget(`id(`dds_table),`CurrentItem);
+
+ dds_id = key;
+
+ foreach(string key, IsnsServer::readDDSMembers(address,dds_id), {
+ y2milestone("results received: %1",key);
+ if (count == 0)
+ {
+ index = key;
+ count = 1;
+ }
+ else
+ {
+ inc_items = add(inc_items, `item(`id(index), key));
+ count = 0;
+ }
+ });
+
+ UI::ChangeWidget(`id(`dds_members_table), `Items, inc_items);
+}
+
+
+symbol handleAddress(string key, map event){
+ address=(string)UI::QueryWidget(`isnsaddress,`Value);
+ SCR::Execute(.target.bash_output, sformat("echo
\"isns_address=%1\">/etc/isns.conf",address));
+ y2milestone("isnsaddress is %1",address);
+ return nil;
+}
+
+
+symbol handleISCSI(string key, map event){
+ if ( event["EventReason"]:"" == "Activated" ){
+ switch((symbol)event["WidgetID"]:nil){
+ case `delete:
+ any del = UI::QueryWidget(`id (`members_table),`CurrentItem);
+ if (del != nil)
+ {
+ if (Popup::ContinueCancel(_("Really delete the selected item?")))
+ {
+ string discoverydomainsetname =
((term)UI::QueryWidget(`id(`members_table), `Item(del)))[1]:"";
+ IsnsServer::deleteISCSI(address,discoverydomainsetname);
+ initISCSI ("");
+ }
+ else
+ y2milestone("Delete canceled");
+ }
+ break;
+ }
+ }
+}
+
+symbol handleDiscoveryDomain(string key, map event){
+
+ if ( event["EventReason"]:"" == "SelectionChanged" ){
+ y2milestone("selectionChangedEvent");
+ string dd_id = (string)UI::QueryWidget(`id(`dd_table),`CurrentItem);
+ y2milestone("selectionChangedEvent - dd-id:%1",dd_id);
+ initDDISCSIMembers(dd_id);
+ }
+
+ else if ( event["EventReason"]:"" == "Activated" ){
+ y2milestone("handleDiscoveryDomainCalled:Activated");
+ switch((symbol)event["WidgetID"]:nil){
+ case `delete:
+ string del = (string)UI::QueryWidget(`id (`dd_table),`CurrentItem);
+ if (del != nil)
+ {
+ if (Popup::ContinueCancel(_("Really delete this domain?")))
+ {
+ IsnsServer::deleteDD(address,del);
+ initDiscoveryDomain ("");
+ }
+ else
+ y2milestone("Delete canceled");
+ }
+ break;
+ case `add:
+ map<string, any> add_map = DiscoveryDomainDetailDialog($["VALUE":""]);
+ if (add_map!=$[])
+ {
+ // IsnsServer::addDD(address, add_map["VALUE"]:"");
+ initDiscoveryDomain ("");
+ }
+ break;
+ }
+ }
+}
+
+symbol handleDiscoveryDomainSet(string key, map event){
+ string mycurrent = (string)UI::QueryWidget(`id (`dds_table),`CurrentItem);
+ y2milestone("handleDiscoveryDomainSet action called: %1 -- %2 -- %3", key,
event, mycurrent);
+
+ if ( event["EventReason"]:"" == "SelectionChanged" ){
+ y2milestone("selectionChangedEvent");
+ string dds_id = (string)UI::QueryWidget(`id(`dds_table),`CurrentItem);
+ y2milestone("selectionChangedEvent - dds-id:%1",dds_id);
+ initDiscoveryDomainSetMembers(dds_id);
+ }
+
+ if ( event["EventReason"]:"" == "Activated" ){
+ switch((symbol)event["WidgetID"]:nil){
+ case `delete:
+ string del = (string)UI::QueryWidget(`id (`dds_table),`CurrentItem);
+ if (del != nil){
+ if (Popup::ContinueCancel(_("Really delete the selected item?"))) {
+ IsnsServer::deleteDDS(address,del);
+ initDiscoveryDomainSet ("");
+ }
+ else
+ y2milestone("Delete canceled");
+ }
+ break;
+ case `add:
+ map<string, any> add_map = DiscoveryDomainSetDetailDialog($["VALUE":""]);
+ if (add_map!=$[]){
+ IsnsServer::addDDS(address, add_map["VALUE"]:"");
+ initDiscoveryDomainSet ("");
+ }
+ break;
+ }
+ }
+}
+
+}
+
+symbol handleDiscoveryDomainMembers(string key, map event)
+{
+ if ( event["EventReason"]:"" == "Activated" ){
+ switch((symbol)event["WidgetID"]:nil){
+ case `delete:
+ {
+ // domain deleted, but we get this event so update the members
table
+ string dd_id =
(string)UI::QueryWidget(`id(`dd_table),`CurrentItem);
+ initDDISCSIMembers (dd_id);
+ break;
+ }
+ case `remove:
+ {
+ any iqn = UI::QueryWidget(`id (`dd_members_table),`CurrentItem);
+ string dd_name =
((term)UI::QueryWidget(`id(`dd_members_table),`Item(iqn)))[1]:"";
+ string dd_id =
(string)UI::QueryWidget(`id(`dd_table),`CurrentItem);
+ IsnsServer::deleteDDMember(address,dd_id,dd_name);
+ initDDISCSIMembers (dd_id);
+ break;
+ }
+ case `addiscsinode:
+ {
+ string dd_id =
(string)UI::QueryWidget(`id(`dd_table),`CurrentItem);
+ string dd_name =
((term)UI::QueryWidget(`id(`dd_table),`Item(dd_id)))[1]:"";
+ map<string, any> add_map1 =
DisplayAllMembersDialog(dd_name,dd_id);
+ initDDISCSIMembers (dd_id);
+ break;
+ }
+ case `createmember:
+ {
+ string dd_id =
(string)UI::QueryWidget(`id(`dd_table),`CurrentItem);
+ string dd_name =
((term)UI::QueryWidget(`id(`dd_table),`Item(dd_id)))[1]:"";
+
+ map<string, any> add_map = CreateNode($["VALUE":""]);
+ if (add_map!=$[]){
+ IsnsServer::addDDMember (address, dd_id,
add_map["VALUE"]:"");
+ }
+
+ initDDISCSIMembers (dd_id);
+
+ break;
+ }
+ }
+ }
+}
+
+symbol handleDiscoveryDomainSetMembers(string key, map event)
+{
+ if ( event["EventReason"]:"" == "Activated" ){
+ switch((symbol)event["WidgetID"]:nil){
+ case `delete:
+ {
+ // domain Set deleted, but we get this event so update the
members table
+ string dds_id =
(string)UI::QueryWidget(`id(`dds_table),`CurrentItem);
+ initDiscoveryDomainSetMembers (dds_id);
+ break;
+ }
+ case `remove:
+ {
+ y2milestone("Unassign a dds member");
+ string dds_id =
(string)UI::QueryWidget(`id(`dds_table),`CurrentItem);
+ string dd_id = (string)UI::QueryWidget(`id
(`dds_members_table),`CurrentItem);
+ IsnsServer::deleteDDSMember(address,dds_id,dd_id);
+ initDiscoveryDomainSetMembers (dds_id);
+ break;
+ }
+ case `adddd:
+ {
+ y2milestone("Add a dds member");
+ string dds_id =
(string)UI::QueryWidget(`id(`dds_table),`CurrentItem);
+ string dds_name =
((term)UI::QueryWidget(`id(`dds_table),`Item(dds_id)))[1]:"";
+ map<string, any> add_map1 =
DisplayAllDiscoveryDomainsDialog(dds_name,dds_id);
+ initDiscoveryDomainSetMembers (dds_id);
+ break;
+ }
+ }
+ }
+}
+
+integer checkISNS()
+{
+ string isns_status = IsnsServer::testISNSAccess(address);
+ if (isns_status != "OK")
+ {
+// boolean display = true;
+// Report::DisplayErrors(display,10);
+ Report::Error(_("Unable to connection to iSNS server. Check iSNS
server address"));
+ return 1;
+ }
+
+ return 0;
+}

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

< Previous Next >
This Thread
  • No further messages