diff options
author | Daniil Baturin <daniil@baturin.org> | 2025-01-20 19:15:10 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-20 19:15:10 +0000 |
commit | a375860a302a224722d254c31a1cb210cb12d972 (patch) | |
tree | 96217a1eaf38c910e183c30f2adab865b409e916 /src/vyconfd.ml | |
parent | 5ae7f4150091efb66c6f9946df81adde3ddc6ace (diff) | |
parent | 5cb1952f52a8a67905a9361364a0c0823d44ed03 (diff) | |
download | vyconf-a375860a302a224722d254c31a1cb210cb12d972.tar.gz vyconf-a375860a302a224722d254c31a1cb210cb12d972.zip |
Merge pull request #13 from jestabro/mutable-world
T7046: T6946: add ability to reload reference tree at runtime
Diffstat (limited to 'src/vyconfd.ml')
-rw-r--r-- | src/vyconfd.ml | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/vyconfd.ml b/src/vyconfd.ml index 7c4caeb..004ed6f 100644 --- a/src/vyconfd.ml +++ b/src/vyconfd.ml @@ -143,6 +143,17 @@ let validate world token (req: request_validate) = response_tmpl with Session.Session_error msg -> {response_tmpl with status=Fail; error=(Some msg)} +let reload_reftree world (_req: request_reload_reftree) = + let config = world.Session.vyconf_config in + let reftree = + Startup.read_reference_tree (FP.concat config.reftree_dir config.reference_tree) + in + match reftree with + | Ok reftree -> + world.reference_tree <- reftree; + {response_tmpl with status=Success} + | Error s -> {response_tmpl with status=Fail; error=(Some s)} + let send_response oc resp = let enc = Pbrt.Encoder.create () in let%lwt () = encode_pb_response resp enc |> return in @@ -167,6 +178,7 @@ let rec handle_connection world ic oc () = match req with | _, Status -> response_tmpl | _, Setup_session r -> setup_session world r + | _, Reload_reftree r -> reload_reftree world r | None, _ -> {response_tmpl with status=Fail; output=(Some "Operation requires session token")} | Some t, Teardown _ -> teardown t | Some t, Configure r -> enter_conf_mode r t @@ -220,7 +232,7 @@ let read_reference_tree file = let make_world config dirs = let open Session in (* the reference_tree json file is generated at vyos-1x build time *) - let reftree = read_reference_tree (FP.concat config.config_dir config.reference_tree) in + let reftree = read_reference_tree (FP.concat config.reftree_dir config.reference_tree) in let running_config = CT.make "" in {running_config=running_config; reference_tree=reftree; vyconf_config=config; dirs=dirs} |