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 <[email protected]>
---
 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



_______________________________________________
pve-devel mailing list
[email protected]
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to