diff options
author | John Estabrook <jestabro@vyos.io> | 2023-05-01 11:04:18 -0500 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2023-05-10 22:52:25 -0500 |
commit | 68dc8217310dca1a4eddaa5145ba934037869a61 (patch) | |
tree | 25eb3bd720463289dfdca399e833bfd2c6cf0a1f | |
parent | 690ea5bbd5c0c569796a80aeff1ff7c2d6b83b87 (diff) | |
download | vyos1x-config-68dc8217310dca1a4eddaa5145ba934037869a61.tar.gz vyos1x-config-68dc8217310dca1a4eddaa5145ba934037869a61.zip |
T5194: import load_interface_definitions from vyconf
-rw-r--r-- | src/generate.ml | 16 | ||||
-rw-r--r-- | src/generate.mli | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/generate.ml b/src/generate.ml new file mode 100644 index 0000000..c90cfc9 --- /dev/null +++ b/src/generate.ml @@ -0,0 +1,16 @@ +(* Load interface definitions from a directory into a reference tree *) +let load_interface_definitions dir = + let open Reference_tree in + let relative_paths = FileUtil.ls dir in + let absolute_paths = + try Ok (List.map Util.absolute_path relative_paths) + with Sys_error no_dir_msg -> Error no_dir_msg + in + let load_aux tree file = + load_from_xml tree file + in + try begin match absolute_paths with + | Ok paths -> Ok (List.fold_left load_aux default paths) + | Error msg -> Error msg end + with Bad_interface_definition msg -> Error msg + diff --git a/src/generate.mli b/src/generate.mli new file mode 100644 index 0000000..cbb03ff --- /dev/null +++ b/src/generate.mli @@ -0,0 +1 @@ +val load_interface_definitions : string -> (Reference_tree.t, string) result |