Add a function from loading interface definitions from a directory to the Startup module
Open, NormalPublic


Note: I made a module for "housekeeping" stuff (src/ and moved relevant functions from 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, : string -> string list
Given a dir, you can make a list of absolute paths from it with function, the rest is List.fold_left , wrapped in a try/with block.
You can find the List module docs here: (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.


Difficulty level
Easy (less than an hour)
shon added a subscriber: shon.Jan 1 2017, 5:46 AM
shon added a comment.EditedJan 13 2017, 3:23 AM

@dmbaturin, you can probably assign this one to me, if you feel comfortable doing so. I think I'm nearly done. I'd just like to put together some decent test cases before making a PR.

dmbaturin assigned this task to shon.Jan 13 2017, 7:16 AM