summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2018-09-02 13:05:37 +0200
committerDaniil Baturin <daniil@baturin.org>2018-09-02 13:05:37 +0200
commit81f662f716dbc36129957cde5b97284e6e2f4181 (patch)
treee9edf8e4e21e3200de7d1c5498166adb479335bc
parentf8a647dd798fefcb51be9db8ff32d1e4e77d5134 (diff)
downloadlibvyosconfig-81f662f716dbc36129957cde5b97284e6e2f4181.tar.gz
libvyosconfig-81f662f716dbc36129957cde5b97284e6e2f4181.zip
T824: add support for node renaming.
-rw-r--r--debian/changelog6
-rw-r--r--lib/bindings.ml9
2 files changed, 15 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog
index ae5d6bc..cdfb586 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+libvyosconfig0 (0.0.2) unstable; urgency=medium
+
+ * Add support for node renaming.
+
+ -- Daniil Baturin <daniil@baturin.org> Sun, 02 Sep 2018 13:04:28 +0200
+
libvyosconfig0 (0.0.1) unstable; urgency=low
* Created the package
diff --git a/lib/bindings.ml b/lib/bindings.ml
index 4b8d04b..e2a0e71 100644
--- a/lib/bindings.ml
+++ b/lib/bindings.ml
@@ -64,6 +64,14 @@ let delete_node c_ptr path =
Root.set c_ptr new_ct;
0 (* return 0 *)
+let rename_node c_ptr path newname =
+ let ct = Root.get c_ptr in
+ let path = Pcre.split ~rex:(Pcre.regexp "\\s+") path in
+ if not (Vytree.exists ct path) then 1 else
+ let new_ct = Vytree.rename ct path newname in
+ Root.set c_ptr new_ct;
+ 0 (* return 0 *)
+
let set_tag c_ptr path =
let ct = Root.get c_ptr in
let path = Pcre.split ~rex:(Pcre.regexp "\\s+") path in
@@ -124,6 +132,7 @@ struct
let () = I.internal "set_valueless" ((ptr void) @-> string @-> returning int) set_valueless
let () = I.internal "delete_value" ((ptr void) @-> string @-> string @-> returning int) delete_value
let () = I.internal "delete_node" ((ptr void) @-> string @-> returning int) delete_node
+ let () = I.internal "rename_node" ((ptr void) @-> string @-> string @-> returning int) rename_node
let () = I.internal "set_tag" ((ptr void) @-> string @-> returning int) set_tag
let () = I.internal "is_tag" ((ptr void) @-> string @-> returning int) is_tag
let () = I.internal "exists" ((ptr void) @-> string @-> returning int) exists