Author: gs
Date: Tue May 17 13:37:40 2011
New Revision: 64011
URL: http://svn.opensuse.org/viewcvs/yast?rev=64011&view=rev
Log:
improve edit dialog, write /etc/fcoe/cfg-ethx settings
Modified:
trunk/fcoe-client/src/FcoeClient.ycp
trunk/fcoe-client/src/complex.ycp
trunk/fcoe-client/src/dialogs.ycp
Modified: trunk/fcoe-client/src/FcoeClient.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/fcoe-client/src/FcoeClient.ycp?rev=64011&r1=64010&r2=64011&view=diff
==============================================================================
--- trunk/fcoe-client/src/FcoeClient.ycp (original)
+++ trunk/fcoe-client/src/FcoeClient.ycp Tue May 17 13:37:40 2011
@@ -277,26 +277,29 @@
if ( content == "" || content == nil )
{
// remove '-fcoe' and try again
- y2milestone( "Reading %1", substring( file_name, 0, size(file_name)-5 ) );
- content = (string)SCR::Read(.target.string, substring( file_name, 0, size(file_name)-5 ) );
+ file_name = substring( file_name, 0, size(file_name)-5 );
+ y2milestone( "Reading %1", file_name );
+ content = (string)SCR::Read(.target.string, file_name );
}
if ( content == "" || content == nil )
{
+ string create_file_name = sformat( "/etc/fcoe/cfg-%1", vlan_device_name );
y2milestone( "Cannot read cfg-file creating %1 with default values from /etc/fcoe/cfg-ethx",
- file_name );
+ create_file_name );
string def_values = (string)SCR::Read( .target.string, "/etc/fcoe/cfg-ethx" );
- if ( def_values != "" )
+ if ( def_values != "" && def_values != nil )
{
- boolean ret = SCR::Write( .target.string, file_name, def_values );
+ boolean ret = SCR::Write( .target.string, create_file_name, def_values );
if ( ret == true )
{
status_map = add( status_map, "FCOE_ENABLE", "yes");
status_map = add( status_map, "DCB_REQUIRED", "yes");
+ status_map = add( status_map, "Filename", create_file_name );
}
else
{
- y2error( "Cannot create %1", file_name );
+ y2error( "Cannot create %1", create_file_name );
}
}
else
@@ -322,6 +325,7 @@
status_map = add( status_map, "DCB_REQUIRED", deletechars( substring( line, 13 ),"\"") );
}
});
+ status_map = add( status_map, "Filename", file_name );
}
else
{
@@ -513,14 +517,15 @@
dcb_capable = DCBCapable( card["dev_name"]:"" );
- info_list = add( info_list, card["dev_name"]:""); // network card, e.g. eth3
- info_list = add( info_list, card["device"]:""); // description
- info_list = add( info_list, fcoe_vlan_interface ); // FCoE VLAN interface, e.g. eth3.200
- info_list = add( info_list, dcb_capable ); // DCB capable
- info_list = add( info_list, status_map["FCOE_ENABLE"]:"");
- info_list = add( info_list, status_map["DCB_REQUIRED"]:"");
- info_list = add( info_list, vlan_interface ); // VLAN interface, e.g. 200
- info_list = add( info_list, "no" ); // data not modified
+ info_list = add( info_list, card["dev_name"]:""); // 0 network card, e.g. eth3
+ info_list = add( info_list, card["device"]:""); // 1 description
+ info_list = add( info_list, fcoe_vlan_interface ); // 2 FCoE VLAN interface, e.g. eth3.200
+ info_list = add( info_list, dcb_capable ); // 3 DCB capable
+ info_list = add( info_list, status_map["FCOE_ENABLE"]:""); // 4 FCOE_ENABLE
+ info_list = add( info_list, status_map["DCB_REQUIRED"]:""); // 5 DCB_REQUIRED
+ info_list = add( info_list, vlan_interface ); // 6 VLAN interface, e.g. 200
+ info_list = add( info_list, "no" ); // 7 data not modified
+ info_list = add( info_list, status_map["Filename"]:"" ); // 8 file name
network_interfaces = add( network_interfaces, row, info_list );
row = row + 1;
} );
@@ -618,6 +623,49 @@
return ret;
}
+boolean WriteCfgFiles()
+{
+ map netcards = GetNetworkCards();
+ boolean success = true;
+
+ foreach ( integer row, list card, (map)netcards, {
+ if ( card[7]:"no" == "yes" ) // data modified
+ {
+ string content = (string)SCR::Read( .target.string, card[8]:"" );
+ y2milestone( "Original content: %1", content );
+
+ list <string> lines = (list<string>)splitstring( content, "\n" );
+ lines = maplist( string line, lines, {
+ if ( regexpmatch( line, "^FCOE_ENABLE" ) )
+ {
+ return sformat( "FCOE_ENABLE=\"%1\"", card[4]:"no" );
+ }
+ else if ( regexpmatch( line, "^DCB_REQUIRED" ) )
+ {
+ return sformat( "DCB_REQUIRED=\"%1\"", card[5]:"no" );
+ }
+ else
+ {
+ return line;
+ }
+ });
+ content = mergestring( lines, "\n" );
+ y2milestone( "Modified content: %1", content );
+
+ boolean ret = SCR::Write( .target.string, card[8]:"", content );
+ if ( !ret )
+ y2error( "Cannot write %1", card[8]:"" );
+ else
+ y2milestone( "%1 written", card[8]:"" );
+
+ if ( success )
+ success = ret;
+ }
+ } );
+
+ return success;
+}
+
/**
* Read all fcoe-client settings
* @return true on success
@@ -754,11 +802,14 @@
Progress::NextStage();
boolean success = WriteFcoeConfig();
-
/* Error message */
if( !success ) Report::Error (_("Cannot write settings to /etc/fcoe/config."));
sleep(sl);
+ success = WriteCfgFiles();
+ if( !success ) Report::Error (_("Cannot write settings for FCoE interfaces.
+For details see /var/log/YaST2/y2log") );
+
// run SuSEconfig
if(Abort()) return false;
Progress::NextStage ();
Modified: trunk/fcoe-client/src/complex.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/fcoe-client/src/complex.ycp?rev=64011&r1=64010&r2=64011&view=diff
==============================================================================
--- trunk/fcoe-client/src/complex.ycp (original)
+++ trunk/fcoe-client/src/complex.ycp Tue May 17 13:37:40 2011
@@ -214,6 +214,7 @@
// set values for 'FCoE Enabled' and 'DCB Required'
UI::ChangeWidget( `id(`fcoe), `Value, card[4]:"" );
UI::ChangeWidget( `id(`dcb), `Value, card[5]:"" );
+ UI::ChangeWidget( `id(`heading), `Value, sformat( _("Configuration of Interface %1"), card[2]:"" ) );
}
/**
@@ -339,7 +340,7 @@
y2milestone( "Setting auto start of FCoE to true");
}
- boolean lldpad_auto = (boolean)UI::QueryWidget( `id ("llpad_startup_auto"), `Value );
+ boolean lldpad_auto = (boolean)UI::QueryWidget( `id ("lldpad_startup_auto"), `Value );
if ( lldpad_auto )
{
@@ -365,22 +366,23 @@
void StoreEditDialog (string id, map event)
{
y2milestone( "Store edit dialog" );
- string modified = "no";
list <string> card = FcoeClient::GetCurrentNetworkCard();
+
string fcoe_enabled = (string)UI::QueryWidget( `id(`fcoe), `Value );
if ( card[4]:"" != fcoe_enabled )
{
card[4] = fcoe_enabled;
- modified = "yes";
+ card[7] = "yes"; // set modified to "yes"
}
+
string dcb_required = (string)UI::QueryWidget( `id(`dcb), `Value );
if ( card[5]:"" != dcb_required )
{
card[5] = dcb_required;
- modified = "yes";
+ card[7] = "yes"; // set modified to "yes"
}
- card[7] = modified;
+
FcoeClient::SetNetworkCardsValue( FcoeClient::current_card, card );
y2milestone( "Current data: %1", FcoeClient::GetNetworkCards() );
Modified: trunk/fcoe-client/src/dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/fcoe-client/src/dialogs.ycp?rev=64011&r1=64010&r2=64011&view=diff
==============================================================================
--- trunk/fcoe-client/src/dialogs.ycp (original)
+++ trunk/fcoe-client/src/dialogs.ycp Tue May 17 13:37:40 2011
@@ -63,24 +63,27 @@
{
return `VBox(
`VStretch(),
- `HBox(
- `HStretch(),
- `HSpacing (1),
- `VBox(
- `ComboBox( `id(`fcoe), _("FCoE Enable"),
- [`item(`id("yes"), "yes" ),
- `item(`id("no"), "no", true ) ]
- ),
- `VSpacing (2),
- `ComboBox( `id(`dcb), _("DCB Required"),
- [`item(`id("yes"), "yes" ),
- `item(`id("no"), "no", true ) ]
- ),
- `VSpacing (2)
- ),
- `HSpacing (1),
- `HStretch()
- ),
+ // heading is replaced later (InitEditDialog)
+ `Label( `id(`heading), ("Configuration of Interface ...................") ),
+ `HBox (
+ `HStretch(),
+ `Frame( _(""),
+ `VBox(
+ `VSpacing(2),
+ `ComboBox( `id(`fcoe), _("FCoE Enable"),
+ [`item(`id("yes"), "yes" ),
+ `item(`id("no"), "no", true ) ]
+ ),
+ `VSpacing (2),
+ `ComboBox( `id(`dcb), _("DCB Required"),
+ [`item(`id("yes"), "yes" ),
+ `item(`id("no"), "no", true ) ]
+ ),
+ `VSpacing (2)
+ )
+ ),
+ `HStretch()
+ ),
`VStretch()
);
}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org