File tree Expand file tree Collapse file tree 5 files changed +49
-2
lines changed Expand file tree Collapse file tree 5 files changed +49
-2
lines changed Original file line number Diff line number Diff line change @@ -2040,6 +2040,9 @@ let _ =
2040
2040
error Api_errors. disable_ssh_partially_failed [" hosts" ]
2041
2041
~doc: " Some of hosts failed to disable SSH access." () ;
2042
2042
2043
+ error Api_errors. set_console_timeout_partially_failed [" hosts" ]
2044
+ ~doc: " Some hosts failed to set console timeout." () ;
2045
+
2043
2046
error Api_errors. host_driver_no_hardware [" driver variant" ]
2044
2047
~doc: " No hardware present for this host driver variant" () ;
2045
2048
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"
1420
1420
1421
1421
let disable_ssh_partially_failed = add_error " DISABLE_SSH_PARTIALLY_FAILED"
1422
1422
1423
+ let set_console_timeout_partially_failed =
1424
+ add_error " SET_CONSOLE_TIMEOUT_PARTIALLY_FAILED"
1425
+
1423
1426
let host_driver_no_hardware = add_error " HOST_DRIVER_NO_HARDWARE"
1424
1427
1425
1428
let 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
1287
1287
1288
1288
let reboot_required_hfxs = ref " /run/reboot-required.hfxs"
1289
1289
1290
+ let console_timeout_profile_path = ref " /etc/profile.d/xapi-console-timeout.sh"
1291
+
1290
1292
(* Fingerprint of default patch key *)
1291
1293
let citrix_patch_key =
1292
1294
" NERDNTUzMDMwRUMwNDFFNDI4N0M4OEVCRUFEMzlGOTJEOEE5REUyNg=="
Original file line number Diff line number Diff line change @@ -3136,4 +3136,36 @@ let disable_ssh ~__context ~self =
3136
3136
3137
3137
let set_ssh_enabled_timeout ~__context ~self :_ ~value :_ = ()
3138
3138
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
+ try
3152
+ let content =
3153
+ match value with
3154
+ | 0L ->
3155
+ " # Console timeout is disabled\n "
3156
+ | timeout ->
3157
+ Printf. sprintf " # Console timeout configuration\n export TMOUT=%Ld\n "
3158
+ timeout
3159
+ in
3160
+
3161
+ Unixext. atomic_write_to_file ! Xapi_globs. console_timeout_profile_path 0o0644
3162
+ (fun fd ->
3163
+ Unix. write fd (Bytes. of_string content) 0 (String. length content)
3164
+ |> ignore
3165
+ ) ;
3166
+
3167
+ Db.Host. set_console_idle_timeout ~__context ~self ~value
3168
+ with e ->
3169
+ error " Failed to configure console timeout: %s" (Printexc. to_string e) ;
3170
+ Helpers. internal_error " Failed to set console timeout: %Ld: %s" value
3171
+ (Printexc. to_string e)
Original file line number Diff line number Diff line change @@ -4003,6 +4003,13 @@ module Ssh = struct
4003
4003
let disable ~__context ~self :_ =
4004
4004
operate ~__context ~action: Client.Host. disable_ssh
4005
4005
~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
4006
4013
end
4007
4014
4008
4015
let enable_ssh = Ssh. enable
@@ -4011,4 +4018,4 @@ let disable_ssh = Ssh.disable
4011
4018
4012
4019
let set_ssh_enabled_timeout ~__context ~self :_ ~value :_ = ()
4013
4020
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