Author: gs
Date: Thu Apr 28 14:01:49 2011
New Revision: 63883
URL: http://svn.opensuse.org/viewcvs/yast?rev=63883&view=rev
Log:
Transfer detecting of netcards to module
Modified:
trunk/fcoe-client/src/FcoeClient.ycp
trunk/fcoe-client/src/complex.ycp
Modified: trunk/fcoe-client/src/FcoeClient.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/fcoe-client/src/FcoeClient.ycp?rev=63883&r1=63882&r2=63883&view=diff
==============================================================================
--- trunk/fcoe-client/src/FcoeClient.ycp (original)
+++ trunk/fcoe-client/src/FcoeClient.ycp Thu Apr 28 14:01:49 2011
@@ -38,6 +38,10 @@
import "Report";
import "Summary";
import "Message";
+import "Stage";
+import "Mode";
+import "Package";
+import "Popup";
/**
* Prototypes
@@ -122,19 +126,148 @@
// Settings: Define all variables needed for configuration of fcoe-client
-// TODO FIXME: Define all the variables necessary to hold
-// TODO FIXME: the configuration here (with the appropriate
-// TODO FIXME: description)
-// TODO FIXME: For example:
-// /**
-// * List of the configured cards.
-// */
-// list cards = [];
-//
-// /**
-// * Some additional parameter needed for the configuration.
-// */
-// boolean additional_parameter = true;
+
+// Define all the variables necessary to hold
+
+global string NOT_CONFIGURED = "not configured";
+
+// map containing information about networks cards and VLAN, FCoE aand DCB status
+map network_interfaces = $[];
+
+// map containing information about values in /etc/fcoe/config
+map fcoe_general_config = $[];
+
+//
+// Check whether open-fcoe is installed and do installation if user agrees
+// (dependencies: 'lldpad', 'libhbalinux2' and 'libHBAAPI2')
+//
+boolean CheckInstalledPackages()
+{
+ boolean ret = false;
+
+ // don't check interactively for packages (bnc#367300)
+ // skip it during initial and second stage or when create AY profile
+ if(Stage::cont() || Stage::initial() || Mode::config()) return true;
+ y2milestone("Check if open-fcoe package installed");
+
+ if( !Package::InstallMsg( "open-fcoe",
+ _("<p>To continue the FCoE configuration, the <b>%1</b> package must be installed.</p>") +
+ _("<p>Install it now?</p>")) )
+ {
+ Popup::Error( Message::CannotContinueWithoutPackagesInstalled() );
+ }
+ else
+ {
+ ret = true;
+ }
+ return ret;
+}
+
+
+//
+// Check whether a VLAN interface is configured for a given network interface
+//
+string GetVlanInterface ( string interface )
+{
+ string vlan_interface = "";
+ string command = sformat( "sed -n 's/\\([^ ]*\\) *.*%1/\\1/p' /proc/net/vlan/config",
+ interface );
+ y2milestone( "Executing command: %1", command );
+
+ map output = (map)SCR::Execute( .target.bash_output, command );
+ // read stdout (remove \n at the end)
+ vlan_interface = substring( output["stdout"]:"", 0, size(output["stdout"]:"") -1 );
+
+ return vlan_interface;
+}
+
+//
+// Get status of FCoE and DCB from /etc/fcoe/cfg-eth GetFCoEStatus( string vlan_interface )
+{
+ map status_map = $[];
+
+ if ( vlan_interface != "")
+ {
+ string file_name = sformat( "/etc/fcoe/cfg-%1", vlan_interface );
+ y2milestone( "VLAN channel %1 found, reading %2", vlan_interface, file_name );
+
+ string content = (string)SCR::Read(.target.string, file_name);
+ if ( content == "" )
+ y2warning( "Cannot read %1", file_name );
+ else
+ y2milestone( "Content: %1", content );
+
+ list <string> lines = splitstring( content, "\n" );
+
+ foreach( string line, (list<string>)lines, {
+ if ( regexpmatch( line, "^FCOE_ENABLE" ) )
+ {
+ status_map = add( status_map, "FCOE_ENABLE", substring( line, 12 ) );
+ }
+ if ( regexpmatch( line, "^DCB_REQUIRED" ) )
+ {
+ status_map = add( status_map, "DCB_REQUIRED", substring( line, 13 ) );
+ }
+ });
+ }
+ else
+ {
+ y2error( "Interface not valid" );
+ }
+
+ return status_map;
+}
+
+//
+// Detect network interface cards (hardware probe) and get status
+//
+void DetectNetworkCards()
+{
+ string vlan_interface = "";
+
+ 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 status_map = $[];
+
+ vlan_interface = GetVlanInterface( card["dev_name"]:"" );
+ if ( vlan_interface != "" )
+ status_map = GetFCoEStatus( vlan_interface );
+ else
+ vlan_interface = NOT_CONFIGURED;
+
+ info_list = add( info_list, card["dev_name"]:"");
+ info_list = add( info_list, card["device"]:"");
+ info_list = add( info_list, vlan_interface );
+ info_list = add( info_list, status_map["FCOE_ENABLE"]:"");
+ info_list = add( info_list, status_map["DCB_REQUIRED"]:"");
+
+ network_interfaces = add( network_interfaces, row, info_list );
+ row = row + 1;
+ } );
+}
+
+//
+// Returns the map containing all detected interfaces including
+// configuration status of VLAN, FCoE and DCB
+//
+global map GetNetworkCards()
+{
+ return network_interfaces;
+}
+
+//
+// Returns the map containing general FCoE configuration
+//
+global map GetFcoeConfig()
+{
+ return fcoe_general_config;
+}
/**
* Read all fcoe-client settings
@@ -154,18 +287,18 @@
// We do not set help text here, because it was set outside
Progress::New( caption, " ", steps, [
/* Progress stage 1/3 */
- _("Read the database"),
+ _("Check installed packages"),
/* Progress stage 2/3 */
- _("Read the previous settings"),
+ _("Detect network cards"),
/* Progress stage 3/3 */
- _("Detect the devices")
+ _("Check services")
], [
/* Progress step 1/3 */
- _("Reading the database..."),
+ _("Checking for installed packages..."),
/* Progress step 2/3 */
- _("Reading the previous settings..."),
+ _("Detecting network cards..."),
/* Progress step 3/3 */
- _("Detecting the devices..."),
+ _("Checking for services..."),
/* Progress finished */
_("Finished")
],
@@ -175,15 +308,21 @@
// read database
if(Abort()) return false;
Progress::NextStage();
+
+ boolean installed = CheckInstalledPackages();
+
/* Error message */
- if(false) Report::Error(_("Cannot read database."));
+ if( !installed ) return false;
sleep(sl);
// read current settings
if(Abort()) return false;
Progress::NextStage();
+
+ DetectNetworkCards();
+
/* Error message */
- if(false) Report::Error(Message::CannotReadCurrentSettings());
+ if(false) Report::Error(_("Cannot get information about netcards"));
sleep(sl);
// detect devices
Modified: trunk/fcoe-client/src/complex.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/fcoe-client/src/complex.ycp?rev=63883&r1=63882&r2=63883&view=diff
==============================================================================
--- trunk/fcoe-client/src/complex.ycp (original)
+++ trunk/fcoe-client/src/complex.ycp Thu Apr 28 14:01:49 2011
@@ -88,58 +88,28 @@
y2milestone( "Init services dialog" );
}
-
//
-// Check whether a VLAN interface is configured for a given network interface
//
-string GetVlanInterface ( string interface )
-{
- string vlan_interface = "";
- string command = sformat( "sed -n 's/\\([^ ]*\\) *.*%1/\\1/p' /proc/net/vlan/config", interface );
- y2milestone( "Executing command: %1", command );
-
- map output = (map)SCR::Execute( .target.bash_output, command );
- // read stdout (remove \n at the end)
- vlan_interface = substring( output["stdout"]:"", 0, size(output["stdout"]:"") -1 );
-
- return vlan_interface;
-}
-
-map GetFCoEStatus( string vlan_interface )
+//
+void AdjustButtons()
{
- map status_map = $[];
+ map netcards = FcoeClient::GetNetworkCards();
+ integer row = (integer)UI::QueryWidget( `id(`interfaces), `CurrentItem );
+ list card = netcards[row]:[];
- if ( vlan_interface != "")
- {
- string file_name = sformat( "/etc/fcoe/cfg-%1", vlan_interface );
- y2milestone( "VLAN channel %1 found, reading %2", vlan_interface, file_name );
- string content = (string)SCR::Read(.target.string, file_name);
- if ( content == "" )
- y2warning( "Cannot read %1", file_name );
- else
- y2milestone( "Content: %1", content );
+ y2milestone( "row: %1 card: %2", row, card );
- list <string> lines = splitstring( content, "\n" );
-
- foreach( string line, (list<string>)lines, {
- if ( regexpmatch( line, "^FCOE_ENABLE" ) )
- {
- status_map = add( status_map, "FCOE_ENABLE", substring( line, 12 ) );
- y2milestone( "FCOE_ENABLE: %1", status_map["FCOE_ENABLE"]:"" );
- }
- if ( regexpmatch( line, "^DCB_REQUIRED" ) )
- {
- status_map = add( status_map, "DCB_REQUIRED", substring( line, 13 ) );
- y2milestone( "DCB_REQUIRED: %1", status_map["DCB_REQUIRED"]:"" );
- }
- });
+ // check VLAN status
+ if ( card[2]:"" == FcoeClient::NOT_CONFIGURED )
+ {
+ UI::ChangeWidget( `id(`edit), `Enabled, false );
+ UI::ChangeWidget( `id(`config), `Enabled, true );
}
else
{
- y2error( "Interface not valid" );
+ UI::ChangeWidget( `id(`edit), `Enabled, true );
+ UI::ChangeWidget( `id(`config), `Enabled, false );
}
-
- return status_map;
}
@@ -147,32 +117,27 @@
y2milestone( "Init interfaces dialog" );
string vlan_interface = "";
- list <map> netcards = (list<map>)SCR::Read(.probe.netcard);
- y2milestone( "Detected netcards: %1", netcards );
+ map netcards = FcoeClient::GetNetworkCards();
+ y2milestone( "Got netcards: %1", netcards );
list <term> table_items = [];
- integer row = 0;
- foreach ( map card, netcards, {
- map status_map = $[];
- vlan_interface = GetVlanInterface( card["dev_name"]:"" );
- if ( vlan_interface != "" )
- status_map = GetFCoEStatus( vlan_interface );
- else
- vlan_interface = "not configured";
-
+ foreach ( integer row, list card, netcards, {
table_items = add( table_items,
- `item(`id(row), card["dev_name"]:"", card["device"]:"", vlan_interface,
- status_map["FCOE_ENABLE"]:"", status_map["DCB_REQUIRED"]:"" )
+ `item(`id(row), card[0]:"", card[1]:"", card[2]:"",
+ card[3]:"", card[4]:"" )
);
- row = row + 1;
});
UI::ChangeWidget( `id(`interfaces), `Items, table_items );
+ UI::ChangeWidget( `id(`interfaces), `CurrentItem, `id(0) );
+ AdjustButtons();
}
-
+//
+//
+//
void InitConfigurationDialog (string id) {
y2milestone( "Init configuration dialog" );
@@ -213,11 +178,17 @@
{
any action = event["ID"]:nil;
+ y2milestone( "Event: %1", event );
+
if ( action == `edit )
{
y2milestone( "Action: %1, returning `edit", action);
return `edit;
}
+ else if ( action == `interfaces )
+ {
+ AdjustButtons();
+ }
return nil;
}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org