This tool parses an XAPI database XML file, builds an in-memory relational database,
and provides a prompt-oriented interface to explore the database using OpaqueRef
identifiers.
unix: https://ocaml.org/manual/5.4/api/Unix.htmlxmlm: https://erratique.ch/software/xmlmlinenoise: https://github.com/ocaml-community/ocaml-linenoise
- Show help:
dune exec xapidb_in_shell -- -help- Open a REPL using local sample.xml file:
dune exec xapidb_in_shell -- sample.xml- Query a specific
OpaqueReffrom sample.xml:
dune exec xapidb_in_shell -- sample.xml 3ec68fc0-3c60-ffa4-e499-6142c369ea39- Use a remote database:
dune exec xapidb_in_shell -- -host 10.1.38.11 /var/lib/xcp/state.db- A full interactive REPL is not available yet (See section below).
- Local and remote databases work.
- The goal is to provide an interactive shell with the following commands:
-
ls: display all fields of the currentOpaqueRefor tables if noOpaqueRefis selected -
ls <table>: list allOpaqueRefof the given table -
cd <opaqueref>: open theOpaqueRef -
cd ..: navigate up -
pwd: show the path we followed -
help: display available commands -
exit: exit the REPL
-
- With multiple
OpaqueRef:
❯ dune exec xapidb_in_shell -- sample.xml 082d1948-c3f7-91ae-8793-568c9e888810 3ec68fc0-3c60-ffa4-e499-6142c369ea39
Entering directory '/home/gthouvenin/devel/ocaml/ocaml_sandkasten'
Leaving directory '/home/gthouvenin/devel/ocaml/ocaml_sandkasten'
Found 3 entries in DB
----------------------------------------
OpaqueRef 082d1948-c3f7-91ae-8793-568c9e888810:
table Certificate
uuid bd62e7eb-ab54-82df-9c76-bea4981bf48d
type host_internal
name
host 3ec68fc0-3c60-ffa4-e499-6142c369ea39
ref 082d1948-c3f7-91ae-8793-568c9e888810
----------------------------------------
OpaqueRef 3ec68fc0-3c60-ffa4-e499-6142c369ea39:
table host
uuid 6ff4b261-3e37-47f8-ace1-53556da6fcf2
CERTIFICATEs ('OpaqueRef:2b3b5149-e164-25b8-3e5c-b3da1765d060'%.'OpaqueRef:082d1948-c3f7-91ae-8793-568c9e888810')
ref 3ec68fc0-3c60-ffa4-e499-6142c369ea39- Without
OpaqueRefit starts the REPL
❯ dune exec xapidb_in_shell sample.xml
Found 3 OpaqueRefs in DB
XAPI DB 0.1, type 'help' for more information
no ref > ls
Certificate
Cluster
Cluster_host
host
pool_update
probe_result
role
no ref > cd 082d1948-c3f7-91ae-8793-568c9e888810
082d1948> ls
OpaqueRef 082d1948-c3f7-91ae-8793-568c9e888810:
table Certificate
uuid bd62e7eb-ab54-82df-9c76-bea4981bf48d
type host_internal
name
host 3ec68fc0-3c60-ffa4-e499-6142c369ea39
ref 082d1948-c3f7-91ae-8793-568c9e888810
082d1948> quit
Bye