PVE::API2::HA::Resources is not imported through a use statement here, so `qm create ... --ha-managed 1` will not add the VM 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/Qemu.pm | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm index 71bedc1e..d7455275 100644 --- a/src/PVE/API2/Qemu.pm +++ b/src/PVE/API2/Qemu.pm @@ -1391,9 +1391,8 @@ __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 => "vm:$vmid", state => $state }); - }; + my $cmd = ['ha-manager', 'add', "vm:$vmid", '--state', $state]; + eval { PVE::Tools::run_command($cmd); }; warn $@ if $@; } }; @@ -1482,9 +1481,8 @@ __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 => "vm:$vmid", state => $state }); - }; + my $cmd = ['ha-manager', 'add', "vm:$vmid", '--state', $state]; + eval { PVE::Tools::run_command($cmd); }; warn $@ if $@; } -- 2.47.3 _______________________________________________ pve-devel mailing list [email protected] https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
