Skip to content

Commit 50bc09a

Browse files
committed
CP-54382 Set Different Auto-Mode Default Values for XS8 and XS9
- For XS8, a configuration file (/etc/xapi.conf.d/ssh-auto-mode.conf) will be loaded, and auto_mode will be set to false. - For XS9, no configuration file exists, so the default value will be set to true. Signed-off-by: Lunfan Zhang[Lunfan.Zhang] <[email protected]>
1 parent ccaf4d6 commit 50bc09a

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

ocaml/xapi/dbsync_slave.ml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ let create_localhost ~__context info =
6464
~ssh_enabled_timeout:Constants.default_ssh_enabled_timeout
6565
~ssh_expiry:Date.epoch
6666
~console_idle_timeout:Constants.default_console_idle_timeout
67-
~ssh_auto_mode:Constants.default_ssh_auto_mode
67+
~ssh_auto_mode:!Xapi_globs.ssh_auto_mode_default
6868
in
6969
()
7070

@@ -384,7 +384,19 @@ let update_env __context sync_keys =
384384
switched_sync Xapi_globs.sync_ssh_status (fun () ->
385385
let ssh_service = !Xapi_globs.ssh_service in
386386
let status = Fe_systemctl.is_active ~service:ssh_service in
387-
Db.Host.set_ssh_enabled ~__context ~self:localhost ~value:status
387+
Db.Host.set_ssh_enabled ~__context ~self:localhost ~value:status ;
388+
let auto_mode_in_db =
389+
Db.Host.get_ssh_auto_mode ~__context ~self:localhost
390+
in
391+
let ssh_monitor_enabled =
392+
Fe_systemctl.is_active ~service:!Xapi_globs.ssh_monitor_service
393+
in
394+
(* For xs9 when fresh install, the ssh_monitor service is not enabled by default.
395+
If the auto_mode is enabled, we need to enable the ssh_monitor service.
396+
and user may have disabled monitor service by mistake as well, so we need to check the status. *)
397+
if auto_mode_in_db <> ssh_monitor_enabled then
398+
Xapi_host.set_ssh_auto_mode ~__context ~self:localhost
399+
~value:auto_mode_in_db
388400
) ;
389401

390402
remove_pending_guidances ~__context

ocaml/xapi/xapi_globs.ml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,6 +1299,8 @@ let ssh_service = ref "sshd"
12991299

13001300
let ssh_monitor_service = ref "xapi-ssh-monitor"
13011301

1302+
let ssh_auto_mode_default = ref true
1303+
13021304
(* Fingerprint of default patch key *)
13031305
let citrix_patch_key =
13041306
"NERDNTUzMDMwRUMwNDFFNDI4N0M4OEVCRUFEMzlGOTJEOEE5REUyNg=="
@@ -1743,6 +1745,12 @@ let other_options =
17431745
, (fun () -> string_of_bool !validate_reusable_pool_session)
17441746
, "Enable validation of reusable pool sessions before use"
17451747
)
1748+
; ( "ssh-auto-mode"
1749+
, Arg.Bool (fun b -> ssh_auto_mode_default := b)
1750+
, (fun () -> string_of_bool !ssh_auto_mode_default)
1751+
, "Defaults to true; overridden to false via \
1752+
/etc/xapi.conf.d/ssh-auto-mode.conf(e.g., in XenServer 8)"
1753+
)
17461754
]
17471755

17481756
(* The options can be set with the variable xapiflags in /etc/sysconfig/xapi.

0 commit comments

Comments
 (0)