How to configure VM's From Legacy Replication to Enhanced Replication Using API.
search cancel

How to configure VM's From Legacy Replication to Enhanced Replication Using API.

book

Article ID: 388924

calendar_today

Updated On:

Products

VMware vSphere ESXi

Issue/Introduction

Guidance to reconfigure existing replication of VMs from Legacy to Enhanced by using REST API.

Overview:

vSphere Replication 9.0 supports Enhanced replication, using vSphere Replication with enhanced replication the replications are distributed on all available hosts in the target cluster. This is performed by load balancing which distributes replicated VMs across resources for optimal performance. With Enhanced vSphere Replication, replication traffic goes directly to the host at the target site. The traffic bypasses the replication appliance while supporting backward compatibility and supporting a more optimized data path, allowing for automatic scalability and automatic load balancing. To use the enhanced replication capabilities with vSphere Replication, you must reconfigure your existing Legacy replication to use Enhanced replication mode.

For more information please refer, Enhanced vSphere Replication.

Environment

vSphere Replication 9.0.2.1

Resolution

Requirements for moving VMs from Legacy to Enhanced replication by using REST API:

  • vSphere Replication must be version 9.0.2.1 or later.

  • Enhanced replications require TCP network connectivity on ports 31031 and 32032 from the ESXi hosts on which the replicated VMs are running to the ESXi hosts of the cluster containing the target datastore.

  • You must have a site pair between the source and the target sites.

  • Configuring and re-configuring legacy replications to use enhanced vSphere Replication with an RPO lower than 5 minutes requires VMware Live Recovery license. If there is no VMware Live Recovery license in the pair, you might get an error message during a configure or reconfigure operation.

Steps to move VMs from Legacy to Enhanced replication by using REST API:

  1. First the Rest API file needs to be downloaded and uploaded into Debugger API tool :
    1. Open vSphere Replication appliance page and select Explore REST API, example - https://vSphere_replication_IP/

       

    2. Select "Select API version" as "v2" and download the API file using "DOWNLOAD OPEN API SPEC" button, as per below screenshot.

    3. Any valid tool for Testing, Designing and Debugging API can be used, Example - The below screenshots are from Swagger editor and Postman tool.  

  2. . Finally, to configure VMs to enhanced replication using API tool:

    1. To login to the source site, make a POST request.

      POST BASE_URL/api/rest/vr/API_VERSION/session

       

      Enter your user name and password in the Аuthorization HTTP header. Use the returned session ID as a value for x-dr-session HTTP header for all subsequent calls to the REST API.

    2. To get the pairing ID and the local vCenter Server ID, make a GET request.

      GET BASE_URL/api/rest/vr/API_VERSION/pairings/

        Example response:

      {
         "pairing_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx50745074", <----------- Pairing ID
         "local_vc_server": {
            "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx50745074", <--------------- VC ID
            "url": "https://xxxxxxxx.xxx.xx.x.xxx.xxx:443/sdk",
            "name": "xxxxxxxxx.xxx.xx.x.x.xxx.xxxx",
            "server_status": "OK",
            // Other fields are not relevant in this example
      }

       

      Save the pairing ID and the local vCenter Server ID.

    3. To get the virtual machines IDs per site pair, make a GET request.

      GET BASE_URL/api/rest/vr/API_VERSION/pairings/PAIRING_ID/vcenters/VC_GUID/vms

       

      Save the ID of the VM for which you want to configure the replication.

    4. To get the target vSphere Replication datastore, make a POST request to login to the target site:

      POST BASE_URL/api/rest/vr/API_VERSION/pairings/PAIRING_ID/remote-session

       

      Enter your user name and password in the Authorization HTTP header. Ensure the x-dr-session HTTP header is still present.

    5. Get the target datastore, make a GET request.

      GET BASE_URL/api/rest/vr/API_VERSION/pairings/PAIRING_ID/vcenters/VC_ID/datastores

       

      Replace the VC_ID value with the ID of the target vCenter Server and save the response.

    6. To get the preferred storage policy ID, make a GET request.

      GET BASE_URL/api/rest/vr/API_VERSION/pairings/PAIRING_ID/vcenters/VC_ID/storage-policies

       

      Replace the VC_ID value with the ID of the target vCenter Server, and save the preferred target storage policy ID.

    7. To get information about the disks of a VM, make a GET request

      GET BASE_URL/api/rest/vr/API_VERSION/pairings/PAIRING_ID/vcenters/VC_ID/vms/VM_ID/disks

        Replace the VC_ID value with the ID of the source vCenter Server, replace the VM_ID value with the ID of the VM which you got in Step 3., and save the response

    8. To configure the replication, make a POST request.

      POST BASE_URL/api/rest/vr/API_VERSION/pairings/PAIRING_ID/replications

        The "enhanced_replication" must be set to true, replication traffic must be encrypted "lwd_encryption_enabled": true, and "target_replication_server_id" must be set to null.

        Example Configure Enhanced Replication request body:

      [
        {
          "quiesce_enabled": false,
          "enhanced_replication": true,
          "rpo": 5,
          "network_compression_enabled": true,
          "mpit_enabled": false,
          "mpit_instances": 0,
          "mpit_days": 0,
          "auto_replicate_new_disks": true,
          "target_replication_server_id": null,
          "lwd_encryption_enabled": true,
          "vm_data_sets_replication_enabled": true,
          "disks": [
            {
              "vm_disk": {
                          "vm_id": "VirtualMachine:vm-xxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
                          "device_key": 0,
                          "is_vm_home": true,
                          "encrypted": false,
                          "capacity": 0,
                          "source_disk_format": null,
                          "source_path": {
                              "datastore_id": "Datastore:datastore-xx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
                              "datastore_name": "Test_Datatore",
                              "path": "XXXX",
                              "filename": "XXXX"
                          },
                          "source_storage_policy_name": "Datastore Default",
                          "source_storage_policy_id": null,
                          "label": "VM home",
                          "controller_key": 0,
                          "controller_label": null,
                          "supported_for_replication": false
              },
              "enabled_for_replication": true,
              "use_seeds": false,
              "destination_storage_policy_id": null,
              "destination_path": null,
              "destination_datastore_id": "Datastore:datastore-18:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
              "destination_disk_format": "SAME_AS_SOURCE"
            },
             {
              "vm_disk": {
                          "vm_id": "VirtualMachine:vm-xxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
                          "device_key": 2000,
                          "is_vm_home": false,
                          "encrypted": false,
                          "capacity": 524288,
                          "source_disk_format": "THICK",
                          "source_path": {
                              "datastore_id": "Datastore:datastore-xx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
                              "datastore_name": "Test_Datastore",
                              "path": "xxxx",
                              "filename": "xxxx"
                          },
                          "source_storage_policy_name": "Datastore Default",
                          "source_storage_policy_id": null,
                          "label": "Hard disk 1",
                          "controller_key": 1000,
                          "controller_label": "SCSI controller 0",
                          "supported_for_replication": true
              },
              "enabled_for_replication": true,
              "use_seeds": false,
              "destination_storage_policy_id": null,
              "destination_path": null,
              "destination_datastore_id": "Datastore:datastore-xx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
              "destination_disk_format": "SAME_AS_SOURCE"
            }
          ],
          "target_vc_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
          "vm_id": "VirtualMachine:vm-xxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx"
        }

      ]

Additional Information

Refer this video for demonstration of steps mentioned in this Knowledge Article - Automating DR using REST APIs and PowerCLI.

Please refer for more information - How to Re-configure Existing Legacy Replications to Use Enhanced vSphere Replication.

Note: The next release of vSphere Replication will deprecate the traditional (Legacy) vSphere Replication data path and replication through the appliance in favor of Enhanced vSphere Replication.