Skip to content

CP-53721 Enable XAPI to configure SSH auto mode #6442

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 3 commits into
base: feature/configure-ssh-phase3
Choose a base branch
from

Conversation

LunfanZhang
Copy link
Contributor

@LunfanZhang LunfanZhang commented Apr 28, 2025

This PR introduces support for Dom0 SSH control, providing the capability to configure the auto mode for a specific host or all hosts in the pool.

New Host Object Fields and Host/Pool API:

  • ssh_auto_mode: Indicates whether SSH auto mode is enabled. configure to true means startup SSH when the XAPI service is down; stop SSH when the XAPI service is up. configure to false means SSH service status is independent and not effected by the XAPI service status.
  • set_ssh_auto_mode: Allows setting auto mode for specific host or all hosts in the pool.

(Note: Default value for XS8/XS9, pool join/eject operations, and XAPI startup scenarios will be addressed in the next PR, this PR only include the change of data_mode/API/cli )

@LunfanZhang LunfanZhang force-pushed the private/lunfan/CP-53721 branch from 8a0098f to ffe74a1 Compare April 28, 2025 04:26
value ;

if value && Db.Host.get_ssh_enabled ~__context ~self then
raise (Api_errors.Server_error (Api_errors.ssh_auto_mode_conflict, [])) ;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a user manually enables SSH using host.enable_ssh, we assume they expect SSH to remain enabled continuously. Therefore, we must set auto-mode to false; otherwise, auto-mode would automatically disable the SSH that the user just explicitly enabled.

@LunfanZhang LunfanZhang force-pushed the private/lunfan/CP-53721 branch from ffe74a1 to c196dc5 Compare April 29, 2025 01:45
@LunfanZhang LunfanZhang requested a review from minglumlu April 29, 2025 01:57
@robhoes robhoes marked this pull request as draft May 7, 2025 13:36
@robhoes
Copy link
Member

robhoes commented May 7, 2025

I marked this as Draft while we are still reviewing the design.

Add new host object fields:
  - ssh_auto_mode
Add new host/pool API to enable to set auto mode
  - set_ssh_auto_mode

Signed-off-by: Lunfan Zhang <[email protected]>
@LunfanZhang LunfanZhang force-pushed the private/lunfan/CP-53721 branch from c196dc5 to e139fbe Compare May 12, 2025 07:30
@LunfanZhang LunfanZhang requested review from minglumlu and BengangY May 13, 2025 01:46
@LunfanZhang LunfanZhang changed the base branch from feature/configure-ssh-phase2 to feature/configure-ssh-phase3 May 13, 2025 02:27
@LunfanZhang LunfanZhang marked this pull request as ready for review May 13, 2025 06:35
@LunfanZhang LunfanZhang force-pushed the private/lunfan/CP-53721 branch from e139fbe to 48cfe77 Compare May 13, 2025 07:59
@LunfanZhang
Copy link
Contributor Author

LunfanZhang commented May 14, 2025

Update base branch to feature/configure-ssh-phase3

(NOTE: Default auto mode setting for XS8/XS9, pool join/eject operations will not include in this PR)

Implemented XAPI APIs for SSH auto mode configuration:
  - `host.set_ssh_auto_mode`: Configures SSH auto mode for a specific host.
  - `pool.set_ssh_auto_mode`: Configures SSH auto mode for all hosts in the pool.

Additionally:
  - `host.enable_ssh` now automatically sets SSH auto mode to `false`.

Signed-off-by: Lunfan Zhang <[email protected]>
Updated `records.ml` file to support `host-param-set/get/list` and `pool-param-set/get/list` for ssh-auto-mode.

Signed-off-by: Lunfan Zhang <[email protected]>
@LunfanZhang LunfanZhang force-pushed the private/lunfan/CP-53721 branch from 48cfe77 to 9624328 Compare May 19, 2025 08:51
@LunfanZhang
Copy link
Contributor Author

Hi @robhoes Since we have completed some offline reviews locally, if you have no further comments, this PR will be merged.


let set_ssh_auto_mode ~__context ~self ~value =
info "Pool.set_ssh_auto_mode: pool='%s' value='%b'"
(pool_uuid ~__context self)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we report at the API level the reference (rather the UUID) in logs. User-facing messages report the UUID, though.

let disable_ssh_internal ~__context ~self =
try
debug "Disabling SSH for host %s" (Helpers.get_localhost_uuid ()) ;
Xapi_systemctl.disable ~wait_until_success:false !Xapi_globs.ssh_service ;
if Db.Host.get_ssh_auto_mode ~__context ~self = false then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use if not (Db.Host.get_ssh_auto_mode .. )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants