[pve-devel] [PATCH container 1/1] api: create_vm: use ha-manager command to add container as an HA resource

Daniel Kral d.kral at proxmox.com
Mon Nov 10 15:36:20 CET 2025


PVE::API2::HA::Resources is not imported through a use statement here,
so `pct create ... --ha-managed 1` will not add the container as an HA
resource.

Replace the direct API call with a 'ha-manager' invocation as we don't
seem to import API modules from other packages except in pve-manager and
use the 'ha-manager' command at other call sites already.

Signed-off-by: Daniel Kral <d.kral at proxmox.com>
---
 src/PVE/API2/LXC.pm | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index e53b388..b792930 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -627,9 +627,7 @@ __PACKAGE__->register_method({
             if ($ha_managed) {
                 print "Add as HA resource\n";
                 my $state = $start_after_create ? 'started' : 'stopped';
-                eval {
-                    PVE::API2::HA::Resources->create({ sid => "ct:$vmid", state => $state });
-                };
+                eval { run_command(['ha-manager', 'add', "ct:$vmid", '--state', $state]); };
                 warn $@ if $@;
             }
         };
-- 
2.47.3





More information about the pve-devel mailing list