Page MenuHomeVyOS Platform

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

Description

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.

Details

Difficulty level
Easy (less than an hour)

Event Timeline

@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.

syncer changed the subtype of this task from "Task" to "Enhancement".Oct 20 2018, 7:10 AM