diff options
author | John Estabrook <jestabro@vyos.io> | 2025-01-14 12:33:06 -0600 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2025-01-15 18:42:07 -0600 |
commit | 5cb1952f52a8a67905a9361364a0c0823d44ed03 (patch) | |
tree | 96217a1eaf38c910e183c30f2adab865b409e916 /src/vyconfd.ml | |
parent | 41bb56f9a69001100c5a003f3a0abb03afd3bae2 (diff) | |
download | vyconf-5cb1952f52a8a67905a9361364a0c0823d44ed03.tar.gz vyconf-5cb1952f52a8a67905a9361364a0c0823d44ed03.zip |
T7046: add request reload_reftree
Diffstat (limited to 'src/vyconfd.ml')
-rw-r--r-- | src/vyconfd.ml | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/vyconfd.ml b/src/vyconfd.ml index 4e8708d..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 |