[pve-devel] [RFC v2 container 3/3] fix #1291: add option purge for destroy_vm api call

Christian Ebner c.ebner at proxmox.com
Wed Jun 26 18:02:35 CEST 2019


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

Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
version 2:
    * s/remove_vmid_from_cronjobs/remove_vmid_from_backup_jobs/

 src/PVE/API2/LXC.pm | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index cf14d75..299312a 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -18,6 +18,7 @@ use PVE::LXC;
 use PVE::LXC::Create;
 use PVE::LXC::Migrate;
 use PVE::GuestHelpers;
+use PVE::VZDump::Plugin;
 use PVE::API2::LXC::Config;
 use PVE::API2::LXC::Status;
 use PVE::API2::LXC::Snapshot;
@@ -627,6 +628,11 @@ __PACKAGE__->register_method({
 	properties => {
 	    node => get_standard_option('pve-node'),
 	    vmid => get_standard_option('pve-vmid', { completion => \&PVE::LXC::complete_ctid_stopped }),
+	    purge => {
+		type => 'boolean',
+		description => "Remove vmid from backup cron jobs.",
+		optional => 1,
+	    },
 	},
     },
     returns => {
@@ -636,16 +642,12 @@ __PACKAGE__->register_method({
 	my ($param) = @_;
 
 	my $rpcenv = PVE::RPCEnvironment::get();
-
 	my $authuser = $rpcenv->get_user();
-
 	my $vmid = $param->{vmid};
 
 	# test if container exists
 	my $conf = PVE::LXC::Config->load_config($vmid);
-
 	my $storage_cfg = cfs_read_file("storage.cfg");
-
 	PVE::LXC::Config->check_protection($conf, "can't remove CT $vmid");
 
 	die "unable to remove CT $vmid - used in HA resources\n"
@@ -669,6 +671,7 @@ __PACKAGE__->register_method({
 	    PVE::LXC::destroy_lxc_container($storage_cfg, $vmid, $conf);
 	    PVE::AccessControl::remove_vm_access($vmid);
 	    PVE::Firewall::remove_vmfw_conf($vmid);
+	    PVE::VZDump::Plugin::remove_vmid_from_backup_jobs($vmid) if ($param->{purge});
 	};
 
 	my $realcmd = sub { PVE::LXC::Config->lock_config($vmid, $code); };
-- 
2.20.1




More information about the pve-devel mailing list