]> git.proxmox.com Git - pve-container.git/commitdiff
api status: code cleanup for HA calls
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 13 May 2019 11:39:52 +0000 (11:39 +0000)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 13 May 2019 11:39:52 +0000 (11:39 +0000)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/API2/LXC/Status.pm

index c893f3cfd8256987a016051b336fe4c92b7cd174..7fcd7b82b72559c1d52f7074b4d3ce89c4fbcc1f 100644 (file)
@@ -157,15 +157,10 @@ __PACKAGE__->register_method({
            my $hacmd = sub {
                my $upid = shift;
 
-               my $service = "ct:$vmid";
-
-               my $cmd = ['ha-manager', 'set', $service, '--state', 'started'];
-
                print "Requesting HA start for CT $vmid\n";
 
+               my $cmd = ['ha-manager', 'set',  "ct:$vmid", '--state', 'started'];
                PVE::Tools::run_command($cmd);
-
-               return;
            };
 
            return $rpcenv->fork_worker('hastart', $vmid, $authuser, $hacmd);
@@ -247,15 +242,10 @@ __PACKAGE__->register_method({
            my $hacmd = sub {
                my $upid = shift;
 
-               my $service = "ct:$vmid";
-
-               my $cmd = ['ha-manager', 'set', $service, '--state', 'stopped'];
-
                print "Requesting HA stop for CT $vmid\n";
 
+               my $cmd = ['ha-manager', 'set',  "ct:$vmid", '--state', 'stopped'];
                PVE::Tools::run_command($cmd);
-
-               return;
            };
 
            return $rpcenv->fork_worker('hastop', $vmid, $authuser, $hacmd);
@@ -321,32 +311,23 @@ __PACKAGE__->register_method({
        my ($param) = @_;
 
        my $rpcenv = PVE::RPCEnvironment::get();
-
        my $authuser = $rpcenv->get_user();
 
        my $node = extract_param($param, 'node');
-
        my $vmid = extract_param($param, 'vmid');
 
        my $timeout = extract_param($param, 'timeout') // 60;
 
        die "CT $vmid not running\n" if !PVE::LXC::check_running($vmid);
 
-       if (PVE::HA::Config::vm_is_ha_managed($vmid) &&
-           $rpcenv->{type} ne 'ha') {
-
+       if (PVE::HA::Config::vm_is_ha_managed($vmid) && $rpcenv->{type} ne 'ha') {
            my $hacmd = sub {
                my $upid = shift;
 
-               my $service = "ct:$vmid";
-
-               my $cmd = ['ha-manager', 'set', $service, '--state', 'stopped'];
-
                print "Requesting HA stop for CT $vmid\n";
 
+               my $cmd = ['ha-manager', 'set',  "ct:$vmid", '--state', 'stopped'];
                PVE::Tools::run_command($cmd);
-
-               return;
            };
 
            return $rpcenv->fork_worker('hastop', $vmid, $authuser, $hacmd);