File tree Expand file tree Collapse file tree 4 files changed +29
-0
lines changed Expand file tree Collapse file tree 4 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -380,5 +380,10 @@ let update_env __context sync_keys =
380380 Create_misc. create_chipset_info ~__context info
381381 ) ;
382382 switched_sync Xapi_globs. sync_gpus (fun () -> Xapi_pgpu. update_gpus ~__context) ;
383+ switched_sync Xapi_globs. sync_ssh_status (fun () ->
384+ let ssh_service = ! Xapi_globs. ssh_service in
385+ let status = Fe_systemctl. is_active ~service: ssh_service in
386+ Db.Host. set_ssh_enabled ~__context ~self: localhost ~value: status
387+ ) ;
383388
384389 remove_pending_guidances ~__context
Original file line number Diff line number Diff line change @@ -368,6 +368,8 @@ let sync_bios_strings = "sync_bios_strings"
368368
369369let sync_chipset_info = " sync_chipset_info"
370370
371+ let sync_ssh_status = " sync_ssh_status"
372+
371373let sync_pci_devices = " sync_pci_devices"
372374
373375let sync_gpus = " sync_gpus"
Original file line number Diff line number Diff line change @@ -577,3 +577,6 @@ val set_ssh_enabled_timeout :
577577
578578val set_console_idle_timeout :
579579 __context :Context .t -> self :API .ref_host -> value :int64 -> unit
580+
581+ val schedule_disable_ssh_job :
582+ __context :Context .t -> self :API .ref_host -> timeout :int64 -> unit
Original file line number Diff line number Diff line change 1313 *)
1414(* * Periodic scheduler for background tasks. *)
1515
16+ module Date = Clock. Date
17+
1618module D = Debug. Make (struct let name = " backgroundscheduler" end )
1719
1820open D
@@ -73,6 +75,22 @@ let register ~__context =
7375 (fun __context -> Xapi_subject. update_all_subjects ~__context
7476 )
7577 in
78+ let sync_ssh_status ~__context =
79+ let self = Helpers. get_localhost ~__context in
80+ let timeout = Db.Host. get_ssh_enabled_timeout ~__context ~self in
81+
82+ if timeout > 0L then
83+ let expiry_time =
84+ Db.Host. get_ssh_expiry ~__context ~self
85+ |> Date. to_unix_time
86+ |> Int64. of_float
87+ in
88+ let current_time = Unix. time () |> Int64. of_float in
89+
90+ if Int64. compare expiry_time current_time > 0 then
91+ let timeout = Int64. sub expiry_time current_time in
92+ Xapi_host. schedule_disable_ssh_job ~__context ~self ~timeout
93+ in
7694 let update_all_subjects_delay = 10.0 in
7795 (* initial delay = 10 seconds *)
7896 if master then
@@ -133,6 +151,7 @@ let register ~__context =
133151 " Check stunnel cache expiry"
134152 (Xapi_stdext_threads_scheduler.Scheduler. Periodic stunnel_period)
135153 stunnel_period Stunnel_cache. gc ;
154+ sync_ssh_status ~__context ;
136155 if
137156 master
138157 && Db.Pool. get_update_sync_enabled ~__context
You can’t perform that action at this time.
0 commit comments