Skip to content

Latest commit

 

History

History
32 lines (23 loc) · 1.08 KB

virt-enabling-disabling-vm-delete-protection-cli.adoc

File metadata and controls

32 lines (23 loc) · 1.08 KB

Enabling or disabling VM delete protection by using the command line

To prevent the inadvertent deletion of a virtual machine (VM), you can enable VM delete protection by using the command line. You can also disable delete protection for a VM.

By default, delete protection is not enabled for VMs. You must set the option for each individual VM.

Prerequisites
  • You have installed the {oc-first}.

Procedure
  • Enable delete protection for a VM by running the following command:

    $ oc patch vm <vm_name> --type merge -p '{"metadata":{"labels":{"kubevirt.io/vm-delete-protection":"True"}}}' -n <namespace>
  • Disable delete protection for a VM by running the following command:

    $ oc patch vm <vm_name> --type json -p '[{"op": "remove", "path": "/metadata/labels/kubevirt.io~1vm-delete-protection"}]' -n <namespace>