[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[augeas-devel] [PATCH] - New lens for NFS server settings



Since /etc/sysconfig/nfs comments out all settings this lens allows for specified settings to be altered and uncommented. This also has the ability to recomment a setting.

For example,

#MOUNTD_PORT=682

augtool> rm /files/etc/sysconfig/nfs/MOUNTD_PORT/commented

will become

MOUNTD_PORT=682

Recommenting is just as simple

augtool> clear /files/etc/sysconfig/nfs/MOUNTD_PORT/commented

Finally setting

augtool> set /files/etc/sysconfig/nfs/MOUNTD_PORT 5500

Cool thing about the set functionality is it will leave the setting in its current commented/uncommented state.

Thanks to David for all his help on getting this setup and some of this functionality will make its way back into shellvars for the rest of the sysconfig scripts to use.

I am hoping to utilize all of this and the pure python library for augeas to re-work system-config-nfs and more of the system-config* down the road.

thanks

-- 
        __          __                
.-----.|  |_.-----.|  |--.-----.-----.
|__ --||   _|  _  ||    <|  -__|__ --|
|_____||____|_____||__|__|_____|_____|
 .----------------------------------.
(   ajs redhat com || 919.754.4187   )
 `----------------------------------'

--- nfsserver.aug	2010-01-06 21:34:53.434440924 -0500
+++ nfsserver.aug.stokes	2010-01-06 16:18:23.238468680 -0500
@@ -0,0 +1,54 @@
+(* /etc/sysconfig/nfs - nfs server settings *)
+
+module NFSserver =
+    autoload xfm
+   
+    let eol             = del /[ \t]*\n/ "\n"
+    let value_sep       = del /[ \t]*=[ \t]*/  " = "
+    let indent          = del /[ \t]*/ ""
+    let empty           = [ label "#empty" . eol ]
+    
+    let comment         =
+        let settings    = /RQUOTAD_PORT|LOCKD_TCPPORT|LOCKD_UDPPORT|MOUNTD_PORT|STATD_PORT/ in
+        let line_re     = /([^ \t\n][^\n]*)?/ - (settings . /[ \t]*=[ \t]*.*/) in
+        [ label "#comment" . del /#[ \t]*/ "# " . store line_re . del /\n/ "\n" ]
+
+    let int_val         = store /[0-9]+/
+    
+    let int_entry (kw:string) = 
+        let marker = [ del /#[ \t]*/ "# " . label "commented" ] in
+        [ marker? . key kw . value_sep . int_val ]
+    
+    let mountd_entry    = int_entry "MOUNTD_PORT"
+    let lockd_entry     = int_entry "LOCKD_TCPPORT"
+                        | int_entry "LOCKD_UDPPORT"
+    let statd_entry     = int_entry "STATD_PORT"
+    let rquotad_entry   = int_entry "RQUOTAD_PORT"
+    
+    let entry           = mountd_entry
+                        | lockd_entry
+                        | statd_entry
+                        | rquotad_entry
+    
+    let record          = indent . entry . eol
+    
+    let lns             = ( record | comment | empty ) *
+
+    let filter          = incl "/etc/sysconfig/nfs"
+                        . Util.stdexcl
+              
+    let xfm             = transform lns filter
+
+(* /etc/sysconfig/nfs test runs *)
+
+    test lns get "MOUNTD_PORT=892\n" = { "MOUNTD_PORT" = "892" }
+    
+    test lns get "# MOUNTD_PORT=892\n" =
+      { "MOUNTD_PORT" = "892"
+          { "commented" } }
+    
+    test lns put "MOUNTD_PORT=892\n" after clear "/MOUNTD_PORT/commented" =
+      "# MOUNTD_PORT=892\n"
+    
+    test lns put "# MOUNTD_PORT=892\n" after rm "/MOUNTD_PORT/commented" =
+      "MOUNTD_PORT=892\n"
--- shellvars.aug.orig	2010-01-06 15:17:49.604496695 -0500
+++ shellvars.aug	2010-01-06 15:18:02.609514219 -0500
@@ -72,7 +72,6 @@
       sc_incl "nasd" .
       sc_incl "netconsole" .
       sc_incl "network" .
-      sc_incl "nfs" .
       sc_incl "ntpd" .
       sc_incl "prelink" .
       sc_incl "readonly-root" .

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]