Skip to content

Commit

Permalink
Pythonpaste: new lens for Python Paste configs.
Browse files Browse the repository at this point in the history
Added a new lense file for Python Paste configs. This is useful
for editing a variety of Openstack config files including,
Nova api-paste.ini, Glance *.ini files, keystone.conf, and the
swift config files.
  • Loading branch information
dprince authored and David Lutterkort committed Jul 19, 2012
1 parent b7c6216 commit 730cdda
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 0 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Contributions by:
Joel Nimety <[email protected]>
Matt Palmer <[email protected]>
Bill Pemberton <[email protected]>
Dan Prince <[email protected]>
Alan Pevec <[email protected]>
Brett Porter <[email protected]>
Robin Lee Powell <[email protected]>
Expand Down
54 changes: 54 additions & 0 deletions lenses/pythonpaste.aug
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
(* Python paste config file lens for Augeas
Author: Dan Prince <[email protected]>
*)
module PythonPaste =
autoload xfm

(************************************************************************
* INI File settings
*************************************************************************)

let comment = IniFile.comment "#" "#"

let sep = IniFile.sep "=" "="

let eol = Util.eol

(************************************************************************
* ENTRY
*************************************************************************)

let url_entry = /\/[\/A-Za-z0-9.-_]* ?[:|=] [A-Za-z0-9.-_]+/

let no_inline_comment_entry (kw:regexp) (sep:lens) (comment:lens)
= [ key kw . sep . IniFile.sto_to_eol? . eol ]
| comment
| [ seq "urls" . store url_entry . eol ]

let entry_re = ( /[A-Za-z][:#A-Za-z0-9._-]+/ )

let entry = no_inline_comment_entry entry_re sep comment

(************************************************************************
* RECORD
*************************************************************************)

let title = IniFile.title IniFile.record_re

let record = IniFile.record title entry

(************************************************************************
* LENS & FILTER
*************************************************************************)
let lns = IniFile.lns record comment

let filter = ((incl "/etc/glance/*.ini")
. (incl "/etc/keystone/keystone.conf")
. (incl "/etc/nova/api-paste.ini")
. (incl "/etc/swift/swift.conf")
. (incl "/etc/swift/proxy-server.conf")
. (incl "/etc/swift/account-server/*.conf")
. (incl "/etc/swift/container-server/*.conf")
. (incl "/etc/swift/object-server/*.conf"))

let xfm = transform lns filter
41 changes: 41 additions & 0 deletions lenses/tests/test_pythonpaste.aug
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module Test_pythonpaste =

let conf = "
#blah blah
[main]
pipeline = hello

[composite:main]
use = egg:Paste#urlmap
/v2.0 = public_api
/: public_version_api
"

test PythonPaste.lns get conf =
{ }
{ "#comment" = "blah blah" }
{ "main"
{ "pipeline" = "hello" }
{ }
}
{ "composite:main"
{ "use" = "egg:Paste#urlmap" }
{ "1" = "/v2.0 = public_api" }
{ "2" = "/: public_version_api" }
}


test PythonPaste.lns put conf after
set "main/pipeline" "goodbye";
set "composite:main/3" "/v3: a_new_api_version"
= "
#blah blah
[main]
pipeline = goodbye

[composite:main]
use = egg:Paste#urlmap
/v2.0 = public_api
/: public_version_api
/v3: a_new_api_version
"
1 change: 1 addition & 0 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ lens_tests = \
lens-protocols.sh \
lens-puppet.sh \
lens-puppetfileserver.sh \
lens-pythonpaste.sh \
lens-qpid.sh \
lens-reprepro_uploaders.sh \
lens-resolv.sh \
Expand Down

0 comments on commit 730cdda

Please sign in to comment.