summaryrefslogtreecommitdiff
path: root/src/vyconfd.ml
diff options
context:
space:
mode:
Diffstat (limited to 'src/vyconfd.ml')
-rw-r--r--src/vyconfd.ml27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/vyconfd.ml b/src/vyconfd.ml
index f3816d4..59425ee 100644
--- a/src/vyconfd.ml
+++ b/src/vyconfd.ml
@@ -1,11 +1,14 @@
open Lwt
-open Defaults
-open Vyconf_config
-open Vyconf_pb
-open Vyconf_types
+
+open Vyconf_connect.Vyconf_types
+open Vyconf_connect.Vyconf_pb
+open Vyconfd_config.Defaults
module FP = FilePath
module CT = Vyos1x.Config_tree
+module Gen = Vyos1x.Generate
+module Session = Vyconfd_config.Session
+module Directories = Vyconfd_config.Directories
(* On UNIX, self_init uses /dev/random for seed *)
let () = Random.self_init ()
@@ -94,7 +97,7 @@ let exists world token (req: request_exists) =
let get_value world token (req: request_get_value) =
try
- let () = (Lwt_log.debug @@ Printf.sprintf "[%s]\n" (Util.string_of_list req.path)) |> Lwt.ignore_result in
+ let () = (Lwt_log.debug @@ Printf.sprintf "[%s]\n" (Vyos1x.Util.string_of_list req.path)) |> Lwt.ignore_result in
let value = Session.get_value world (find_session token) req.path in
let fmt = Option.value req.output_format ~default:Out_plain in
let value_str =
@@ -110,8 +113,8 @@ let get_values world token (req: request_get_values) =
let fmt = Option.value req.output_format ~default:Out_plain in
let values_str =
(match fmt with
- | Out_plain -> Util.string_of_list @@ List.map (Printf.sprintf "\'%s\'") values
- | Out_json -> Util.json_of_list values)
+ | Out_plain -> Vyos1x.Util.string_of_list @@ List.map (Printf.sprintf "\'%s\'") values
+ | Out_json -> Vyos1x.Util.json_of_list values)
in {response_tmpl with output=(Some values_str)}
with Session.Session_error msg -> {response_tmpl with status=Fail; error=(Some msg)}
@@ -121,8 +124,8 @@ let list_children world token (req: request_list_children) =
let fmt = Option.value req.output_format ~default:Out_plain in
let children_str =
(match fmt with
- | Out_plain -> Util.string_of_list @@ List.map (Printf.sprintf "\'%s\'") children
- | Out_json -> Util.json_of_list children)
+ | Out_plain -> Vyos1x.Util.string_of_list @@ List.map (Printf.sprintf "\'%s\'") children
+ | Out_json -> Vyos1x.Util.json_of_list children)
in {response_tmpl with output=(Some children_str)}
with Session.Session_error msg -> {response_tmpl with status=Fail; error=(Some msg)}
@@ -137,12 +140,12 @@ let send_response oc resp =
let enc = Pbrt.Encoder.create () in
let%lwt () = encode_response resp enc |> return in
let%lwt resp_msg = Pbrt.Encoder.to_bytes enc |> return in
- let%lwt () = Message.write oc resp_msg in
+ let%lwt () = Vyconf_connect.Message.write oc resp_msg in
Lwt.return ()
let rec handle_connection world ic oc fd () =
try%lwt
- let%lwt req_msg = Message.read ic in
+ let%lwt req_msg = Vyconf_connect.Message.read ic in
let%lwt req =
try
let envelope = decode_request_envelope (Pbrt.Decoder.of_bytes req_msg) in
@@ -196,7 +199,7 @@ let main_loop basepath world () =
let load_interface_definitions dir =
(* let open Session in *)
- let reftree = Startup.load_interface_definitions dir in
+ let reftree = Gen.load_interface_definitions dir in
match reftree with
| Ok r -> r
| Error s -> Startup.panic s