Author: gs
Date: Wed May 18 11:43:02 2011
New Revision: 64028
URL: http://svn.opensuse.org/viewcvs/yast?rev=64028&view=rev
Log:
use list<map> to store infos about interfaces
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=64028&r1=64027&r2=64028&view=diff
==============================================================================
--- trunk/fcoe-client/src/FcoeClient.ycp (original)
+++ trunk/fcoe-client/src/FcoeClient.ycp Wed May 18 11:43:02 2011
@@ -149,7 +149,7 @@
global string NOT_AVAILABLE = "not available";
// map containing information about networks cards and VLAN, FCoE and DCB status
-map network_interfaces = $[];
+list <map> network_interfaces = [];
// map containing information about values in /etc/fcoe/config
map fcoe_general_config = $[ "DEBUG":"no",
@@ -487,10 +487,9 @@
list <map> netcards = (list<map>)SCR::Read(.probe.netcard);
y2milestone( "Detected netcards: %1", netcards );
- integer row = 0;
foreach ( map card, netcards, {
- list info_list = [];
+ map info_map = $[];
map status_map = $[];
vlan_interface = GetVlanInterface( card["dev_name"]:"" );
@@ -517,17 +516,17 @@
dcb_capable = DCBCapable( card["dev_name"]:"" );
- 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;
+ info_map = add( info_map, "dev_name", card["dev_name"]:""); // network card, e.g. eth3
+ info_map = add( info_map, "device", card["device"]:""); // description
+ info_map = add( info_map, "fcoe_vlan", fcoe_vlan_interface ); // FCoE VLAN interface, e.g. eth3.200
+ info_map = add( info_map, "dcb_capable", dcb_capable ); // DCB capable
+ info_map = add( info_map, "fcoe_enable", status_map["FCOE_ENABLE"]:""); // FCOE_ENABLE
+ info_map = add( info_map, "dcb_required", status_map["DCB_REQUIRED"]:""); // DCB_REQUIRED
+ info_map = add( info_map, "vlan_interface", vlan_interface ); // VLAN interface, e.g. 200
+ info_map = add( info_map, "modified", "no" ); // data not modified
+ info_map = add( info_map, "cfg_file", status_map["Filename"]:"" ); // cfg file name
+
+ network_interfaces = add( network_interfaces, info_map );
} );
}
@@ -535,17 +534,17 @@
// Returns the map containing all detected interfaces including
// configuration status of VLAN, FCoE and DCB
//
-global map GetNetworkCards()
+global list <map> GetNetworkCards()
{
return network_interfaces;
}
-global list <string> GetCurrentNetworkCard()
+global map GetCurrentNetworkCard()
{
- return (list <string>)network_interfaces[ current_card ]:[];
+ return network_interfaces[current_card]:$[];
}
-global void SetNetworkCardsValue( integer row, list card )
+global void SetNetworkCardsValue( integer row, map card )
{
network_interfaces[row] = card;
}
@@ -625,24 +624,24 @@
boolean WriteCfgFiles()
{
- map netcards = GetNetworkCards();
+ list <map> netcards = GetNetworkCards();
boolean success = true;
- foreach ( integer row, list card, (map)netcards, {
- if ( card[7]:"no" == "yes" ) // data modified
+ foreach ( map card, (list<map>)netcards, {
+ if ( card["modified"]:"no" == "yes" ) // data modified
{
- string content = (string)SCR::Read( .target.string, card[8]:"" );
+ string content = (string)SCR::Read( .target.string, card["cfg_file"]:"" );
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" );
+ return sformat( "FCOE_ENABLE=\"%1\"", card["fcoe_enable"]:"no" );
}
else if ( regexpmatch( line, "^DCB_REQUIRED" ) )
{
- return sformat( "DCB_REQUIRED=\"%1\"", card[5]:"no" );
+ return sformat( "DCB_REQUIRED=\"%1\"", card["dcb_required"]:"no" );
}
else
{
@@ -652,14 +651,16 @@
content = mergestring( lines, "\n" );
y2milestone( "Modified content: %1", content );
- boolean ret = SCR::Write( .target.string, card[8]:"", content );
+ boolean ret = SCR::Write( .target.string, card["cfg_file"]:"", content );
if ( !ret )
- y2error( "Cannot write %1", card[8]:"" );
- else
- y2milestone( "%1 written", card[8]:"" );
-
- if ( success )
+ {
success = ret;
+ y2error( "Cannot write %1", card["cfg_file"]:"" );
+ }
+ else
+ {
+ y2milestone( "%1 written", card["cfg_file"]:"" );
+ }
}
} );
Modified: trunk/fcoe-client/src/complex.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/fcoe-client/src/complex.ycp?rev=64028&r1=64027&r2=64028&view=diff
==============================================================================
--- trunk/fcoe-client/src/complex.ycp (original)
+++ trunk/fcoe-client/src/complex.ycp Wed May 18 11:43:02 2011
@@ -116,34 +116,19 @@
}
//
-// Get current network interface (netcard)
-//
-list GetCurrentNetcard()
-{
- list card = [];
-
- map netcards = FcoeClient::GetNetworkCards();
- integer row = (integer)UI::QueryWidget( `id(`interfaces), `CurrentItem );
- card = netcards[row]:[];
- y2milestone( "Current row: %1 card: %2", row, card );
-
- return card;
-}
-
-//
// Adjust buttons, means set 'Change Settings' and 'Create VLAN' sensitive or insensitive
//
void AdjustButtons()
{
- list card = GetCurrentNetcard();
+ map card = FcoeClient::GetCurrentNetworkCard();
// check VLAN status
- if ( card[2]:"" == FcoeClient::NOT_CONFIGURED )
+ if ( card["fcoe_vlan"]:"" == FcoeClient::NOT_CONFIGURED )
{
UI::ChangeWidget( `id(`edit), `Enabled, false );
UI::ChangeWidget( `id(`create), `Enabled, true );
}
- else if ( card[2]:"" == FcoeClient::NOT_AVAILABLE )
+ else if ( card["fcoe_vlan"]:"" == FcoeClient::NOT_AVAILABLE )
{
UI::ChangeWidget( `id(`edit), `Enabled, false );
UI::ChangeWidget( `id(`create), `Enabled, false );
@@ -159,20 +144,23 @@
void InitInterfacesDialog (string id) {
y2milestone( "Init interfaces dialog" );
string vlan_interface = "";
+ integer row = 0;
- map netcards = FcoeClient::GetNetworkCards();
+ list <map> netcards = FcoeClient::GetNetworkCards();
y2milestone( "Got netcards: %1", netcards );
list <term> table_items = [];
- foreach ( integer row, list card, netcards, {
+ foreach ( map card, (list<map>)netcards, {
table_items = add( table_items,
- `item(`id(row), card[0]:"", card[1]:"", card[2]:"",
- card[3]:"", card[4]:"", card[5]:"" )
+ `item(`id(row), card["dev_name"]:"", card["device"]:"", card["fcoe_vlan"]:"",
+ card["dcb_capable"]:"", card["fcoe_enable"]:"", card["dcb_required"]:"" )
);
+ row = row + 1;
});
UI::ChangeWidget( `id(`interfaces), `Items, table_items );
+ // set current item
UI::ChangeWidget( `id(`interfaces), `CurrentItem, `id(0) );
FcoeClient::current_card = 0;
@@ -208,13 +196,13 @@
void InitEditDialog( string id )
{
y2milestone( "Init edit dialog" );
- map cards = FcoeClient::GetNetworkCards();
- list card = cards[ FcoeClient::current_card ]:[];
+ list <map> cards = FcoeClient::GetNetworkCards();
+ map card = cards[FcoeClient::current_card]:$[];
// 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]:"" ) );
+ UI::ChangeWidget( `id(`fcoe), `Value, card["fcoe_enable"]:"" );
+ UI::ChangeWidget( `id(`dcb), `Value, card["dcb_required"]:"" );
+ UI::ChangeWidget( `id(`heading), `Value, sformat( _("Configuration of Interface %1"), card["fcoe_vlan"]:"" ) );
}
/**
@@ -244,12 +232,12 @@
}
else if ( action == `create )
{
- list card = (list)GetCurrentNetcard();
- string dev_name = card[0]:"";
+ map card = FcoeClient::GetCurrentNetworkCard();
+ string dev_name = card["dev_name"]:"";
boolean ret = Popup::YesNoHeadline( _("Creating and starting FCoE on detected VLAN device"),
- sformat( _("Do you really want to create a network
-interface on %1 for discovered FCoE VLAN interface
-and start the FCoE initiator?"), dev_name ) );
+ sformat( _("Do you really want to create a FCoE network
+interface for discovered FCoE VLAN interface
+on %1 and start the FCoE initiator?"), dev_name ) );
if ( ret == true )
{
string vlan_interface = "";
@@ -265,14 +253,14 @@
if ( output["exit"]:255 == 0 )
{
// Get new status and exchange list (table) entry
- vlan_interface = FcoeClient::GetVlanInterface( card[0]:"" );
+ vlan_interface = FcoeClient::GetVlanInterface( card["dev_name"]:"" );
if ( vlan_interface == "" )
{
fcoe_vlan_interface = FcoeClient::NOT_AVAILABLE;
}
else
{
- fcoe_vlan_interface = FcoeClient::GetFcoeVlanInterface( card[0]:"", vlan_interface );
+ fcoe_vlan_interface = FcoeClient::GetFcoeVlanInterface( card["dev_name"]:"", vlan_interface );
if ( fcoe_vlan_interface != "" )
status_map = FcoeClient::GetFCoEStatus( fcoe_vlan_interface );
@@ -281,9 +269,11 @@
}
y2milestone( "FCoE VLAN interface: %1", fcoe_vlan_interface );
// set new value in global map network_interfaces
- card[2] = fcoe_vlan_interface;
- card[4] = status_map["FCOE_ENABLE"]:"";
- card[5] = status_map["DCB_REQUIRED"]:"";
+ card["fcoe_vlan"] = fcoe_vlan_interface;
+ card["fcoe_enable"] = status_map["FCOE_ENABLE"]:"";
+ card["dcb_required"] = status_map["DCB_REQUIRED"]:"";
+ card["cfg_file"] = status_map["Filename"]:"";
+
FcoeClient::SetNetworkCardsValue( FcoeClient::current_card, card );
y2milestone( "Current network interfaces: %1", FcoeClient::GetNetworkCards() );
@@ -367,20 +357,20 @@
{
y2milestone( "Store edit dialog" );
- list <string> card = FcoeClient::GetCurrentNetworkCard();
+ map card = FcoeClient::GetCurrentNetworkCard();
string fcoe_enabled = (string)UI::QueryWidget( `id(`fcoe), `Value );
- if ( card[4]:"" != fcoe_enabled )
+ if ( card["fcoe_enable"]:"" != fcoe_enabled )
{
- card[4] = fcoe_enabled;
- card[7] = "yes"; // set modified to "yes"
+ card["fcoe_enable"] = fcoe_enabled;
+ card["modified"] = "yes"; // set modified to "yes"
}
string dcb_required = (string)UI::QueryWidget( `id(`dcb), `Value );
- if ( card[5]:"" != dcb_required )
+ if ( card["dcb_required"]:"" != dcb_required )
{
- card[5] = dcb_required;
- card[7] = "yes"; // set modified to "yes"
+ card["dcb_required"] = dcb_required;
+ card["modified"] = "yes"; // set modified to "yes"
}
FcoeClient::SetNetworkCardsValue( FcoeClient::current_card, card );
Modified: trunk/fcoe-client/src/dialogs.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/fcoe-client/src/dialogs.ycp?rev=64028&r1=64027&r2=64028&view=diff
==============================================================================
--- trunk/fcoe-client/src/dialogs.ycp (original)
+++ trunk/fcoe-client/src/dialogs.ycp Wed May 18 11:43:02 2011
@@ -67,7 +67,7 @@
`Label( `id(`heading), ("Configuration of Interface ...................") ),
`HBox (
`HStretch(),
- `Frame( _(""),
+ `Frame( (""),
`VBox(
`VSpacing(2),
`ComboBox( `id(`fcoe), _("FCoE Enable"),
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org