Note: I made a module for "housekeeping" stuff (src/startup.ml) and moved relevant functions from vyconfd.ml to there.
The idea is that we load all interface definitions from a directory, in VyOS it could be /usr/share/vyos/interfaces, and we need a function for this. The function will have type:
val load_interface_definitions : string -> Reference_tree.t
The function should panic if an error occurs, see load_config. I took care of errors that come from the Xml module, so the only exception you need to catch is Bad_interface_definition
For those who want to take it up:
To make a root node for the reference tree, use
let root = Vytree.make Reference_tree.default_data "root" in ...
The function for loading a reference tree from file is Reference_tree.load_from xml : Reference_tree.t -> string -> Reference_tree.t
To get a list of files in a dir, there's a handy function in the fileutils library, FileUtil.ls : string -> string list
Given a dir, you can make a list of absolute paths from it with List.map function, the rest is List.fold_left , wrapped in a try/with block.
You can find the List module docs here: http://caml.inria.fr/pub/docs/manual-ocaml/libref/List.html (one thing of note is that both map and fold_left take the function as their first argument).
If you want to take it up and have any questions, feel free to ask.