The purge flag allows to remove the vmid from the vzdump.cron backup jobs.

Signed-off-by: Christian Ebner <c.eb...@proxmox.com>
---
 PVE/API2/Qemu.pm | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index a628a20..60b0f11 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -28,6 +28,7 @@ use PVE::Network;
 use PVE::Firewall;
 use PVE::API2::Firewall::VM;
 use PVE::API2::Qemu::Agent;
+use PVE::VZDump::Plugin;
 
 BEGIN {
     if (!$ENV{PVE_GENERATING_DOCS}) {
@@ -1436,7 +1437,6 @@ __PACKAGE__->register_method({
     }
 });
 
-
 __PACKAGE__->register_method({
     name => 'destroy_vm',
     path => '{vmid}',
@@ -1453,6 +1453,11 @@ __PACKAGE__->register_method({
            node => get_standard_option('pve-node'),
            vmid => get_standard_option('pve-vmid', { completion => 
\&PVE::QemuServer::complete_vmid_stopped }),
            skiplock => get_standard_option('skiplock'),
+           purge => {
+               type => 'boolean',
+               description => "Remove vmid from backup cron jobs.",
+               optional => 1,
+           },
        },
     },
     returns => {
@@ -1462,9 +1467,7 @@ __PACKAGE__->register_method({
        my ($param) = @_;
 
        my $rpcenv = PVE::RPCEnvironment::get();
-
        my $authuser = $rpcenv->get_user();
-
        my $vmid = $param->{vmid};
 
        my $skiplock = $param->{skiplock};
@@ -1473,11 +1476,8 @@ __PACKAGE__->register_method({
 
        # test if VM exists
        my $conf = PVE::QemuConfig->load_config($vmid);
-
        my $storecfg = PVE::Storage::config();
-
        PVE::QemuConfig->check_protection($conf, "can't remove VM $vmid");
-
        die "unable to remove VM $vmid - used in HA resources\n"
            if PVE::HA::Config::vm_is_ha_managed($vmid);
 
@@ -1493,12 +1493,10 @@ __PACKAGE__->register_method({
            my $upid = shift;
 
            syslog('info', "destroy VM $vmid: $upid\n");
-
            PVE::QemuServer::vm_destroy($storecfg, $vmid, $skiplock);
-
            PVE::AccessControl::remove_vm_access($vmid);
-
-            PVE::Firewall::remove_vmfw_conf($vmid);
+           PVE::Firewall::remove_vmfw_conf($vmid);
+           PVE::VZDump::Plugin::remove_vmid_from_cronjobs($vmid) if 
($param->{purge});
        };
 
        return $rpcenv->fork_worker('qmdestroy', $vmid, $authuser, $realcmd);
-- 
2.11.0

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

Reply via email to