Browse files

cli: add new sub-command "directory <key>"

  • Loading branch information...
1 parent 4c72876 commit 08e93d65e60aade766b7cac4c31857fe1640d2ae David Scott committed Apr 6, 2012
Showing with 105 additions and 0 deletions.
  1. +96 −0 cli/xs.1
  2. +9 −0 cli/
96 cli/xs.1
@@ -0,0 +1,96 @@
+.TH xs 1 "November 19, 2011" "version 0.1" "Xen"
+xs \- interact with XenStore from the commandline
+.B xs
+[\-h] [\-v] [-t TIMEOUT] subcommand [args]
+Description should go here.
+More description here.
+display a short help text
+display verbose output
+timeout with failure after TIMEOUT seconds
+read path
+print the value stored at "path"
+directory path
+list the direct children of the node stored at "path"
+write path newvalue
+store the value "newvalue" at "path"
+wait expr
+block until the expression "expr" evaluates to TRUE
+Read the value stored at /foo:
+.B xs
+read /foo
+Write to the value stored at /foo:
+.B xs
+write /bar value
+Wait until the key /foo exists:
+.B xs
+wait /foo
+Wait until the key /foo is deleted:
+.B xs
+wait "not(/foo)"
+Wait until either the key /foo or the key /bar is created:
+.B xs
+wait /foo or /bar
+Wait until either the key /foo is deleted or the key /bar is set to value "hello":
+.B xs
+wait "not(/foo) or (/bar = hello)"
+Add a disk device to Xen domain id 2, backed by /dev/disk from Xen domain id 0. Note this command will return quickly and the disk will be connected asynchronously.
+.B xs
+write $BACK/frontend-id=2 and \\
+ $BACK/online=1 and \\
+ $BACK/removable=1 and \\
+ $BACK/state=1 and \\
+ $BACK/dev=XXX and \\
+ $BACK/mode=XXX and \\
+ $BACK/params=/dev/disk and \\
+ $FRONT/backend-id=0 and \\
+ $FRONT/state=1 and \\
+ $FRONT/virtual-device=51712 and \\
+ $FRONT/device-type=disk
+Wait until a disk device has been successfully unplugged, or an error happens, with a timeout of 30 seconds:
+.B xs
+wait -t 30 not($BACK/hotplug-status) or \\
+ $FRONT/errorXXX
+xs returns a zero exist status if it succeeds. Non zero is returned in
+case of failure.
+David Scott (dave (at)
9 cli/
@@ -114,6 +114,8 @@ let usage () =
" -- read the value stored at <key>, or fail if it doesn't exist";
bin " write <key=val> [and keyN=valN]*";
" -- write the key value pair(s)";
+ bin " directory <key>";
+ " -- list the direct children of <key>";
bin " wait <expr>";
" -- block until the <expr> is true";
@@ -155,6 +157,13 @@ let main () =
lwt v = read xs key in
Lwt_io.write Lwt_io.stdout v
) >> return ()
+ | [ "directory"; key ] ->
+ lwt client = make () in
+ with_xs client
+ (fun xs ->
+ lwt ls = directory xs key in
+ Lwt_list.iter_s (fun x -> Lwt_io.write Lwt_io.stdout (x ^ "\n")) ls
+ ) >> return ()
| "write" :: expr ->
begin lwt items = try_lwt
let expr = String.concat " " expr |> parse_expr in

0 comments on commit 08e93d6

Please sign in to comment.