Hello,
Raphael Pinson and me wrote a lense for cgrules.conf configuration file
and a test file for it.
(cgrules.conf file is a part of libcgroup tool
-http://libcg.sourceforge.net/)
I'm sending them in attachment.
If there are any problems please ping me.
Thanks,
Ivana Hutarova Varekova
(*
Module: cgrules
Parses /etc/cgrules.conf
Author:
Raphael Pinson <[email protected]>
Ivana Hutarova Varekova <[email protected]>
About: Licence
This file is licensed under the LGPLv2+, like the rest of Augeas.
About: Lens Usage
Sample usage of this lens in augtool:
About: Configuration files
This lens applies to /etc/cgconfig.conf. See <filter>.
*)
module Cgrules =
autoload xfm
(************************************************************************
* Group: USEFUL PRIMITIVES
*************************************************************************)
(* Group: Separators *)
(* Variable: ws *)
let ws = del /[ \t]+/ " "
(* Group: Comments and empty lines *)
(* Variable: eol *)
let eol = Util.eol
(* Variable: comment *)
let comment = Util.comment
(* Variable: empty *)
let empty = Util.empty
(* Group: Generic primitive definitions *)
(* Variable: name *)
let name = /[...@%\# \t\n][^ \t\n]*/
(* Variable: ctrl_key *)
let ctrl_key = /[^ \t\n\/]+/
(* Variable: ctrl_value *)
let ctrl_value = /[^ \t\n]+/
(************************************************************************
* Group: CONTROLLER
*************************************************************************)
(* Variable: controller *)
let controller = ws . [ key ctrl_key . ws . store ctrl_value ]
let more_controller = Util.del_str "%" . controller . eol
(************************************************************************
* Group: RECORDS
*************************************************************************)
let generic_record (lbl:string) (lns:lens) =
[ label lbl . lns
. controller . eol
. more_controller* ]
(* Variable: user_record *)
let user_record = generic_record "user" (store name)
(* Variable: group_record *)
let group_record = generic_record "group" (Util.del_str "@" . store name)
(************************************************************************
* Group: LENS & FILTER
*************************************************************************)
(* View: lns
The sudoers lens, any amount of
* <empty> lines
* <comment>
* <user_record>
* <group_record>
*)
let lns = ( empty | comment | user_record | group_record )*
let xfm = transform lns (incl "/etc/cgrules.conf")
module Test_cgrules =
let conf="#cgrules test configuration file
poooeter cpu test1/
% memory test2/
@somegroup cpu toto/
% devices toto1/
% memory toto3/
"
test Cgrules.lns get conf =
{ "#comment" = "cgrules test configuration file" }
{ "user" = "poooeter"
{ "cpu" = "test1/" }
{ "memory" = "test2/" } }
{ "group" = "somegroup"
{ "cpu" = "toto/" }
{ "devices" = "toto1/" }
{ "memory" = "toto3/" } }
test Cgrules.lns put conf after
set "user/cpu" "test3/";
rm "user/memory";
rm "group";
insa "devices" "user/*[last()]";
set "user/devices" "newtest/";
insb "memory" "user/devices";
set "user/memory" "memtest/"
= "#cgrules test configuration file
poooeter cpu test3/
% memory memtest/
% devices newtest/
"
_______________________________________________
augeas-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/augeas-devel