summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2025-03-20 21:26:37 -0500
committerJohn Estabrook <jestabro@vyos.io>2025-03-31 00:50:30 -0500
commitbed066dbf1b6cf9d606c0f1f827cce30f4dcc430 (patch)
treec0bf75f5de2faeaacc3d9486b049700c4b5559ec /src
parent96058ef19d655a8854ccbb676ec43b16b4d1e0af (diff)
downloadvyconf-bed066dbf1b6cf9d606c0f1f827cce30f4dcc430.tar.gz
vyconf-bed066dbf1b6cf9d606c0f1f827cce30f4dcc430.zip
T7272: simplify library dependencies for implementation of commit op
Diffstat (limited to 'src')
-rw-r--r--src/commit.ml20
-rw-r--r--src/commit.mli4
-rw-r--r--src/dune37
-rw-r--r--src/vycall_client.ml26
-rw-r--r--src/vycall_client.mli2
5 files changed, 19 insertions, 70 deletions
diff --git a/src/commit.ml b/src/commit.ml
index a2b9f6e..a0d9d35 100644
--- a/src/commit.ml
+++ b/src/commit.ml
@@ -2,7 +2,6 @@ module VT = Vyos1x.Vytree
module CT = Vyos1x.Config_tree
module CD = Vyos1x.Config_diff
module RT = Vyos1x.Reference_tree
-module FP = FilePath
type tree_source = DELETE | ADD
@@ -175,22 +174,3 @@ let commit_store c_data =
| false -> acc ^ "\n" ^ r.out
in List.fold_left func "" c_data.node_list
in print_endline out
-
-let show_commit_data at wt =
- let vc =
- Startup.load_daemon_config Defaults.defaults.config_file in
- let rt_opt =
- Startup.read_reference_tree (FP.concat vc.reftree_dir vc.reference_tree)
- in
- match rt_opt with
- | Error msg -> msg
- | Ok rt ->
- let del_list, add_list =
- calculate_priority_lists rt at wt
- in
- let sprint_node_data acc s =
- acc ^ "\n" ^ (node_data_to_yojson s |> Yojson.Safe.to_string)
- in
- let del_out = List.fold_left sprint_node_data "" del_list in
- let add_out = List.fold_left sprint_node_data "" add_list in
- del_out ^ "\n" ^ add_out
diff --git a/src/commit.mli b/src/commit.mli
index da97389..696f595 100644
--- a/src/commit.mli
+++ b/src/commit.mli
@@ -26,6 +26,8 @@ type commit_data = {
node_list: node_data list;
} [@@deriving to_yojson]
+val tree_source_to_yojson : tree_source -> [> `String of string ]
+
val default_node_data : node_data
val default_commit_data : commit_data
@@ -33,5 +35,3 @@ val default_commit_data : commit_data
val calculate_priority_lists : Vyos1x.Reference_tree.t -> Vyos1x.Config_tree.t -> Vyos1x.Config_tree.t -> node_data list * node_data list
val commit_store : commit_data -> unit
-
-val show_commit_data : Vyos1x.Config_tree.t -> Vyos1x.Config_tree.t -> string
diff --git a/src/dune b/src/dune
index c9a6eb6..63e1167 100644
--- a/src/dune
+++ b/src/dune
@@ -8,10 +8,23 @@
(preprocess (pps lwt_ppx)))
(library
+ (name vycall_message)
+ (public_name vyconf.vycall-message)
+ (modules vycall_pbt)
+ (libraries ocaml-protoc))
+
+(library
+ (name commitd_client)
+ (public_name vyconf.vycall-client)
+ (modules vycall_client commit)
+ (libraries vyos1x-config vycall_message lwt lwt.unix lwt_log lwt_ppx ocplib-endian)
+ (preprocess (pps lwt_ppx)))
+
+(library
(name vyconfd_config)
(public_name vyconf.vyconfd-config)
- (modules vyconf_config startup session directories defaults commit)
- (libraries vyos1x-config vyconf_connect toml sha ppx_deriving.show yojson ppx_deriving_yojson)
+ (modules vyconf_config startup session directories defaults)
+ (libraries vyos1x-config vyconf_connect commitd_client toml sha ppx_deriving.show yojson ppx_deriving_yojson)
(preprocess (pps lwt_ppx ppx_deriving.show ppx_deriving_yojson)))
(library
@@ -21,19 +34,6 @@
(libraries vyos1x-config vyconf_connect lwt lwt.unix lwt_log lwt_ppx)
(preprocess (pps lwt_ppx)))
-(library
- (name vycall_message)
- (public_name vyconf.vycall-message)
- (modules vycall_pbt)
- (libraries ocaml-protoc))
-
-(library
- (name commitd_client)
- (public_name vyconf.vycall-client)
- (modules vycall_client)
- (libraries vyos1x-config vyconfd_config vycall_message lwt lwt.unix lwt_log lwt_ppx ocplib-endian)
- (preprocess (pps lwt_ppx)))
-
(executable
(name vyconfd)
(public_name vyconfd)
@@ -54,13 +54,6 @@
(modules validate)
(libraries vyconfd_client))
-(executable
- (name test_commit_data)
- (public_name test-commit-data)
- (modules test_commit_data)
- (libraries vyos1x-config vyconfd_config)
- (preprocess (pps lwt_ppx)))
-
(rule
(mode promote)
(targets vyconf_pbt.ml vyconf_pbt.mli)
diff --git a/src/vycall_client.ml b/src/vycall_client.ml
index c7fc811..f146543 100644
--- a/src/vycall_client.ml
+++ b/src/vycall_client.ml
@@ -1,12 +1,10 @@
(* send commit data to Python commit daemon *)
open Vycall_message.Vycall_pbt
-open Vyconfd_config.Commit
+open Commit
module CT = Vyos1x.Config_tree
module IC = Vyos1x.Internal.Make(CT)
-module ST = Vyconfd_config.Startup
-module DF = Vyconfd_config.Defaults
module FP = FilePath
type t = {
@@ -100,25 +98,3 @@ let do_commit session_data =
let%lwt () = Lwt_io.close client.oc in
update (commit_proto_to_commit_data resp session_data)
in Lwt_main.run @@ run ()
-
-(* test function *)
-let test_commit at wt =
- let vc =
- ST.load_daemon_config DF.defaults.config_file in
- let () =
- IC.write_internal at (FP.concat vc.session_dir vc.running_cache) in
- let () =
- IC.write_internal wt (FP.concat vc.session_dir vc.session_cache) in
- let rt_opt =
- ST.read_reference_tree (FP.concat vc.reftree_dir vc.reference_tree)
- in
- match rt_opt with
- | Error msg -> print_endline msg
- | Ok rt ->
- let del_list, add_list =
- calculate_priority_lists rt at wt
- in
- let commit_session =
- { default_commit_data with node_list = del_list @ add_list }
- in
- do_commit commit_session
diff --git a/src/vycall_client.mli b/src/vycall_client.mli
index 8836f73..0fdb6d7 100644
--- a/src/vycall_client.mli
+++ b/src/vycall_client.mli
@@ -1 +1 @@
-val test_commit : Vyos1x.Config_tree.t -> Vyos1x.Config_tree.t -> unit
+val do_commit : Commit.commit_data -> unit