Page MenuHomeVyOS Platform

Add a function from loading interface definitions from a directory to the Startup module
Not ApplicablePublicENHANCEMENT

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

Version
1.3
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Unspecified (please specify)

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
dmbaturin removed projects: Bugs, VyConf, VyOS 2.0.x.
dmbaturin set Version to 1.3.
dmbaturin edited a custom field.
dmbaturin set Is it a breaking change? to Unspecified (possibly destroys the router).
dmbaturin set Issue type to Unspecified (please specify).