Editing or Removing a VM Class from Your Environment

You can use the automation APIs to edit the configuration of a VM class that you created or a predefined VM classes that vSphere with Tanzu offers. When you no longer need an existing VM class, you can remove it from your vCenter Server instance.

Note that editing a VM class specification does not affect the VMs that are already deployed by the DevOps engineers from this class. Only newly deployed VMs will use the reconfigured VM class.

Deleting a VM class results in its removal from all related namespaces. All VMs deployed with this VM class remain unchanged but DevOps engineers can no longer use it.

You can list all VM classes available for a vCenter Server instance. Call the list method of the VirtualMachineClasses interface or use the GET https://<vCenter_Server_IP>/api/vcenter/namespace-management/virtual-machine-classes HTTP request. You receive a list of all VM classes and a detailed information about each one of them. Based on the detailed information, you can narrow the list and retrieve the IDs of the VM classes that you want to edit or delete.

To edit a VM class configuration, call the update(String vmClass, VirtualMachineClassesTypes.UpdateSpec spec) method of the VirtualMachineClasses interface and pass as arguments the VM class ID and the update specification. You can also use the PATCH https://<vCenter_Server_IP>/api/vcenter/namespace-management/virtual-machine-classes/<VM_Class_ID> HTTP request and pass the update specification in the request body. You can edit all VM class attributes except the ID of the class. Only the attributes modified within the update specification will be edited.

To delete a VM class from your environment, call the delete(java.lang.String vmClass) method of the VirtualMachineClasses interface and pass the ID of the class as argument. You can also use the DELETE https://<vCenter_Server_IP>/api/vcenter/namespace-management/virtual-machine-classes/<VM_Class_ID> HTTP request.