Error: "The requested operation could not be executed on vApp <vapp_name>. Stop the vApp and try again" when deleting standalone VMs in Cloud Director
search cancel

Error: "The requested operation could not be executed on vApp <vapp_name>. Stop the vApp and try again" when deleting standalone VMs in Cloud Director

book

Article ID: 325506

calendar_today

Updated On:

Products

VMware Cloud Director

Issue/Introduction

  • Attempting to delete a standalone VM in Cloud Director (VCD) fails with an error of the form:
The requested operation could not be executed on vApp <vapp_name>. Stop the vApp and try again.
  • The standalone VM is already in a Powered Off state and cannot be stopped.
  • The standalone VM is connected to a network.
  • The vApp is not visible in the VCD UI as the VM is standalone.
  • The VM may be in an Unknown state in the VCD UI.

Environment

VMware Cloud Director 10.x

Cause

Standalone VMs in VCD have an automatically generated hidden vApp which is not visible in the VCD UI.
When a Standalone VM is powered off the hidden vApp should also be automatically powered off.

In some scenarios it is possible that the standalone VM will enter a powered off state but the hidden vApp stays powered on.
This will block the delete operation and generate the error above asking for the vApp to be powered off first.

Resolution

To resolve this issue, the affected standalone VM can be converted to a vApp so that it can be completely undeployed and deleted.
Example steps would be as follows:

  1. From the Tenant UI of Cloud Director navigate to the Datacenters > Compute > Virtual Machines view and locate the affected standalone VM.
  2. Click Actions menu for the affected VM and select Convert to vApp.
  3. Complete the instructions to save the standalone VM as a vApp.
  4. Locate the newly created vApp in the Datacenters > Compute > vApps view.
  5. Power Off the vApp to completely undeploy it and then Delete the vApp to remove both vApp and VM.
It is possible that the Convert to vApp button is greyed out if the standalone VM is in an invalid state, for example an "Unknown" state.
To workaround this, power off the hidden vApp using the Cloud Director API and then retry the standalone VM deletion from the UI:
  1. From the Tenant UI of Cloud Director navigate to the Datacenters > Compute > Virtual Machines view and locate the affected standalone VM.
  2. Click on the VM to be deleted and open its details.
  3. From the URL in the browser copy the VM ID for the affected VM.

    Example URL:
    https://<vcd_address>/tenant/<org_name>/vdc/<orgvdc_id>/vm/vm-########-####-####-####-########01ab/general

    Example VM ID from the URL:
    vm-########-####-####-####-########01ab

  4. Log in to the Cloud Director API as a System Administrator, How to establish an API connection VMware Cloud Director.
  5. Using the VM ID from step 3, retrieve the details of the VM using the Cloud Director API:

    Request:
    GET https://<vcd_address>/api/vApp/vm-########-####-####-####-########01ab

    Request Headers:
    Accept: application/*+xml;version=<vcd_api_version>
    Authorization: Bearer <vcd_auth_token>

  6. From the VM XML response retrieve the vApp href for this VM's vApp.

    Example vApp information:
    <Link rel="up" href="https://<vcd_address>/api/vApp/vapp-########-####-####-####-########23cd" type="application/vnd.vmware.vcloud.vApp+xml"/>

    Example vApp href from the URL:
    https://<vcd_address>/api/vApp/vapp-########-####-####-####-########23cd

  7. Using the vApp href from step 6, retrieve the details of the vApp using the Cloud Director API:

    Request:
    GET https://<vcd_address>/api/vApp/vapp-########-####-####-####-########23cd

    Request Headers:
    Accept: application/*+xml;version=<vcd_api_version>
    Authorization: Bearer <vcd_auth_token>

  8. If the correct vApp is returned it can be powered off using the Cloud Director API by performing a power/action/powerOff action:

    Request:
    POST https://<vcd_address>/api/vApp/vapp-########-####-####-####-########23cd/power/action/powerOff

    Request Headers:
    Accept: application/*+xml;version=<vcd_api_version>
    Authorization: Bearer <vcd_auth_token>
    Content-Type:application/*+xml

    Request Body:
    <root:UndeployVAppParams xmlns:root="http://www.vmware.com/vcloud/v1.5">
    <root:UndeployPowerAction>powerOff</root:UndeployPowerAction>
    </root:UndeployVAppParams>

  9. After powering off the vApp, retry the VM deletion from the Cloud Director UI.