File tree Expand file tree Collapse file tree 5 files changed +50
-2
lines changed
Expand file tree Collapse file tree 5 files changed +50
-2
lines changed Original file line number Diff line number Diff line change @@ -2040,6 +2040,9 @@ let _ =
20402040 error Api_errors. disable_ssh_partially_failed [" hosts" ]
20412041 ~doc: " Some of hosts failed to disable SSH access." () ;
20422042
2043+ error Api_errors. set_console_timeout_partially_failed [" hosts" ]
2044+ ~doc: " Some hosts failed to set console timeout." () ;
2045+
20432046 error Api_errors. host_driver_no_hardware [" driver variant" ]
20442047 ~doc: " No hardware present for this host driver variant" () ;
20452048
Original file line number Diff line number Diff line change @@ -1420,6 +1420,9 @@ let enable_ssh_partially_failed = add_error "ENABLE_SSH_PARTIALLY_FAILED"
14201420
14211421let disable_ssh_partially_failed = add_error " DISABLE_SSH_PARTIALLY_FAILED"
14221422
1423+ let set_console_timeout_partially_failed =
1424+ add_error " SET_CONSOLE_TIMEOUT_PARTIALLY_FAILED"
1425+
14231426let host_driver_no_hardware = add_error " HOST_DRIVER_NO_HARDWARE"
14241427
14251428let tls_verification_not_enabled_in_pool =
Original file line number Diff line number Diff line change @@ -1287,6 +1287,8 @@ let gpumon_stop_timeout = ref 10.0
12871287
12881288let reboot_required_hfxs = ref " /run/reboot-required.hfxs"
12891289
1290+ let console_timeout_profile_path = ref " /etc/profile.d/xapi-console-timeout.sh"
1291+
12901292(* Fingerprint of default patch key *)
12911293let citrix_patch_key =
12921294 " NERDNTUzMDMwRUMwNDFFNDI4N0M4OEVCRUFEMzlGOTJEOEE5REUyNg=="
Original file line number Diff line number Diff line change @@ -3136,4 +3136,37 @@ let disable_ssh ~__context ~self =
31363136
31373137let set_ssh_enabled_timeout ~__context ~self :_ ~value :_ = ()
31383138
3139- let set_console_idle_timeout ~__context ~self :_ ~value :_ = ()
3139+ let set_console_idle_timeout ~__context ~self ~value =
3140+ let assert_timeout_valid timeout =
3141+ if timeout < 0L then
3142+ raise
3143+ (Api_errors. Server_error
3144+ ( Api_errors. invalid_value
3145+ , [" console_timeout" ; Int64. to_string timeout]
3146+ )
3147+ )
3148+ in
3149+
3150+ assert_timeout_valid value ;
3151+ let timeout_file = ! Xapi_globs. console_timeout_profile_path in
3152+
3153+ try
3154+ let content =
3155+ match value with
3156+ | 0L ->
3157+ " # Console timeout is disabled\n "
3158+ | timeout ->
3159+ Printf. sprintf " # Console timeout configuration\n export TMOUT=%Ld\n "
3160+ timeout
3161+ in
3162+
3163+ Unixext. atomic_write_to_file timeout_file 0o0644 (fun fd ->
3164+ Unix. write fd (Bytes. of_string content) 0 (String. length content)
3165+ |> ignore
3166+ ) ;
3167+
3168+ Db.Host. set_console_idle_timeout ~__context ~self ~value
3169+ with e ->
3170+ error " Failed to configure console timeout: %s" (Printexc. to_string e) ;
3171+ Helpers. internal_error " Failed to set console timeout: %Ld: %s" value
3172+ (Printexc. to_string e)
Original file line number Diff line number Diff line change @@ -4003,6 +4003,13 @@ module Ssh = struct
40034003 let disable ~__context ~self :_ =
40044004 operate ~__context ~action: Client.Host. disable_ssh
40054005 ~error: Api_errors. disable_ssh_partially_failed
4006+
4007+ let set_console_timeout ~__context ~self :_ ~value =
4008+ operate ~__context
4009+ ~action: (fun ~rpc ~session_id ~self ->
4010+ Client.Host. set_console_idle_timeout ~rpc ~session_id ~self ~value
4011+ )
4012+ ~error: Api_errors. set_console_timeout_partially_failed
40064013end
40074014
40084015let enable_ssh = Ssh. enable
@@ -4011,4 +4018,4 @@ let disable_ssh = Ssh.disable
40114018
40124019let set_ssh_enabled_timeout ~__context ~self :_ ~value :_ = ()
40134020
4014- let set_console_idle_timeout ~ __context ~ self : _ ~ value : _ = ()
4021+ let set_console_idle_timeout = Ssh. set_console_timeout
You can’t perform that action at this time.
0 commit comments