diff options
| author | Daniil Baturin <daniil@vyos.io> | 2025-09-18 12:32:18 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-18 12:32:18 +0100 |
| commit | 304e4d2a172fe1baf2c1df7f61b7a0a8e40f7d5d (patch) | |
| tree | 4a415189068819e7914ae1352a69abe08eb45c60 /src/commit.ml | |
| parent | 2da0981501a9bec8b69d29f1e52c10db90571aa4 (diff) | |
| parent | bca62a7bd1da4e78497fdce3882421609ce28c00 (diff) | |
| download | vyconf-304e4d2a172fe1baf2c1df7f61b7a0a8e40f7d5d.tar.gz vyconf-304e4d2a172fe1baf2c1df7f61b7a0a8e40f7d5d.zip | |
Merge pull request #31 from jestabro/interstitial-set
T7737: add analogue of configfs for config tree updates during commit
Diffstat (limited to 'src/commit.ml')
| -rw-r--r-- | src/commit.ml | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/src/commit.ml b/src/commit.ml index 8913ceb..7b04c36 100644 --- a/src/commit.ml +++ b/src/commit.ml @@ -12,10 +12,20 @@ let tree_source_to_yojson = function | ADD -> `String "ADD" type status = { - success : bool; - out : string; + success : bool; + out : string; } [@@deriving to_yojson] +let default_status = { + success = true; + out = ""; +} + +let fail_status msg = + { success = false; + out = msg; + } + type node_data = { script_name: string; priority: int; @@ -39,6 +49,9 @@ let default_node_data = { type commit_data = { session_id: string; + session_pid: int32; + sudo_user: string; + user: string; dry_run: bool; atomic: bool; background: bool; @@ -49,21 +62,6 @@ type commit_data = { result : status; } [@@deriving to_yojson] -let default_commit_data = { - session_id = ""; - dry_run = false; - atomic = false; - background = false; - init = None; - node_list = []; - config_diff = CT.default; - config_result = CT.default; - result = { success = true; out = ""; }; -} - -let fail_status msg = - { success=false; out=msg } - let lex_order c1 c2 = let c = Vyos1x.Util.lex_order c1.path c2.path in match c with @@ -224,25 +222,31 @@ let config_result_update c_data n_data = let commit_update c_data = match c_data.init with | None -> - { default_commit_data with - init=Some (fail_status "commitd failure: no init status provided") + { c_data with + init = Some (fail_status "commitd failure: no init status provided") } | Some _ -> let func acc_data nd = match nd.reply with | None -> - { default_commit_data with - init=Some (fail_status"commitd failure: no reply status provided") + { c_data with + init = Some (fail_status "commitd failure: no reply status provided") } | Some _ -> config_result_update acc_data nd in List.fold_left func c_data c_data.node_list -let make_commit_data ?(dry_run=false) rt at wt id = +let make_commit_data ?(dry_run=false) rt at wt id pid sudo_user user = let diff = CD.diff_tree [] at wt in let del_list, add_list = calculate_priority_lists rt diff in - { default_commit_data with - session_id = id; + { session_id = id; + session_pid = pid; + sudo_user = sudo_user; + user = user; dry_run = dry_run; + atomic = false; + background = false; + init = None; config_diff = diff; config_result = CT.get_subtree diff ["inter"]; - node_list = del_list @ add_list; } + node_list = del_list @ add_list; + result = default_status; } |
