summaryrefslogtreecommitdiff
path: root/src/session.ml
diff options
context:
space:
mode:
Diffstat (limited to 'src/session.ml')
-rw-r--r--src/session.ml30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/session.ml b/src/session.ml
index e7be5d7..9ce2807 100644
--- a/src/session.ml
+++ b/src/session.ml
@@ -160,6 +160,36 @@ let prepare_commit ?(dry_run=false) w s id =
in
CC.make_commit_data ~dry_run:dry_run rt at wt id
+let get_config w s id =
+ let at = w.running_config in
+ let wt = s.proposed_config in
+ let vc = w.vyconf_config in
+ let running_cache = Printf.sprintf "%s_%s" vc.running_cache id in
+ let session_cache = Printf.sprintf "%s_%s" vc.session_cache id in
+ let () =
+ try
+ IC.write_internal at (FP.concat vc.session_dir running_cache)
+ with
+ Vyos1x.Internal.Write_error msg -> raise (Session_error msg)
+ in
+ let () =
+ try
+ IC.write_internal wt (FP.concat vc.session_dir session_cache)
+ with
+ Vyos1x.Internal.Write_error msg -> raise (Session_error msg)
+ in id
+
+let cleanup_config w id =
+ let remove_file file =
+ if Sys.file_exists file then
+ Sys.remove file
+ in
+ let vc = w.vyconf_config in
+ let running_cache = Printf.sprintf "%s_%s" vc.running_cache id in
+ let session_cache = Printf.sprintf "%s_%s" vc.session_cache id in
+ remove_file (FP.concat vc.session_dir running_cache);
+ remove_file (FP.concat vc.session_dir session_cache)
+
let get_value w s path =
if not (VT.exists s.proposed_config path) then
raise (Session_error ("Config path does not exist"))