Skip to content

CP-54384 Update Auto-Mode Configuration for Pool Operations and Default Values #6484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: feature/configure-ssh-phase3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions ocaml/xapi/dbsync_slave.ml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ let create_localhost ~__context info =
~ssh_enabled_timeout:Constants.default_ssh_enabled_timeout
~ssh_expiry:Date.epoch
~console_idle_timeout:Constants.default_console_idle_timeout
~ssh_auto_mode:Constants.default_ssh_auto_mode
~ssh_auto_mode:!Xapi_globs.ssh_auto_mode_default
in
()

Expand Down Expand Up @@ -384,7 +384,19 @@ let update_env __context sync_keys =
switched_sync Xapi_globs.sync_ssh_status (fun () ->
let ssh_service = !Xapi_globs.ssh_service in
let status = Fe_systemctl.is_active ~service:ssh_service in
Db.Host.set_ssh_enabled ~__context ~self:localhost ~value:status
Db.Host.set_ssh_enabled ~__context ~self:localhost ~value:status ;
let auto_mode_in_db =
Db.Host.get_ssh_auto_mode ~__context ~self:localhost
in
let ssh_monitor_enabled =
Fe_systemctl.is_active ~service:!Xapi_globs.ssh_monitor_service
in
(* For xs9 when fresh install, the ssh_monitor service is not enabled by default.
If the auto_mode is enabled, we need to enable the ssh_monitor service.
and user may have disabled monitor service by mistake as well, so we need to check the status. *)
if auto_mode_in_db <> ssh_monitor_enabled then
Xapi_host.set_ssh_auto_mode ~__context ~self:localhost
~value:auto_mode_in_db
) ;

remove_pending_guidances ~__context
8 changes: 8 additions & 0 deletions ocaml/xapi/xapi_globs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1299,6 +1299,8 @@ let ssh_service = ref "sshd"

let ssh_monitor_service = ref "xapi-ssh-monitor"

let ssh_auto_mode_default = ref true

(* Fingerprint of default patch key *)
let citrix_patch_key =
"NERDNTUzMDMwRUMwNDFFNDI4N0M4OEVCRUFEMzlGOTJEOEE5REUyNg=="
Expand Down Expand Up @@ -1743,6 +1745,12 @@ let other_options =
, (fun () -> string_of_bool !validate_reusable_pool_session)
, "Enable validation of reusable pool sessions before use"
)
; ( "ssh-auto-mode"
, Arg.Bool (fun b -> ssh_auto_mode_default := b)
, (fun () -> string_of_bool !ssh_auto_mode_default)
, "Defaults to true; overridden to false via \
/etc/xapi.conf.d/ssh-auto-mode.conf(e.g., in XenServer 8)"
)
]

(* The options can be set with the variable xapiflags in /etc/sysconfig/xapi.
Expand Down
7 changes: 7 additions & 0 deletions ocaml/xapi/xapi_pool.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1670,10 +1670,15 @@ let join_common ~__context ~master_address ~master_username ~master_password
Client.Host.get_console_idle_timeout ~rpc ~session_id
~self:remote_coordinator
in
let ssh_auto_mode =
Client.Host.get_ssh_auto_mode ~rpc ~session_id
~self:remote_coordinator
in
Xapi_host.set_console_idle_timeout ~__context ~self:me
~value:console_idle_timeout ;
Xapi_host.set_ssh_enabled_timeout ~__context ~self:me
~value:ssh_enabled_timeout ;
Xapi_host.set_ssh_auto_mode ~__context ~self:me ~value:ssh_auto_mode ;
let ssh_enabled =
Client.Host.get_ssh_enabled ~rpc ~session_id
~self:remote_coordinator
Expand Down Expand Up @@ -2056,6 +2061,8 @@ let eject_self ~__context ~host =
(* Restore SSH service to default state *)
Xapi_host.set_ssh_enabled_timeout ~__context ~self:host
~value:Constants.default_ssh_enabled_timeout ;
Xapi_host.set_ssh_auto_mode ~__context ~self:host
~value:!Xapi_globs.ssh_auto_mode_default ;
match Constants.default_ssh_enabled with
| true ->
Xapi_host.enable_ssh ~__context ~self:host
Expand Down
Loading