diff options
author | Daniil Baturin <daniil@vyos.io> | 2025-04-15 15:12:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-15 15:12:02 +0100 |
commit | 4f8cd87849ae16f5efb127b63767176a243bcd8d (patch) | |
tree | 29f42006c605a639ec0a1bcc467225ec880c7e5f /src/startup.ml | |
parent | 61566db58d2b5f8eacbd1564ba1ae0690ac4b1f6 (diff) | |
parent | f6653abbc5d4a5229fafa49d49bf517f6baada33 (diff) | |
download | vyconf-current.tar.gz vyconf-current.zip |
T7321: Replace legacy operations in configsession.py with vyconf client operations
Diffstat (limited to 'src/startup.ml')
-rw-r--r-- | src/startup.ml | 32 |
1 files changed, 2 insertions, 30 deletions
diff --git a/src/startup.ml b/src/startup.ml index 76599b0..20882cb 100644 --- a/src/startup.ml +++ b/src/startup.ml @@ -78,44 +78,16 @@ let create_server accept_connection sock = Lwt_unix.accept sock >>= accept_connection >>= serve in serve -(* strip commponent version string *) -let strip_version s = - let rex = Pcre.regexp ~flags:[`MULTILINE;`DOTALL] "(^//.*)" in - let res = Pcre.split ~max:0 ~rex s in - match res with - | h :: _ -> h - | [] -> panic "Failure applying regex to config string" - -(** Load the appliance configuration file *) -let load_config file = - try - let chan = open_in file in - let s = really_input_string chan (in_channel_length chan) in - let config = strip_version s |> Vyos1x.Parser.from_string in - Ok config - with - | Sys_error msg -> Error msg - | Vyos1x.Util.Syntax_error (opt, msg) -> - begin - match opt with - | None -> - let out = Printf.sprintf "Parse error: %s\n" msg - in Error out - | Some (line, pos) -> - let out = Printf.sprintf "Parse error: %s line %d pos %d\n" msg line pos - in Error out - end - (** Load the appliance configuration file or the fallback config *) let load_config_failsafe main fallback = - let res = load_config main in + let res = Vyos1x.Config_file.load_config main in match res with | Ok config -> config | Error msg -> Lwt_log.error (Printf.sprintf "Failed to load config file %s: %s. Attempting to load fallback config %s" main msg fallback) |> Lwt.ignore_result; - let res = load_config fallback in + let res = Vyos1x.Config_file.load_config fallback in begin match res with | Ok config -> config |