]> git.proxmox.com Git - pve-container.git/commitdiff
CT protection mode added
authorAlen Grizonic <a.grizonic@proxmox.com>
Thu, 3 Sep 2015 14:59:29 +0000 (16:59 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 9 Sep 2015 15:13:47 +0000 (17:13 +0200)
src/PVE/API2/LXC.pm
src/PVE/LXC.pm

index 4c8da5f91fb2c05b5a3537535253794a444505d9..ed19ea772511ea0e40b304cd7ba52fe36aa90f0e 100644 (file)
@@ -463,6 +463,9 @@ __PACKAGE__->register_method({
 
        my $storage_cfg = cfs_read_file("storage.cfg");
 
+       die  "can't remove CT $vmid - protection mode enabled\n"
+           if ($conf->{protection} == 1);
+
        die "unable to remove CT $vmid - used in HA resources\n"
            if PVE::HA::Config::vm_is_ha_managed($vmid);
 
index 7f11ba0a5955b59a801df637a083a204e8706a69..4d741a0ba485260cdd0eb88cc822b4be01422fb0 100644 (file)
@@ -176,6 +176,12 @@ my $confdesc = {
        enum => ['shell', 'console', 'tty'],
        default => 'tty',
     },
+    protection => {
+       optional => 1,
+       type => 'boolean',
+       description => "Sets the protection flag of the container. This will prevent the remove operation.",
+       default => 0,
+    },
 };
 
 my $valid_lxc_conf_keys = {
@@ -1101,6 +1107,8 @@ sub update_pct_config {
                next if !$running;
                my $netid = $1;
                PVE::Network::veth_delete("veth${vmid}i$netid");
+           } elsif ($opt eq 'protection') {
+               delete $conf->{$opt};
            } elsif ($opt =~ m/^mp(\d+)$/) {
                delete $conf->{$opt};
                push @nohotplug, $opt;
@@ -1173,6 +1181,8 @@ sub update_pct_config {
            } else {
                update_net($vmid, $conf, $opt, $net, $netid, $rootdir);
            }
+       } elsif ($opt eq 'protection') {
+           $conf->{$opt} = $value ? 1 : 0;
         } elsif ($opt =~ m/^mp(\d+)$/) {
            $conf->{$opt} = $value;
            push @$new_disks, $opt;