[augeas-devel] [PATCH 2/4] new lens for Carbon cache.

Marc Fournier marc.fournier at camptocamp.com
Mon Oct 8 07:01:25 UTC 2012


---
 lenses/carbon.aug            |   30 +++++++++++++++
 lenses/tests/test_carbon.aug |   84 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 114 insertions(+)
 create mode 100644 lenses/carbon.aug
 create mode 100644 lenses/tests/test_carbon.aug

diff --git a/lenses/carbon.aug b/lenses/carbon.aug
new file mode 100644
index 0000000..58d8fff
--- /dev/null
+++ b/lenses/carbon.aug
@@ -0,0 +1,30 @@
+(*
+Module: Carbon
+  Parses Carbon's configuration files
+  NB: whitelist.conf and blacklist.conf use a different syntax. This lens
+  doesn't support them.
+
+Author: Marc Fournier <marc.fournier at camptocamp.com>
+
+About: License
+  This file is licensed under the LGPL v2+, like the rest of Augeas.
+*)
+module Carbon =
+autoload xfm
+
+let comment = IniFile.comment "#" "#"
+let sep     = IniFile.sep "=" "="
+
+let entry   = IniFile.entry IniFile.entry_re sep comment
+let title   = IniFile.title IniFile.record_re
+let record  = IniFile.record title entry
+
+let lns     = IniFile.lns record comment
+
+let filter  = incl "/etc/carbon/carbon.conf"
+            . incl "/etc/carbon/relay-rules.conf"
+            . incl "/etc/carbon/rewrite-rules.conf"
+            . incl "/etc/carbon/storage-aggregation.conf"
+            . incl "/etc/carbon/storage-schemas.conf"
+
+let xfm     = transform lns filter
diff --git a/lenses/tests/test_carbon.aug b/lenses/tests/test_carbon.aug
new file mode 100644
index 0000000..e077569
--- /dev/null
+++ b/lenses/tests/test_carbon.aug
@@ -0,0 +1,84 @@
+(*
+Module: Test_Carbon
+  Provides unit tests for the <Carbon> lens.
+*)
+
+module Test_Carbon =
+
+let carbon_conf = "[cache]
+# Configure carbon directories.
+
+# Specify the user to drop privileges to
+# If this is blank carbon runs as the user that invokes it
+# This user must have write access to the local data directory
+USER =
+
+MAX_CACHE_SIZE = inf # comment at EOL
+LINE_RECEIVER_INTERFACE=0.0.0.0
+LINE_RECEIVER_PORT = 2003
+ENABLE_UDP_LISTENER = False
+
+[relay]
+LINE_RECEIVER_INTERFACE = 0.0.0.0
+LINE_RECEIVER_PORT = 2013
+PICKLE_RECEIVER_INTERFACE = 0.0.0.0
+PICKLE_RECEIVER_PORT = 2014
+"
+
+test Carbon.lns get carbon_conf =
+  { "cache"
+    { "#comment" = "Configure carbon directories." }
+    { }
+    { "#comment" = "Specify the user to drop privileges to" }
+    { "#comment" = "If this is blank carbon runs as the user that invokes it" }
+    { "#comment" = "This user must have write access to the local data directory" }
+    { "USER" }
+    { }
+    { "MAX_CACHE_SIZE" = "inf"
+      { "#comment" = "comment at EOL" }
+    }
+    { "LINE_RECEIVER_INTERFACE" = "0.0.0.0" }
+    { "LINE_RECEIVER_PORT" = "2003" }
+    { "ENABLE_UDP_LISTENER" = "False" }
+    { }
+  }
+  { "relay"
+    { "LINE_RECEIVER_INTERFACE" = "0.0.0.0" }
+    { "LINE_RECEIVER_PORT" = "2013" }
+    { "PICKLE_RECEIVER_INTERFACE" = "0.0.0.0" }
+    { "PICKLE_RECEIVER_PORT" = "2014" }
+  }
+
+let relay_rules_conf = "# You must have exactly one section with 'default = true'
+# Note that all destinations listed must also exist in carbon.conf
+# in the DESTINATIONS setting in the [relay] section
+[default]
+default = true
+destinations = 127.0.0.1:2004:a, 127.0.0.1:2104:b
+"
+
+test Carbon.lns get relay_rules_conf =
+  { "#comment" = "You must have exactly one section with 'default = true'" }
+  { "#comment" = "Note that all destinations listed must also exist in carbon.conf" }
+  { "#comment" = "in the DESTINATIONS setting in the [relay] section" }
+  { "default"
+    { "default" = "true" }
+    { "destinations" = "127.0.0.1:2004:a, 127.0.0.1:2104:b" }
+  }
+
+let storage_aggregation_conf = "# Aggregation methods for whisper files. Entries are scanned in order,
+# and first match wins. This file is scanned for changes every 60 seconds
+[max]
+pattern = \.max$
+xFilesFactor = 0.1
+aggregationMethod = max
+"
+
+test Carbon.lns get storage_aggregation_conf =
+  { "#comment" = "Aggregation methods for whisper files. Entries are scanned in order," }
+  { "#comment" = "and first match wins. This file is scanned for changes every 60 seconds" }
+  { "max"
+    { "pattern" = "\.max$" }
+    { "xFilesFactor" = "0.1" }
+    { "aggregationMethod" = "max" }
+  }
-- 
1.7.10.4




More information about the augeas-devel mailing list