@@ -26,9 +26,6 @@ let ip_begin_key = "ip_begin"
2626let ip_end_key = " ip_end"
2727let ip_disable_gw_key = " ip_disable_gw"
2828
29- let leases_db = Filename. concat " /var/lib/xcp" " dhcp-leases.db"
30- let pidfile = " /var/run/udhcpd.pid"
31-
3229let (|>) x f = f x
3330
3431module Ip = struct
@@ -95,16 +92,16 @@ let update_db_nolock ~__context =
9592
9693(* * Called on startup to reload the leases database *)
9794let load_db_nolock () =
98- let s = Unixext. string_of_file leases_db in
95+ let s = Unixext. string_of_file ! Xapi_globs. udhcpd_leases_db in
9996 let rpc = Jsonrpc. of_string s in
10097 assigned := static_leases_of_rpc rpc;
101- info " Host internal management network successfully loaded DHCP leases db from %s" leases_db
98+ info " Host internal management network successfully loaded DHCP leases db from %s" ! Xapi_globs. udhcpd_leases_db
10299
103100(* * Called before every update to save the leases database *)
104101let save_db_nolock () =
105102 let rpc = rpc_of_static_leases ! assigned in
106103 let s = Jsonrpc. to_string rpc in
107- Unixext. write_string_to_file leases_db s
104+ Unixext. write_string_to_file ! Xapi_globs. udhcpd_leases_db s
108105
109106module Udhcpd_conf = struct
110107 type t = {
@@ -151,9 +148,9 @@ let write_config_nolock ~__context ip_router =
151148 Unixext. write_string_to_file ! Xapi_globs. udhcpd_conf (Udhcpd_conf. to_string ~__context config)
152149
153150let restart_nolock () =
154- let pid = try Unixext. pidfile_read pidfile with _ -> None in
151+ let pid = try Unixext. pidfile_read ! Xapi_globs. udhcpd_pidfile with _ -> None in
155152 Opt. iter Unixext. kill_and_wait pid;
156- let (_: string * string ) = execute_command_get_output ! Xapi_globs. udhcpd [ ! Xapi_globs. udhcpd_conf ] in
153+ let (_: string * string ) = execute_command_get_output ! Xapi_globs. busybox [ " udhcpd " ; ! Xapi_globs. udhcpd_conf ] in
157154 ()
158155
159156let find_lease_nolock vif =
@@ -226,6 +223,6 @@ let init () =
226223 try
227224 load_db_nolock ()
228225 with e ->
229- info " Caught exception %s loading %s: creating new empty leases database" (Printexc. to_string e) leases_db ;
226+ info " Caught exception %s loading %s: creating new empty leases database" (Printexc. to_string e) ! Xapi_globs. udhcpd_leases_db ;
230227 assigned := []
231228 )
0 commit comments