[yast-commit] r63935 - in /trunk/fcoe-client/src: FcoeClient.ycp complex.ycp dialogs.ycp wizards.ycp
Author: gs Date: Tue May 10 15:41:30 2011 New Revision: 63935 URL: http://svn.opensuse.org/viewcvs/yast?rev=63935&view=rev Log: get/set/adjust status of services Modified: trunk/fcoe-client/src/FcoeClient.ycp trunk/fcoe-client/src/complex.ycp trunk/fcoe-client/src/dialogs.ycp trunk/fcoe-client/src/wizards.ycp Modified: trunk/fcoe-client/src/FcoeClient.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/fcoe-client/src/FcoeClient.ycp?rev=63935&r1=63934&r2=63935&view=diff ============================================================================== --- trunk/fcoe-client/src/FcoeClient.ycp (original) +++ trunk/fcoe-client/src/FcoeClient.ycp Tue May 10 15:41:30 2011 @@ -42,6 +42,7 @@ import "Mode"; import "Package"; import "Popup"; +import "Service"; /** * Prototypes @@ -124,21 +125,42 @@ AbortFunction = function; } +/* + from IscsiClientLib.ycp (line 53) - reading output + + string from_bios = ((map<string, any>)SCR::Execute(.target.bash_output, "iscsiadm -m fw"))["stdout"]:""; + foreach(string row, splitstring(from_bios, "\n"), { + list<string> key_val=splitstring(row, "="); +// if (size(key_val[0]:"")>0) ibft[key_val[0]:""] = key_val[1]:""; + string kv = String::CutBlanks(key_val[0]:""); + if (size(kv) > 0) ibft[kv] = String::CutBlanks(key_val[1]:""); + }); + */ + + // Settings: Define all variables needed for configuration of fcoe-client // Define all the variables necessary to hold -global integer current_card = 0; // currently selected card, means row in list of cards +global integer current_card = 0; // currently selected card, means row in list of cards global string NOT_CONFIGURED = "not configured"; global string NOT_AVAILABLE = "not available"; -// map containing information about networks cards and VLAN, FCoE aand DCB status +// map containing information about networks cards and VLAN, FCoE and DCB status map <integer, list> network_interfaces = $[]; // map containing information about values in /etc/fcoe/config -map <string, string> fcoe_general_config = $[]; +map <string, string> fcoe_general_config = $[ "DEBUG":"no", + "USE_SYSLOG":"yes" ]; + +// list containing information about 'redo' commands +list <string> redo_list = []; + +// map containing information about start of services +map <string, boolean> service_start = $[ "fcoe":false, + "lldpad":false ]; // // Check whether open-fcoe is installed and do installation if user agrees @@ -289,7 +311,7 @@ } list <string> lines = splitstring( content, "\n" ); - + // TODO: better/more elegant way of reading values (use SysConfig agent?) foreach( string line, (list<string>)lines, { if ( regexpmatch( line, "^FCOE_ENABLE" ) ) { @@ -353,11 +375,50 @@ } // +// Set status of services // +global void AdjustStatusOfServices( ) +{ + y2milestone( "Setting start of /etc/init.d/fcoe to %1", service_start["fcoe"]:false ); + if ( service_start["fcoe"]:false == true ) + Service::Enable("fcoe"); + else + Service::Disable("open-fcoe"); + + y2milestone( "Setting start of /etc/init.d/lldpad to %1", service_start["lldpad"]:false ); + if ( service_start["lldpad"]:false == true ) + Service::Enable("lldpad"); + else + Service::Disable("lldpad"); + +} + +global void SetServiceStatus( string service, boolean status ) +{ + y2milestone( "Setting status of %1 to %2", service, status ); + service_start[ service ] = status; +} + // -void CheckServices() +// Get status of services +// +void DetectStatusOfServices() { + boolean status = false; + status = Service::Enabled( "fcoe" ); + y2milestone( "Status of fcoe: %1", status ); + service_start = add( service_start, "fcoe", status ); + + status = Service::Enabled( "lldpad" ); + y2milestone( "Status of lldpad: %1", status ); + service_start = add( service_start, "lldpad", status ); + +} + +global map<string, boolean> GetServiceStatus() +{ + return service_start; } // @@ -458,6 +519,23 @@ return fcoe_general_config; } +// +// Add a command to the list of redo commands +// +global void AddRedoCommand( string command ) +{ + redo_list = add( redo_list, command ); + y2milestone( "Adding redo command: %1", command ); +} + +// +// Get the list of redo commands +// +global list GetRedoCommands() +{ + return redo_list; +} + /** * Read all fcoe-client settings * @return true on success @@ -514,7 +592,7 @@ Progress::NextStage(); // check daemon fcoemon and lldpad - CheckServices(); + DetectStatusOfServices(); /* Error message */ if(false) Report::Error(_("Checking for services failed")); Modified: trunk/fcoe-client/src/complex.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/fcoe-client/src/complex.ycp?rev=63935&r1=63934&r2=63935&view=diff ============================================================================== --- trunk/fcoe-client/src/complex.ycp (original) +++ trunk/fcoe-client/src/complex.ycp Tue May 10 15:41:30 2011 @@ -36,6 +36,7 @@ import "Wizard_hw"; import "Confirm"; import "FcoeClient"; +import "Service"; include "fcoe-client/helps.ycp"; @@ -85,6 +86,19 @@ * Init **/ void InitServicesDialog (string id) { + + map status_map = FcoeClient::GetServiceStatus(); + + if ( status_map["fcoe"]:false == true ) + { + UI::ChangeWidget( `id( "fcoe_startup_auto" ), `Value, true ); + UI::ChangeWidget( `id( "fcoe_startup_manual" ), `Value, false ); + } + else + { + UI::ChangeWidget( `id( "fcoe_startup_auto" ), `Value, false ); + UI::ChangeWidget( `id( "fcoe_startup_manual" ), `Value, true ); + } y2milestone( "Init services dialog" ); } @@ -264,7 +278,12 @@ UI::ChangeWidget( `id( `interfaces), `Cell( FcoeClient::current_card, 4), status_map["FCOE_ENABLE"]:"" ); UI::ChangeWidget( `id( `interfaces), `Cell( FcoeClient::current_card, 5), status_map["DCB_REQUIRED"]:"" ); AdjustButtons(); - + if ( fcoe_vlan_interface != "" ) + { + // store command to be able to redo the creation of FCoE VLAN interface + // in case of abort + FcoeClient::AddRedoCommand( sformat("vconfig rem %1", fcoe_vlan_interface ) ); + } } else { @@ -296,8 +315,30 @@ * Store **/ -void StoreServicesDialog (string id, map event) { - y2milestone( "Store services dialog" ); +void StoreServicesDialog (string id, map event) +{ + y2milestone( "Store services dialog" ); + boolean fcoe_auto = (boolean)UI::QueryWidget( `id ("fcoe_startup_auto"), `Value ); + + if ( fcoe_auto ) + { + FcoeClient::SetServiceStatus( "fcoe", true ); + y2milestone( "Setting auto start of FCoE to true"); + } + // Check whether FCoE already running and start if required + integer status = Service::Status("fcoe"); + + if ( status != 0 ) + { + Service::Start("fcoe"); + y2milestone( "Starting FCoE (/etc/init.d/fcoe start)"); + } + else + { + y2milestone( "FCoE running"); + } + + } void StoreInterfacesDialog (string id, map event) { Modified: trunk/fcoe-client/src/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/fcoe-client/src/dialogs.ycp?rev=63935&r1=63934&r2=63935&view=diff ============================================================================== --- trunk/fcoe-client/src/dialogs.ycp (original) +++ trunk/fcoe-client/src/dialogs.ycp Tue May 10 15:41:30 2011 @@ -41,9 +41,9 @@ term items = `VBox( `VSpacing (0.4), - `Left (`RadioButton (`id ("startup_auto"), `opt (`notify), + `Left (`RadioButton (`id ("fcoe_startup_auto"), `opt (`notify), "When Booting")), - `Left (`RadioButton (`id ("startup_manual"), `opt (`notify), + `Left (`RadioButton (`id ("fcoe_startup_manual"), `opt (`notify), "Manually") ), `VSpacing (0.4) @@ -87,7 +87,7 @@ `VBox ( `VSpacing(2.0), // frame - `Frame (_("Service Start"), + `Frame (_("FCoE Service Start"), `VBox (`RadioButtonGroup (`id ("service_startup"), items)) ), `VStretch() Modified: trunk/fcoe-client/src/wizards.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/fcoe-client/src/wizards.ycp?rev=63935&r1=63934&r2=63935&view=diff ============================================================================== --- trunk/fcoe-client/src/wizards.ycp (original) +++ trunk/fcoe-client/src/wizards.ycp Tue May 10 15:41:30 2011 @@ -97,8 +97,10 @@ ]; string ini_tab = ""; - - if ( true ) // TODO: check lldpad / fcoemon running + + map <string, boolean> status_map = FcoeClient::GetServiceStatus(); + + if ( status_map["fcoe"]:false == true || status_map["lldpad"]:false == true ) ini_tab = "interfaces"; else ini_tab = "services"; -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
gs@svn2.opensuse.org