2 Module: Sysconfig_Route
3 Parses /etc/sysconfig/network-scripts/route-${device}
5 Author: Stephen P. Schaefer
8 This lens allows manipulation of *one* IPv4 variant of the
9 /etc/sysconfig/network-scripts/route-${device} script found in RHEL5+, CentOS5+
12 The variant handled consists of lines like
13 "destination_subnet/cidr via router_ip", e.g.,
14 "10.132.11.0/24 via 10.10.2.1"
16 There are other variants; if you use them, please enhance this lens.
18 The natural key would be "10.132.11.0/24" with value "10.10.2.1", but since
19 augeas cannot deal with slashes in the key value, I reverse them, so that the
20 key is "10.10.2.1[1]" (and "10.10.2.1[2]"... if multiple subnets are reachable
24 This file is licenced under the LGPL v2+, like the rest of Augeas.
27 Sample usage of this lens in augtool
29 * Set the first subnet reachable by a router reachable on the eth0 subnet
30 > set /files/etc/sysconfig/network-scripts/route-eth0/10.10.2.1[1] 172.16.254.0/24
31 * List all the subnets reachable by a router reachable on eth0 subnet
32 > match /files/etc/sysconfig/network-scripts/route-eth0/10.10.2.1
34 About: Configuration files
35 This lens applies to /etc/sysconfig/network-scripts/route-*
38 The <Test_Sysconfig_Route> file contains various examples and tests.
41 module Sysconfig_Route =
44 (******************************************************************************
45 * Group: USEFUL PRIMITIVES
46 ******************************************************************************)
52 A subnet mask can be 0 to 32 bits *)
53 let cidr = /(3[012]|[12][0-9]|[0-9])/
55 Subnet specification *)
56 let subnet = Rx.ipv4 . "/" . cidr
58 (******************************************************************************
60 ******************************************************************************)
64 let entry = [ store subnet . del /[ \t]*via[ \t]*/ " via "
65 . key router . Util.del_str "\n" ]
67 (******************************************************************************
68 * Group: LENS AND FILTER
69 ******************************************************************************)
75 let filter = incl "/etc/sysconfig/network-scripts/route-*"
78 let xfm = transform lns filter