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

[augeas-devel] augeas: master - Ntp: support more commands



Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=bccf692ec237528050cd5d6fe62b3ae7b913a0b4
Commit:        bccf692ec237528050cd5d6fe62b3ae7b913a0b4
Parent:        7ce058488369836ed7b2f9550c81805d4dcd6a19
Author:        David Lutterkort <lutter redhat com>
AuthorDate:    Fri May 29 12:12:55 2009 -0700
Committer:     David Lutterkort <lutter redhat com>
CommitterDate: Fri May 29 12:12:55 2009 -0700

Ntp: support more commands

* process 'broadcastdelay'
* process enable/disable flags
* process leapfile

Minor amount of code cleanup

Fixes bug #62, reported by Frank Sweetser
---
 lenses/ntp.aug            |   33 ++++++++++++++++++++++-----------
 lenses/tests/test_ntp.aug |   11 +++++++++++
 2 files changed, 33 insertions(+), 11 deletions(-)

diff --git a/lenses/ntp.aug b/lenses/ntp.aug
index d1b2615..f324ba9 100644
--- a/lenses/ntp.aug
+++ b/lenses/ntp.aug
@@ -22,6 +22,9 @@ module Ntp =
     let empty   = [ del /[ \t]*\n/ "\n" ]
 
 
+    let kv (k:regexp) (v:regexp) =
+      [ key k . sep_spc. store v . eol ]
+
     (* Define generic record *)
     let record (kw:regexp) (value:lens) =
       [ key kw . sep_spc . store word . value . eol ]
@@ -42,13 +45,24 @@ module Ntp =
     let fudge_opt  = [ sep_spc . key fudge_opt_re . sep_spc . store word ]
     let fudge_record = record "fudge" fudge_opt?
 
-    (* Define simple settings *)
-    let simple_setting (kw:string) = [ key kw . sep_spc . store word . eol ]
+    (* Define simple settings, see miscopt.html in ntp docs *)
+    let flags =
+      let flags_re = /auth|bclient|calibrate|kernel|monitor|ntp|pps|stats/ in
+      let flag = [ label "flag" . store flags_re ] in
+        [ key /enable|disable/ . (sep_spc . flag)* . eol ]
+
+    let simple_setting (k:regexp) = kv k word
+
+    (* Still incomplete, misses logconfig, phone, setvar, tinker, tos,
+       trap, ttl *)
+    let simple_settings =
+        kv "broadcastdelay" Rx.decimal
+      | flags
+      | simple_setting /driftfile|leapfile|logfile|includefile/
+	  | simple_setting "statsdir"
+
+    (* Misc commands, see miscopt.html in ntp docs *)
 
-    let simple_settings = simple_setting "driftfile"
-                        | simple_setting "logfile"
-			| simple_setting "statsdir"
-    
     (* Define restrict *)
     let restrict_record   =
       let action    = [ label "action" . sep_spc . store word ] in
@@ -82,19 +96,16 @@ module Ntp =
 
     (* Authentication commands, see authopt.html#cmd; incomplete *)
     let auth_command =
-      [ key /controlkey|keys|keysdir|requestkey/ . 
+      [ key /controlkey|keys|keysdir|requestkey/ .
             sep_spc . store word . eol ]
      | [ key /autokey|revoke/ . [sep_spc . store word]? . eol ]
      | [ key /trustedkey/ . [ sep_spc . label "key" . store word ]+ . eol ]
 
-    (* Includefile *)
-    let files = [ key /includefile/ . sep_spc . store word . eol ]
-
     (* Define lens *)
 
     let lns = ( comment | empty | command_record | fudge_record
               | restrict_record | simple_settings | statistics_record
-              | filegen_record | files | broadcastclient
+              | filegen_record | broadcastclient
               | auth_command )*
 
     let filter = (incl "/etc/ntp.conf")
diff --git a/lenses/tests/test_ntp.aug b/lenses/tests/test_ntp.aug
index f56a924..3bdd60b 100644
--- a/lenses/tests/test_ntp.aug
+++ b/lenses/tests/test_ntp.aug
@@ -134,3 +134,14 @@ filegen clockstats file clockstats type day enable nolink
 
   test Ntp.auth_command get "trustedkey 42\n" = 
      { "trustedkey" { "key" = "42" } }
+
+  test Ntp.lns get "broadcastdelay 0.008\n" =
+     { "broadcastdelay" = "0.008" }
+
+  test Ntp.lns get "enable auth calibrate\ndisable kernel stats\n" =
+     { "enable"
+         { "flag" = "auth" }
+         { "flag" = "calibrate" } }
+     { "disable"
+         { "flag" = "kernel" }
+         { "flag" = "stats" } }



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