Canceling an HCX Migration using APIs
search cancel

Canceling an HCX Migration using APIs

book

Article ID: 400392

calendar_today

Updated On:

Products

VMware HCX

Issue/Introduction

Resolution

Use the following HCX API command to forceCancel the migration:

curl -k --location -X POST 'https://<SOURCE_HCX_MGR_IP>/hybridity/api/mobility/migrations/forceCancel' \
--header 'accept: application/json' \
--header 'accept-language: en-GB,en-US;q=0.9,en;q=0.8' \
--header 'content-type: application/json' \
--header 'x-hm-authorization: <X-HM_TOKEN>' \
--data '{
    "items": [
        {
            "migrationId": "<migration-ID>"
        }
    ],
    "removeLongRecoveryData": false
}'

This curl should be run on both the connector and cloud managers.

The following information is required:

  • <SOURCE_HCX_MGR_IP>: Specify the IP address or FQDN of the HCX Connector. The API client must be able to reach this VM on the network.
  • <X-HM_TOKEN>: Refer to this KB article Generating x-hm authentication token for use with HCX APIs for instructions on obtaining the X-HM token.
    Alternatively, you can also obtain the token from your browser's Developer Tools:
    • Log in to the HCX Connector UI on port 443, without using the HCX vCenter plugin.
    • After logging in, press the "F12" key to open the Developer Tools.
    • Click on the "Network" tab and select the "Fetch/XHR" filter.
    • In the HCX UI, click on "Site Pairs" or "Interconnect" to generate an API response.
    • Once you click on an API response, select the "Headers" tab and find the x-hm-authorization field.

      Example:





  • <migration-ID>: This is the migration ID you want to cancel.
    You can obtain this information from the HCX Manager UI by navigating to "Migration", selecting the virtual machine, and copying the migration ID.

    Note: If the migration has been archived, or if you are unable to find it from the HCX Manager UI, you will need to locate the migration ID using the following HCX API:

    curl -k -X POST "https://<SOURCE_HCX_MGR_IP>/hybridity/api/migrations?action=query" \
    --header "accept: application/json" \
    --header "x-hm-authorization: <X-HM_TOKEN>" \
    --header "Content-Type: application/json" \
    --data "{filter={skipDrafts=true,createTimeEpoch=1583692200000},options={resultLevel=\"MOBILITYGROUP_ITEMS\",compat=2.1}}"

    Depending on the number of VMs you've migrated, the output from the HCX API can be extensive.
    Consider saving the API output and using jq commands to format the data to find the virtual machine's "entityName" and its corresponding migrationId.

Additional Information