[pve-devel] [PATCH v2 ha-manager 07/12] Add stop command to the API
Fabian Ebner
f.ebner at proxmox.com
Mon Sep 30 09:22:32 CEST 2019
Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
src/PVE/API2/HA/Resources.pm | 37 ++++++++++++++++++++++++++++++++++++
src/PVE/CLI/ha_manager.pm | 2 ++
2 files changed, 39 insertions(+)
diff --git a/src/PVE/API2/HA/Resources.pm b/src/PVE/API2/HA/Resources.pm
index 2b62ee8..ecc5f0c 100644
--- a/src/PVE/API2/HA/Resources.pm
+++ b/src/PVE/API2/HA/Resources.pm
@@ -353,4 +353,41 @@ __PACKAGE__->register_method ({
return undef;
}});
+__PACKAGE__->register_method ({
+ name => 'stop',
+ protected => 1,
+ path => '{sid}/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,
+ optional => 1,
+ },
+ },
+ },
+ returns => { type => 'null' },
+ code => sub {
+ my ($param) = @_;
+
+ my ($sid, $type, $name) = PVE::HA::Config::parse_sid(extract_param($param, 'sid'));
+
+ PVE::HA::Config::service_is_ha_managed($sid);
+
+ check_service_state($sid);
+
+ PVE::HA::Config::queue_crm_commands("stop $sid $param->{timeout}");
+
+ return undef;
+ }});
+
1;
diff --git a/src/PVE/CLI/ha_manager.pm b/src/PVE/CLI/ha_manager.pm
index 5ce4c30..c9d4e7f 100644
--- a/src/PVE/CLI/ha_manager.pm
+++ b/src/PVE/CLI/ha_manager.pm
@@ -114,6 +114,8 @@ our $cmddef = {
migrate => [ "PVE::API2::HA::Resources", 'migrate', ['sid', 'node'] ],
relocate => [ "PVE::API2::HA::Resources", 'relocate', ['sid', 'node'] ],
+ stop => [ "PVE::API2::HA::Resources", 'stop', ['sid', 'timeout'] ],
+
};
1;
--
2.20.1
More information about the pve-devel
mailing list