Author: gs Date: Wed Oct 5 12:54:31 2011 New Revision: 66252 URL: http://svn.opensuse.org/viewcvs/yast?rev=66252&view=rev Log: use network.scr to write sysconfig files, additionally write config for underlying interface Modified: branches/SuSE-Code-11-SP2-Branch/fcoe-client/src/FcoeClient.ycp branches/SuSE-Code-11-SP2-Branch/fcoe-client/src/complex.ycp branches/SuSE-Code-11-SP2-Branch/fcoe-client/src/fcoe-client_finish.ycp Modified: branches/SuSE-Code-11-SP2-Branch/fcoe-client/src/FcoeClient.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/fcoe-client/src/FcoeClient.ycp?rev=66252&r1=66251&r2=66252&view=diff ============================================================================== --- branches/SuSE-Code-11-SP2-Branch/fcoe-client/src/FcoeClient.ycp (original) +++ branches/SuSE-Code-11-SP2-Branch/fcoe-client/src/FcoeClient.ycp Wed Oct 5 12:54:31 2011 @@ -168,7 +168,6 @@ global boolean lldpad_started = false; // service fcoe was started global boolean fcoe_started = false; // service lldpad was started -global string ifcfg_file = ""; // Settings: Define all variables needed for configuration of fcoe-client @@ -397,7 +396,7 @@ } }); content = mergestring( lines, "\n" ); - y2milestone( "Writing content: %1", content ); + y2milestone( "Writing content: %1 to %2", content, file_name ); file_exists = SCR::Write( .target.string, file_name, content ); @@ -736,7 +735,7 @@ } // -// Write /etc/fcoe/config using SCR agent +// Write /etc/fcoe/config using fcoe_config.scr // global boolean WriteFcoeConfig() { @@ -749,13 +748,48 @@ return false; // This is very important- it flushes the cache, and stores the configuration on the disk - SCR::Write(.fcoe.config, nil); + success = SCR::Write(.fcoe.config, nil); - return true; + return success; +} + +// +// Write ifcfg-files in /etc/sysconfig/network (for FCoE VLAN interface and underlying interface) +// using network.scr from yast2/library/network +// +global boolean WriteSysconfigFiles( ) +{ + list <map> netcards = GetNetworkCards(); + boolean success = true; + + foreach ( map card, (list<map>)netcards, { + if ( card["fcoe_vlan"]:"" != FcoeClient::NOT_AVAILABLE && // FCoE VLAN is configured + card["fcoe_vlan"]:"" != FcoeClient::NOT_CONFIGURED && Modified() ) + { + y2milestone( "Writing /etc/sysconfig/network/ifcfg-%1", card["fcoe_vlan"]:"" ); + // write /etc/sysconfig/network/ifcfg-<fcoe-vlan-interface>, e.g. ifcfg-eth3.200 + SCR::Write(.network.value + card["fcoe_vlan"]:"" + "BOOTPROTO", "static" ); + SCR::Write(.network.value + card["fcoe_vlan"]:"" + "STARTMODE", "nfsroot" ); + SCR::Write(.network.value + card["fcoe_vlan"]:"" + "ETHERDEVICE", card["dev_name"]:"" ); + SCR::Write(.network.value + card["fcoe_vlan"]:"" + "USERCONTROL", "no" ); + y2milestone( "Writing /etc/sysconfig/network/ifcfg-%1", card["dev_name"]:"" ); + // write /etc/sysconfig/network/ifcfg-<interface> (underlying interface), e.g. ifcfg-eth3 + SCR::Write(.network.value + card["dev_name"]:"" + "BOOTPROTO", "static" ); + SCR::Write(.network.value + card["dev_name"]:"" + "STARTMODE", "nfsroot" ); + SCR::Write(.network.value + card["dev_name"]:"" + "NAME", card["device"]:"" ); + } + } ); + // This is very important- it flushes the cache, and stores the configuration on the disk + success = SCR::Write( .network, nil ); + if ( !success ) + { + y2error( "Error writing /etc/sysconfig/network/ifcfg-<fcoe-interface>" ); + } + return success; } // -// Write /etc/fcoe/cfg-ethx files +// Write /etc/fcoe/cfg-ethx files using fcoe_cfg-ethx.scr // global boolean WriteCfgFiles() { @@ -764,34 +798,29 @@ string command = ""; map output = $[]; - y2milestone( "Writing /etc/fcoe/cfg-ethx files" ); - foreach ( map card, (list<map>)netcards, { if ( card["fcoe_vlan"]:"" != FcoeClient::NOT_AVAILABLE && // FCoE VLAN is configured card["fcoe_vlan"]:"" != FcoeClient::NOT_CONFIGURED && Modified() ) // and data are modified { - y2milestone( "Write .fcoe.cfg-ethx.value.cfg-%1.<var>", card["cfg_file"]:"" ); + y2milestone( "Writing /etc/fcoe/cfg-%1", card["cfg_file"]:"" ); success = SCR::Write(.fcoe.cfg-ethx.value + card["cfg_file"]:"" + "FCOE_ENABLE", card[ "fcoe_enable"]:"no" ); if ( !success ) { y2error( "Writing FCOE_ENABLE=%1 failed", card[ "fcoe_enable"]:"no" ); - return false; } success = SCR::Write(.fcoe.cfg-ethx.value + card["cfg_file"]:"" + "DCB_REQUIRED", card["dcb_required"]:"no" ); if ( !success ) { y2error( "Writing DCB_REQUIRED=%1 failed", card["dcb_required"]:"no" ); - return false; } success = SCR::Write(.fcoe.cfg-ethx.value + card["cfg_file"]:"" + "AUTO_VLAN", card["auto_vlan"]:"no" ); if ( !success ) { y2error( "Writing AUTO_VLAN=%1 failed", card["auto_vlan"]:"no" ); - return false; } - if ( card["dcb_required"]:"no" == "yes" ) + if ( card["dcb_required"]:"no" == "yes" ) { - //enable DCB on the interface + // enable DCB on the interface command = sformat( "dcbtool sc %1 dcb on", card["dev_name"]:"" ); y2milestone( "Executing command: %1", command ); output = (map)SCR::Execute( .target.bash_output, command ); @@ -816,11 +845,12 @@ } } ); // This is very important- it flushes the cache, and stores the configuration on the disk - SCR::Write( .fcoe.cfg-ethx, nil ); + success = SCR::Write( .fcoe.cfg-ethx, nil ); - return true; + return success; } +// restart service fcoe global boolean RestartServiceFcoe() { boolean ret = true; @@ -985,13 +1015,19 @@ if( !success ) Report::Error (_("Cannot write settings for FCoE interfaces. For details see /var/log/YaST2/y2log") ); - // restart fcoe to enable changes if(PollAbort()) return false; Progress::NextStage(); + // restart fcoe to enable changes success = RestartServiceFcoe(); /* Error message */ - if( !success ) Report::Error (_("/etc/init.d/fcoe restart failed.")); + if( !success ) Report::Error (_("Restarting of service fcoe failed.")); + sleep(sl); + + // write ifcfg-files in /etc/sysconfig/network + success = WriteSysconfigFiles(); + /* Error message */ + if( !success ) Report::Error (_("Cannot write /etc/sysconfig/network/ifcfg-files.")); sleep(sl); // adjust service start of lldpad and fcoe Modified: branches/SuSE-Code-11-SP2-Branch/fcoe-client/src/complex.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/fcoe-client/src/complex.ycp?rev=66252&r1=66251&r2=66252&view=diff ============================================================================== --- branches/SuSE-Code-11-SP2-Branch/fcoe-client/src/complex.ycp (original) +++ branches/SuSE-Code-11-SP2-Branch/fcoe-client/src/complex.ycp Wed Oct 5 12:54:31 2011 @@ -284,9 +284,8 @@ string vlan_interface = ""; string fcoe_vlan_interface = ""; map status_map = $[]; - boolean create_ifcfg = true; - FcoeClient::ifcfg_file = sformat( "/etc/sysconfig/network/ifcfg-%1\.%2", dev_name, card["vlan_interface"]:"" ); + string ifcfg_file = sformat( "/etc/sysconfig/network/ifcfg-%1\.%2", dev_name, card["vlan_interface"]:"" ); // headline of a popup: creating and starting Fibre Channel over Ethernet boolean ret = Popup::YesNoHeadline( _("Creating and starting FCoE on detected VLAN device"), @@ -318,15 +317,13 @@ // if /etc/sysconfig/network/ifcfg-<if>.<vlan> already exists // call 'ifup' for the interface (creates /proc/net/vlan/<if>.<vlan>) - if ( FileUtils::Exists( FcoeClient::ifcfg_file ) ) + if ( FileUtils::Exists( ifcfg_file ) ) { string cmd_ifup = sformat( "ifup %1\.%2", dev_name, card["vlan_interface"]:"" ); y2milestone( "Executing command: %1", cmd_ifup ); output = (map)SCR::Execute( .target.bash_output, cmd_ifup ); y2milestone( "Output: %1", output ); - create_ifcfg = false; // /etc/sysconfig/network/ifcfg-file already exists - if ( output["exit"]:255 == 0 ) { // only start FCoE @@ -351,39 +348,22 @@ return nil; } - // Get new status and exchange list (table) entry - vlan_interface = FcoeClient::GetVlanInterface( card["dev_name"]:"" ); - if ( vlan_interface == "" ) + // Get values and exchange list (table) entry + fcoe_vlan_interface = FcoeClient::GetFcoeVlanInterface( card["dev_name"]:"", card["vlan_interface"]:"" ); + + if ( fcoe_vlan_interface != "" ) { - fcoe_vlan_interface = FcoeClient::NOT_AVAILABLE; + y2milestone( "FCoE VLAN interface %1 created/started", fcoe_vlan_interface ); + // write config for FCoE VLAN interface + FcoeClient::CreateFcoeConfig( fcoe_vlan_interface, card ); + status_map = FcoeClient::GetFcoeStatus ( fcoe_vlan_interface, card["dev_name"]:"" ); + + // store command to be able to revert the creation of FCoE VLAN interface in case of 'Cancel' + FcoeClient::AddRevertCommand( sformat("vconfig rem %1", fcoe_vlan_interface ) ); } else { - fcoe_vlan_interface = FcoeClient::GetFcoeVlanInterface( card["dev_name"]:"", vlan_interface ); - - if ( fcoe_vlan_interface != "" ) - { - y2milestone( "FCoE VLAN interface %1 created/started", fcoe_vlan_interface ); - FcoeClient::CreateFcoeConfig( fcoe_vlan_interface, card ); - status_map = FcoeClient::GetFcoeStatus ( fcoe_vlan_interface, card["dev_name"]:"" ); - // store command to be able to revert the creation of FCoE VLAN interface in case of 'Cancel' - // (also if only 'fipvlan -s <interface>' is called) - FcoeClient::AddRevertCommand( sformat("vconfig rem %1", fcoe_vlan_interface ) ); - - if ( create_ifcfg ) - { - string config = sformat( "BOOTPROTO=\"static\"\nSTARTMODE=\"nfsroot\" -ETHERDEVICE=\"%1\"\nUSERCONTROL=\"no\"\n", dev_name ); - FcoeClient::ifcfg_file = sformat( "/etc/sysconfig/network/ifcfg-%1", fcoe_vlan_interface ); - SCR::Write(.target.string, FcoeClient::ifcfg_file, config); - y2milestone( "Writing config: %1 to %2", config, FcoeClient::ifcfg_file ); - FcoeClient::AddRevertCommand( sformat( "rm %1", FcoeClient::ifcfg_file ) ); - } - } - else - { - fcoe_vlan_interface = FcoeClient::NOT_CONFIGURED; - } + fcoe_vlan_interface = FcoeClient::NOT_CONFIGURED; } // set new values in global map network_interfaces Modified: branches/SuSE-Code-11-SP2-Branch/fcoe-client/src/fcoe-client_finish.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP2-Branch/fcoe-client/src/fcoe-client_finish.ycp?rev=66252&r1=66251&r2=66252&view=diff ============================================================================== --- branches/SuSE-Code-11-SP2-Branch/fcoe-client/src/fcoe-client_finish.ycp (original) +++ branches/SuSE-Code-11-SP2-Branch/fcoe-client/src/fcoe-client_finish.ycp Wed Oct 5 12:54:31 2011 @@ -48,27 +48,41 @@ { boolean start_services = false; string command = ""; - y2milestone( "Copying files /etc/fcoe/* to destination" ); - - // copy fcoe config files to destdir - WFM::Execute (.local.bash,"test -d /etc/fcoe/ && mkdir -p '" + String::Quote(Installation::destdir) + "/etc/fcoe' && cp -a /etc/fcoe/* '" + String::Quote(Installation::destdir) + "/etc/fcoe/'"); - - // copy sysconfig file - command = sformat ( "cp -a %1 '%2/etc/sysconfig/network'", FcoeClient::ifcfg_file, - String::Quote(Installation::destdir) ); - y2milestone( "Executing command: %1", command ); - - WFM::Execute (.local.bash, command ); - - // only enable services if any FCoE VLAN interface is enabled list <map> netcards = FcoeClient::GetNetworkCards(); + if ( netcards != $[] ) + { + y2milestone( "Copying files /etc/fcoe/* to destination" ); + // copy fcoe config files to destdir + WFM::Execute (.local.bash,"test -d /etc/fcoe/ && mkdir -p '" + String::Quote(Installation::destdir) + "/etc/fcoe' && cp -a /etc/fcoe/* '" + String::Quote(Installation::destdir) + "/etc/fcoe/'"); + } + else + { + y2milestone( "Nothing to do" ); + } + foreach ( map card, netcards, { + string command = ""; + string file_name = ""; if ( card["fcoe_vlan"]:"" != FcoeClient::NOT_AVAILABLE && card["fcoe_vlan"]:"" != FcoeClient::NOT_CONFIGURED ) { // FCoE VLAN interface is configured -> start services start_services = true; + + // copy sysconfig files + file_name = sformat( "/etc/sysconfig/network/ifcfg-%1\.%2", + card["dev_name"]:"", card["vlan_interface"] ); + command = sformat ( "cp -a %1 '%2/etc/sysconfig/network'", file_name, + String::Quote(Installation::destdir) ); + y2milestone( "Executing command: %1", command ); + WFM::Execute (.local.bash, command ); + + file_name = sformat( "/etc/sysconfig/network/ifcfg-%1", card["dev_name"]:"" ); + command = sformat ( "cp -a %1 '%2/etc/sysconfig/network'", file_name, + String::Quote(Installation::destdir) ); + y2milestone( "Executing command: %1", command ); + WFM::Execute (.local.bash, command ); } } ); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org