[Libguestfs] [PATCH] New API: Add aug-clear call for clearing an Augeas node.

Richard W.M. Jones rjones at redhat.com
Tue Apr 13 17:43:19 UTC 2010


-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming blog: http://rwmj.wordpress.com
Fedora now supports 80 OCaml packages (the OPEN alternative to F#)
http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
-------------- next part --------------
>From 4085d9032f6e574a8116fec9f0e2bb7d23cadc56 Mon Sep 17 00:00:00 2001
From: Richard Jones <rjones at redhat.com>
Date: Tue, 13 Apr 2010 18:42:27 +0100
Subject: [PATCH] New API: Add aug-clear call for clearing an Augeas node.

---
 daemon/augeas.c  |   20 ++++++++++++++++++++
 src/MAX_PROC_NR  |    2 +-
 src/generator.ml |   14 +++++++++++++-
 3 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/daemon/augeas.c b/daemon/augeas.c
index 36b36b8..a9ad91f 100644
--- a/daemon/augeas.c
+++ b/daemon/augeas.c
@@ -210,6 +210,26 @@ do_aug_set (const char *path, const char *val)
 }
 
 int
+do_aug_clear (const char *path)
+{
+#ifdef HAVE_AUGEAS
+  int r;
+
+  NEED_AUG (-1);
+
+  r = aug_set (aug, path, NULL);
+  if (r == -1) {
+    reply_with_error ("Augeas clear failed");
+    return -1;
+  }
+
+  return 0;
+#else
+  NOT_AVAILABLE (-1);
+#endif
+}
+
+int
 do_aug_insert (const char *path, const char *label, int before)
 {
 #ifdef HAVE_AUGEAS
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 1cf253f..b4249c4 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-238
+239
diff --git a/src/generator.ml b/src/generator.ml
index 532aba9..79a10dd 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -1238,7 +1238,12 @@ matches exactly one node, the C<value> is returned.");
    [], (* XXX Augeas code needs tests. *)
    "set Augeas path to value",
    "\
-Set the value associated with C<path> to C<value>.");
+Set the value associated with C<path> to C<val>.
+
+In the Augeas API, it is possible to clear a node by setting
+the value to NULL.  Due to an oversight in the libguestfs API
+you cannot do that with this call.  Instead you must use the
+C<guestfs_aug_clear> call.");
 
   ("aug_insert", (RErr, [String "augpath"; String "label"; Bool "before"]), 21, [Optional "augeas"],
    [], (* XXX Augeas code needs tests. *)
@@ -4468,6 +4473,13 @@ you would call this with pc = 100 which expands the logical volume
 as much as possible, using all remaining free space in the volume
 group.");
 
+  ("aug_clear", (RErr, [String "augpath"]), 239, [Optional "augeas"],
+   [], (* XXX Augeas code needs tests. *)
+   "clear Augeas path",
+   "\
+Set the value associated with C<path> to C<NULL>.  This
+is the same as the L<augtool(1)> C<clear> command.");
+
 ]
 
 let all_functions = non_daemon_functions @ daemon_functions
-- 
1.6.6.1



More information about the Libguestfs mailing list