Author: kmachalkova
Date: Wed Sep 10 18:14:33 2008
New Revision: 50991
URL: http://svn.opensuse.org/viewcvs/yast?rev=50991&view=rev
Log:
commandline support for routing (first step)
fate#120078
Modified:
trunk/network/src/clients/routing.ycp
Modified: trunk/network/src/clients/routing.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/network/src/clients/routing.ycp?rev=50991&r1=50990&r2=50991&view=diff
==============================================================================
--- trunk/network/src/clients/routing.ycp (original)
+++ trunk/network/src/clients/routing.ycp Wed Sep 10 18:14:33 2008
@@ -23,6 +23,7 @@
import "Wizard";
import "CommandLine";
+import "String";
import "RichText";
import "NetworkService";
@@ -59,22 +60,76 @@
return ret;
}
+string PrintableRoutingTable( list <map> items )
+{
+ list table_items = [];
+ foreach (map route, items, {
+ table_items = add( table_items,
+ [
+ route["destination"]:"",
+ route["gateway"]:"",
+ route["netmask"]:"-",
+ route["device"]:"-",
+ route["extrapara"]:""
+ ]
+ );
+
+ });
+
+ string headline = String::UnderlinedHeader( _("Routing Table"), 0 );
+ string table = String::TextTable(
+ [
+ _("Destination"),
+ _("Gateway"),
+ _("Netmask"),
+ _("Device"),
+ _("Options")
+ ],
+ table_items,
+ $[] );
+
+ return headline + "\n" + table;
+
+}
/**
* Handler for action "list"
* @param options action options
*/
-define boolean ListHandler(map options) {
+define boolean ListHandler( map options ) {
+
+ CommandLine::Print( PrintableRoutingTable( Routing::Routes ) );
+ CommandLine::Print("");
- string summary = "";
- /* Command line output Headline */
- summary = "\n" + _("Routing Configuration Summary:") + "\n\n" +
- RichText::Rich2Plain(Routing::Summary()) + "\n";
+ return true;
+}
+
+define boolean ShowHandler( map options ) {
+ //FIXME: handle empty list
+
+ CommandLine::Print( PrintableRoutingTable (
+ filter( map route, Routing::Routes, {
+ return (route["destination"]:"" == options["dest"]:"");
+ })
+ ) );
+ CommandLine::Print("");
- y2debug("%1", summary);
- CommandLine::Print(summary);
return true;
}
+define boolean IPFWHandler( map options ) {
+ CommandLine::Print( String::UnderlinedHeader(_("IP Forwarding:"), 0) );
+
+ if (options["show"]:nil != nil)
+ {
+ CommandLine::Print("");
+ if ( Routing::Forward )
+ CommandLine::Print(_("IP forwarding is enabled"));
+ else
+ CommandLine::Print(_("IP forwarding is disabled"));
+ CommandLine::Print("");
+ }
+ return true;
+}
/**
* Command line definition
*/
@@ -87,11 +142,37 @@
"finish" : Routing::Write, // FIXME
"actions" : $[
"list" : $[
- /* Commandline command help */
- "help" : _("Display configuration summary"),
- "handler" : ListHandler,
+ "help" : _("Show complete routing table"),
+ "handler" : ListHandler,
+ ],
+ "show" : $[
+ "help" : _("Show routing table entry for selected destination"),
+ "handler" : ShowHandler,
+ ],
+ "ip-forwarding" : $[
+ "help" : _("IP forwarding settings"),
+ "handler" : IPFWHandler,
+ ]
+ ],
+ "options" : $[
+ "dest" : $[
+ "type" : "string",
+ "help" : _("Destination addresss IP"),
+ ],
+ "show" : $[
+ "help" : _("Show current settings")
+ ],
+ "on" : $[
+ "help" : _("Enable IP forwarding")
+ ],
+ "off" : $[
+ "help" : _("Disable IP forwarding")
],
],
+ "mappings" : $[
+ "show" : [ "dest" ],
+ "ip-forwarding" : [ "show", "on", "off" ]
+ ]
];
any ret = CommandLine::Run(cmdline);
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org