]> git.proxmox.com Git - pve-container.git/blobdiff - src/PVE/API2/LXC/Status.pm
switch to 'ha-manager set'
[pve-container.git] / src / PVE / API2 / LXC / Status.pm
index e91ac7c9eefacebe1e78fa6d51ed0851b2b5da4b..0b284c67db3a66b55f5779e7574b2222ccc2ae74 100644 (file)
@@ -52,7 +52,7 @@ __PACKAGE__->register_method({
        my ($param) = @_;
 
        # test if VM exists
-       my $conf = PVE::LXC::load_config($param->{vmid});
+       my $conf = PVE::LXC::Config->load_config($param->{vmid});
 
        my $res = [
            { subdir => 'current' },
@@ -87,12 +87,12 @@ __PACKAGE__->register_method({
        my ($param) = @_;
 
        # test if VM exists
-       my $conf = PVE::LXC::load_config($param->{vmid});
+       my $conf = PVE::LXC::Config->load_config($param->{vmid});
 
        my $vmstatus =  PVE::LXC::vmstatus($param->{vmid});
        my $status = $vmstatus->{$param->{vmid}};
 
-       $status->{ha} = PVE::HA::Config::vm_is_ha_managed($param->{vmid}) ? 1 : 0;
+       $status->{ha} = PVE::HA::Config::get_service_status("ct:$param->{vmid}");
 
        return $status;
     }});
@@ -144,7 +144,7 @@ __PACKAGE__->register_method({
 
                my $service = "ct:$vmid";
 
-               my $cmd = ['ha-manager', 'enable', $service];
+               my $cmd = ['ha-manager', 'set', $service, '--state', 'started'];
 
                print "Executing HA start for CT $vmid\n";
 
@@ -163,16 +163,18 @@ __PACKAGE__->register_method({
 
                    syslog('info', "starting CT $vmid: $upid\n");
 
-                   my $conf = PVE::LXC::load_config($vmid);
+                   my $conf = PVE::LXC::Config->load_config($vmid);
 
                    die "you can't start a CT if it's a template\n"
-                       if PVE::LXC::is_template($conf);
+                       if PVE::LXC::Config->is_template($conf);
 
-                   PVE::LXC::check_lock($conf) if !$skiplock;
+                   if (!$skiplock && !PVE::LXC::Config->has_lock($conf, 'mounted')) {
+                       PVE::LXC::Config->check_lock($conf);
+                   }
 
                    my $storage_cfg = cfs_read_file("storage.cfg");
 
-                   PVE::LXC::update_lxc_config($storage_cfg, $vmid, $conf);
+                   PVE::LXC::update_lxc_config($vmid, $conf);
 
                    local $ENV{PVE_SKIPLOCK}=1 if $skiplock;
 
@@ -186,7 +188,7 @@ __PACKAGE__->register_method({
                return $rpcenv->fork_worker('vzstart', $vmid, $authuser, $realcmd);
            };
 
-           return PVE::LXC::lock_config($vmid, $lockcmd);
+           return PVE::LXC::Config->lock_config($vmid, $lockcmd);
        }
     }});
 
@@ -196,7 +198,7 @@ __PACKAGE__->register_method({
     method => 'POST',
     protected => 1,
     proxyto => 'node',
-    description => "Stop the container.",
+    description => "Stop the container. This will abruptly stop all processes running in the container.",
     permissions => {
        check => ['perm', '/vms/{vmid}', [ 'VM.PowerMgmt' ]],
     },
@@ -235,7 +237,7 @@ __PACKAGE__->register_method({
 
                my $service = "ct:$vmid";
 
-               my $cmd = ['ha-manager', 'disable', $service];
+               my $cmd = ['ha-manager', 'set', $service, '--state', 'stopped'];
 
                print "Executing HA stop for CT $vmid\n";
 
@@ -254,9 +256,11 @@ __PACKAGE__->register_method({
 
                    syslog('info', "stopping CT $vmid: $upid\n");
 
-                   my $conf = PVE::LXC::load_config($vmid);
+                   my $conf = PVE::LXC::Config->load_config($vmid);
 
-                   PVE::LXC::check_lock($conf) if !$skiplock;
+                   if (!$skiplock && !PVE::LXC::Config->has_lock($conf, 'mounted')) {
+                       PVE::LXC::Config->check_lock($conf);
+                   }
 
                    my $cmd = ['lxc-stop', '-n', $vmid, '--kill'];
 
@@ -268,7 +272,7 @@ __PACKAGE__->register_method({
                return $rpcenv->fork_worker('vzstop', $vmid, $authuser, $realcmd);
            };
 
-           return PVE::LXC::lock_config($vmid, $lockcmd);
+           return PVE::LXC::Config->lock_config($vmid, $lockcmd);
        }
     }});
 
@@ -278,7 +282,8 @@ __PACKAGE__->register_method({
     method => 'POST',
     protected => 1,
     proxyto => 'node',
-    description => "Shutdown the container.",
+    description => "Shutdown the container. This will trigger a clean shutdown " .
+       "of the container, see lxc-stop(1) for details.",
     permissions => {
        check => ['perm', '/vms/{vmid}', [ 'VM.PowerMgmt' ]],
     },
@@ -330,9 +335,9 @@ __PACKAGE__->register_method({
 
                $timeout = 60 if !defined($timeout);
 
-               my $conf = PVE::LXC::load_config($vmid);
+               my $conf = PVE::LXC::Config->load_config($vmid);
 
-               PVE::LXC::check_lock($conf);
+               PVE::LXC::Config->check_lock($conf);
 
                my $storage_cfg = PVE::Storage::config();
 
@@ -361,7 +366,7 @@ __PACKAGE__->register_method({
            return $rpcenv->fork_worker('vzshutdown', $vmid, $authuser, $realcmd);
        };
 
-       return PVE::LXC::lock_config($vmid, $lockcmd);
+       return PVE::LXC::Config->lock_config($vmid, $lockcmd);
     }});
 
 __PACKAGE__->register_method({
@@ -403,9 +408,9 @@ __PACKAGE__->register_method({
 
                syslog('info', "suspend CT $vmid: $upid\n");
 
-               my $conf = PVE::LXC::load_config($vmid);
+               my $conf = PVE::LXC::Config->load_config($vmid);
 
-               PVE::LXC::check_lock($conf);
+               PVE::LXC::Config->check_lock($conf);
 
                my $cmd = ['lxc-checkpoint', '-n', $vmid, '-s', '-D', '/var/lib/vz/dump'];
 
@@ -417,7 +422,7 @@ __PACKAGE__->register_method({
            return $rpcenv->fork_worker('vzsuspend', $vmid, $authuser, $realcmd);
        };
 
-       return PVE::LXC::lock_config($vmid, $lockcmd);
+       return PVE::LXC::Config->lock_config($vmid, $lockcmd);
     }});
 
 __PACKAGE__->register_method({