[pve-devel] [PATCH v3 container 4/7] fix #1291: add option purge for destroy_vm api call
Christian Ebner
c.ebner at proxmox.com
Mon Jul 1 15:43:50 CEST 2019
When destroying a CT, we intentionally did not remove all related configs such as
backup or replication jobs.
The intention of this flag is to allow the removal of such configs on destroy.
Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
src/PVE/API2/LXC.pm | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 1561cfe..0acb59e 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 => {
@@ -647,9 +653,13 @@ __PACKAGE__->register_method({
die "unable to remove CT $vmid - used in HA resources\n"
if PVE::HA::Config::vm_is_ha_managed($vmid);
- # do not allow destroy if there are replication jobs
- my $repl_conf = PVE::ReplicationConfig->new();
- $repl_conf->check_for_existing_jobs($vmid);
+ if ($param->{purge}) {
+ PVE::ReplicationConfig::remove_vmid_jobs($vmid);
+ } else {
+ # do not allow destroy if there are replication jobs
+ my $repl_conf = PVE::ReplicationConfig->new();
+ $repl_conf->check_for_existing_jobs($vmid);
+ }
my $running_error_msg = "unable to destroy CT $vmid - container is running\n";
@@ -665,6 +675,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