Permalink
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/xs_client_cli.ml
View
96 cli/xs.1
@@ -0,0 +1,96 @@
+.TH xs 1 "November 19, 2011" "version 0.1" "Xen"
+.SH NAME
+xs \- interact with XenStore from the commandline
+.SH SYNOPSIS
+.B xs
+[\-h] [\-v] [-t TIMEOUT] subcommand [args]
+.SH DESCRIPTION
+Description should go here.
+.PP
+More description here.
+.SH OPTIONS
+.TP
+\-h
+display a short help text
+.TP
+\-v
+display verbose output
+.TP
+\-t TIMEOUT
+timeout with failure after TIMEOUT seconds
+.SH SUBCOMMANDS
+.TP
+read path
+print the value stored at "path"
+.TP
+directory path
+list the direct children of the node stored at "path"
+.TP
+write path newvalue
+store the value "newvalue" at "path"
+.TP
+wait expr
+block until the expression "expr" evaluates to TRUE
+.SH EXAMPLES
+.TP
+Read the value stored at /foo:
+.B xs
+read /foo
+.PP
+.TP
+Write to the value stored at /foo:
+.B xs
+write /bar value
+.PP
+.TP
+Wait until the key /foo exists:
+.B xs
+wait /foo
+.PP
+.TP
+Wait until the key /foo is deleted:
+.B xs
+wait "not(/foo)"
+.PP
+.TP
+Wait until either the key /foo or the key /bar is created:
+.B xs
+wait /foo or /bar
+.PP
+.TP
+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)"
+.PP
+.TP
+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.
+BACK=/local/domain/0
+
+FRONT=/local/domain/2
+
+.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
+.PP
+.TP
+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
+.PP
+.SH EXIT STATUS
+xs returns a zero exist status if it succeeds. Non zero is returned in
+case of failure.
+.SH AUTHOR
+David Scott (dave (at) recoil.org)
+.SH SEE ALSO
+xe(1)
View
9 cli/xs_client_cli.ml
@@ -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.