all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Daniel Kral <d.kral@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH container 1/1] api: create_vm: use ha-manager command to add container as an HA resource
Date: Mon, 10 Nov 2025 15:36:20 +0100	[thread overview]
Message-ID: <20251110143627.365434-6-d.kral@proxmox.com> (raw)
In-Reply-To: <20251110143627.365434-1-d.kral@proxmox.com>

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@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



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


      parent reply	other threads:[~2025-11-10 14:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-10 14:36 [pve-devel] [PATCH container/ha-manager/qemu-server 0/5] Small HA-on-create improvements Daniel Kral
2025-11-10 14:36 ` [pve-devel] [PATCH ha-manager 1/1] api: resources: fix uninitialized value in check_service_state Daniel Kral
2025-11-10 14:36 ` [pve-devel] [PATCH qemu-server 1/3] api: create_vm: use ha-manager command to add VM as an HA resource Daniel Kral
2025-11-10 14:36 ` [pve-devel] [PATCH qemu-server 2/3] qmrestore: allow starting a VM after it was restored successfully Daniel Kral
2025-11-10 14:36 ` [pve-devel] [PATCH qemu-server 3/3] qmrestore: allow adding a VM as an HA resource after it was restored Daniel Kral
2025-11-10 14:36 ` Daniel Kral [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251110143627.365434-6-d.kral@proxmox.com \
    --to=d.kral@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal