By William Lam, Sr. Technical Marketing Engineer
If you are trying to power off or shutdown a vApp for deletion using the vCloud API, you probably thought about using either the powerOff or shutdown API call. What you might have noticed is that even though the Virtual Machines within the vApp are powered off, you are still unable to delete the vApp. If you take a look at the vCloud Director UI, the status of the Virtual Machines show they are in a “Partially Powered Off” state.
If you perform the same operation using the vCloud Director UI, you will see that the Virtual Machines in the vApp are powered off and the vApp is deleted as expected. Why is there a difference between the UI and the vCloud API? The reason for this is the vCloud API provides additional flexibility for the end users for stopping the entire vApp or just the Virtual Machines within the vApp.
The powerOff/shutdown operation for a vApp only applies to the Virtual Machines residing within the vApp, it does not pertain to the “Service” Virtual Machines that might be supporting the vApp such as a vShield Edge Virtual Machine and its allocated resources (e.g. compute + IP Addresses). There might be a situation where you only want to shutdown the Virtual Machines in the vApp, but leave the “Service” Virtual Machines running. In this scenario, the vApp would still be in a “deployed” state and that is why you would see the “Partially Powered Off” status for a Virtual Machine in the vCloud UI.
To cover this particular use case, we have an undeploy API call that will stop both the Virtual machines within the vApp as well as the “Service” Virtual Machines. This API call allows you to specify the undeploy power options: default (leverages the shutdown order), powerOff, suspend, shutdown or force for the Virtual Machines within the vApp. The undeploy operation behaves exactly the same as the vCloud UI when you “stop” a vApp. To see an example of the deprovisioning of a vApp, take a look at the Exploring the vCloud REST API Part 2 blog article.
Note: You could also see this “Partially Powered Off” state in the vCloud UI if you shutdown the VMs from within the guestOS.
Using the GET operation on a vApp, you can check the state of the vApp by looking at both it’s status and deployed state.
From the screenshot above, we can see that the status of both the vApp and Virtual Machines are equal to 8 and using the status table, this means the objects are all powered off. If we look at the “deployed” property, we see that it is currently set to true. We will need to call the undeploy operation to completely de-allocate any resources the vApp might have before we can then delete it.
There was a very useful table that Jake Robinson shared on the VMTN community forums that I thought might be useful for you to visualize the three “deployed” states for the Virtual Machines within a vApp:
vCloud Director UI | vCloud API |
Powered On | Deployed + Powered On |
Partially Powered Off | Deployed + Powered Off |
Powered Off | Undeployed + Powered Off |
Note: These are the states of the Virtual Machine within a vApp.
Hopefully this made it more clear when you would want to use the powerOff/shutdown versus the undeploy operation for a vApp. We are looking to update our documentation to ensure that this information is reflected clearly.
Get notification of new blog postings and more by following lamw on Twitter: @lamw