+__PACKAGE__->register_method ({
+ name => 'stop',
+ path => 'stop',
+ method => 'POST',
+ description => "Request the service to be stopped.",
+ permissions => {
+ check => ['perm', '/', [ 'Sys.Console' ]],
+ },
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ sid => get_standard_option('pve-ha-resource-or-vm-id',
+ { completion => \&PVE::HA::Tools::complete_sid }),
+ timeout => {
+ description => "Timeout in seconds. If set to 0 a hard stop will be performed.",
+ type => 'integer',
+ minimum => 0,
+ },
+ },
+ },
+ returns => { type => 'null' },
+ code => sub {
+ my ($param) = @_;
+
+ my $sid = PVE::HA::Config::parse_sid(extract_param($param, 'sid'));
+
+ PVE::HA::Config::service_is_ha_managed($sid);
+
+ PVE::API2::HA::Resources::check_service_state($sid);
+
+ PVE::HA::Config::queue_crm_commands("stop $sid $param->{timeout}");
+
+ return undef;
+ }});
+