Skip to content

Commit 9adf643

Browse files
committed
Add default value of SSH settings in constants.ml
Signed-off-by: Gang Ji <[email protected]>
1 parent 7b16c58 commit 9adf643

File tree

4 files changed

+28
-13
lines changed

4 files changed

+28
-13
lines changed

ocaml/idl/datamodel_host.ml

+10-8
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,7 @@ let create_params =
13051305
; param_name= "ssh_enabled"
13061306
; param_doc= "True if SSH access is enabled for the host"
13071307
; param_release= numbered_release "25.14.0-next"
1308-
; param_default= Some (VBool true)
1308+
; param_default= Some (VBool Constants.default_ssh_enabled)
13091309
}
13101310
; {
13111311
param_type= Int
@@ -1315,7 +1315,7 @@ let create_params =
13151315
disabled (0 means never), this setting will be applied every time the \
13161316
SSH is enabled by XAPI"
13171317
; param_release= numbered_release "25.14.0-next"
1318-
; param_default= Some (VInt 0L)
1318+
; param_default= Some (VInt Constants.default_ssh_enabled_timeout)
13191319
}
13201320
; {
13211321
param_type= DateTime
@@ -1333,7 +1333,7 @@ let create_params =
13331333
"The timeout in seconds after which idle console will be automatically \
13341334
terminated (0 means never)"
13351335
; param_release= numbered_release "25.14.0-next"
1336-
; param_default= Some (VInt 0L)
1336+
; param_default= Some (VInt Constants.default_console_idle_timeout)
13371337
}
13381338
]
13391339

@@ -2436,7 +2436,7 @@ let set_console_idle_timeout =
24362436
~params:
24372437
[
24382438
(Ref _host, "self", "The host")
2439-
; (Int, "value", "The idle console timeout in seconds")
2439+
; (Int, "value", "The console idle timeout in seconds")
24402440
]
24412441
~allowed_roles:_R_POOL_ADMIN ()
24422442

@@ -3039,10 +3039,11 @@ let t =
30393039
"The SHA256 checksum of updateinfo of the most recently applied \
30403040
update on the host"
30413041
; field ~qualifier:DynamicRO ~lifecycle:[] ~ty:Bool
3042-
~default_value:(Some (VBool true)) "ssh_enabled"
3043-
"True if SSH access is enabled for the host"
3042+
~default_value:(Some (VBool Constants.default_ssh_enabled))
3043+
"ssh_enabled" "True if SSH access is enabled for the host"
30443044
; field ~qualifier:DynamicRO ~lifecycle:[] ~ty:Int
3045-
~default_value:(Some (VInt 0L)) "ssh_enabled_timeout"
3045+
~default_value:(Some (VInt Constants.default_ssh_enabled_timeout))
3046+
"ssh_enabled_timeout"
30463047
"The timeout in seconds after which SSH access will be \
30473048
automatically disabled (0 means never), this setting will be \
30483049
applied every time the SSH is enabled by XAPI"
@@ -3051,7 +3052,8 @@ let t =
30513052
"The time in UTC after which the SSH access will be automatically \
30523053
disabled"
30533054
; field ~qualifier:DynamicRO ~lifecycle:[] ~ty:Int
3054-
~default_value:(Some (VInt 0L)) "console_idle_timeout"
3055+
~default_value:(Some (VInt Constants.default_console_idle_timeout))
3056+
"console_idle_timeout"
30553057
"The timeout in seconds after which idle console will be \
30563058
automatically terminated (0 means never)"
30573059
]

ocaml/xapi-consts/constants.ml

+6
Original file line numberDiff line numberDiff line change
@@ -422,3 +422,9 @@ let observer_components_all =
422422
let tgroups_enabled = ref false
423423

424424
let when_tgroups_enabled f = if !tgroups_enabled then f () else ()
425+
426+
let default_ssh_enabled = true
427+
428+
let default_ssh_enabled_timeout = 0L
429+
430+
let default_console_idle_timeout = 0L

ocaml/xapi/dbsync_slave.ml

+5-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,11 @@ let create_localhost ~__context info =
5959
~external_auth_configuration:[] ~license_params:[] ~edition:""
6060
~license_server:[("address", "localhost"); ("port", "27000")]
6161
~local_cache_sr:Ref.null ~chipset_info:[] ~ssl_legacy:false
62-
~last_software_update:Date.epoch ~last_update_hash:"" ~ssh_enabled:true
63-
~ssh_enabled_timeout:0L ~ssh_expiry:Date.epoch ~console_idle_timeout:0L
62+
~last_software_update:Date.epoch ~last_update_hash:""
63+
~ssh_enabled:Constants.default_ssh_enabled
64+
~ssh_enabled_timeout:Constants.default_ssh_enabled_timeout
65+
~ssh_expiry:Date.epoch
66+
~console_idle_timeout:Constants.default_console_idle_timeout
6467
in
6568
()
6669

ocaml/xapi/xapi_pool.ml

+7-3
Original file line numberDiff line numberDiff line change
@@ -2048,11 +2048,15 @@ let eject_self ~__context ~host =
20482048
( try
20492049
(* Restore console idle timeout *)
20502050
Xapi_host.set_console_idle_timeout ~__context ~self:host
2051-
~value:0L ;
2051+
~value:Constants.default_console_idle_timeout ;
20522052
(* Restore SSH service to default state *)
20532053
Xapi_host.set_ssh_enabled_timeout ~__context ~self:host
2054-
~value:0L ;
2055-
Xapi_host.enable_ssh ~__context ~self:host
2054+
~value:Constants.default_ssh_enabled_timeout ;
2055+
match Constants.default_ssh_enabled with
2056+
| true ->
2057+
Xapi_host.enable_ssh ~__context ~self:host
2058+
| false ->
2059+
Xapi_host.disable_ssh ~__context ~self:host
20562060
with e ->
20572061
warn "Caught %s while restoring ssh service. Ignoring"
20582062
(Printexc.to_string e)

0 commit comments

Comments
 (0)