vSphere Replication REST API を使用して、ソース サイトからターゲット サイトへの仮想マシンのレプリケーションを構成できます。

前提条件

仮想マシンのレプリケーションを構成するには、次の手順を実行します。
  • VRMS Appliance Management Interface または VRMS アプライアンス構成 REST API Gateway を使用して vSphere Replication を Platform Services Controller (PSC) に登録する必要があります。
  • ソース サイトとターゲット サイトの間にサイト ペアが必要です。

手順

  1. ソース サイトにログインするには、POST 要求を送信します。
    POST BASE_URL/api/rest/vr/API_VERSION/session

    認証 HTTP ヘッダーにユーザー名とパスワードを入力します。返されたセッション ID を、REST API に対する以降のすべての呼び出しにおける [x-dr-session] HTTP ヘッダーの値として使用します。

  2. ペアリング ID とローカル vCenter Server ID を取得するには、GET 要求を送信します。
    GET BASE_URL/api/rest/vr/API_VERSION/pairings/
    応答の例:
    {
       "pairing_id": "e41c183f-bc55-319b-bf76-8ec83d335074", <----------- Pairing ID
       "local_vc_server": {
          "id": "0a98c22d-a553-47e4-bd56-2844f45d8ef6", <--------------- VC ID
          "url": "https://s2-srm2-219-12.eng.vmware.com:443/sdk",
          "name": "s2-srm2-219-12.eng.vmware.com",
          "server_status": "OK",
          // Other fields are not relevant in this example
    }

    ペアリング ID とローカル vCenter Server ID を保存します。

  3. サイト ペアごとに仮想マシン ID を取得するには、GET 要求を送信します。
    GET BASE_URL/api/rest/vr/API_VERSION/pairings/PAIRING_ID/vcenters/VC_GUID/vms

    レプリケーションを構成する仮想マシンの ID を保存します。

  4. ターゲット vSphere Replication サーバの ID を取得するには、次の手順を実行します。
    1. POST 要求を送信して、ターゲット サイトにログインします。
      POST BASE_URL/api/rest/vr/API_VERSION/pairings/PAIRING_ID/remote-session

      認証 HTTP ヘッダーにユーザー名とパスワードを入力します。[x-dr-session] HTTP ヘッダーがまだあることを確認します。

    2. GET 要求を送信して、ペアリング内のすべての vSphere Replication 管理サーバ インスタンスを取得します。
      GET BASE_URL/api/rest/vr/API_VERSION/pairings/PAIRING_ID/vrs

      ターゲット vSphere Replication 管理サーバの ID を保存します。

    3. GET 要求を送信して、ターゲット vSphere Replication 管理サーバに登録されているすべての vSphere Replication サーバを取得します。
      GET BASE_URL/api/rest/vr/API_VERSION/pairings/PAIRING_ID/vrs/VR_ID/replication-servers

      PAIRING_ID 値をペアリングの ID に、VR_ID 値を手順 4.b で取得したターゲット vSphere Replication 管理サーバの ID に置き換えます。

      結果から得られたターゲット vSphere Replication サーバの ID を保存します。

  5. ターゲット データストアを取得するには、GET 要求を送信します。
    GET BASE_URL/api/rest/vr/API_VERSION/pairings/PAIRING_ID/vcenters/VC_ID/datastores

    VC_ID 値をターゲット vCenter Server の ID に置き換えて、応答を保存します。

  6. 優先ストレージ ポリシー ID を取得するには、GET 要求を送信します。
    GET BASE_URL/api/rest/vr/API_VERSION/pairings/PAIRING_ID/vcenters/VC_ID/storage-policies

    VC_ID 値をターゲット vCenter Server の ID に置き換えて、優先ターゲット ストレージ ポリシー ID を保存します。

  7. 仮想マシンのディスクに関する情報を取得するには、GET 要求を送信します。
    GET BASE_URL/api/rest/vr/API_VERSION/pairings/PAIRING_ID/vcenters/VC_ID/vms/VM_ID/disks

    VC_ID 値をソース vCenter Server の ID に、VM_ID 値を手順 3 で取得した仮想マシンの ID に置き換えて、応答を保存します。

  8. レプリケーションを構成するには、POST 要求を送信します。
    POST BASE_URL/api/rest/vr/API_VERSION/pairings/PAIRING_ID/replications
    レプリケーション構成要求の本文の例:
    [
       {
          "auto_replicate_new_disks": true,
          "rpo": 60,
          "lwd_encryption_enabled": false,
          "mpit_days": 0,
          "mpit_enabled": false,
          "mpit_instances": 0,
          "network_compression_enabled": false,
          "quiesce_enabled": false,
          // You get this from Step 3.
          "vm_id": "VirtualMachine:vm-38:fa655d23-b8ac-4eb1-8351-129954807e2c",
          //You get this from Step 4.
          "target_replication_server_id": "HmsRemoteHbrServer:HBRSRV-26c6bd13-1fac-4d04-adcb-2700a258025c:b41aa649-bd9b-45e0-9d41-a7a16c0b0946",
          "target_vc_id": "54d0e5ab-3e9d-4372-9f27-036cf1c24639"
          "disks": [
             {
                //  You get this from Step 5.
                "destination_datastore_id": "Datastore:datastore-18:54d0e5ab-3e9d-4372-9f27-036cf1c24639",
                // Options for destination_disk_format parameter: SAME_AS_SOURCE, SAME_AS_PRIMARY, AS_DEFINED_IN_PROFILE, FLAT, THICK, NATIVE_THICK, THIN, RDM.
                "destination_disk_format": "SAME_AS_SOURCE",
                "enabled_for_replication": true,
                "use_seeds": false,
                "destination_path": "target_folder/test-vm-1",
                // You get this from Step 6.
                "destination_storage_policy_id": "4b97756b-3c50-481a-a105-d6a7b1507f9a",
               //  You got this from Step 7.
                "vm_disk" : {
                    "vm_id": "VirtualMachine:vm-38:fa655d23-b8ac-4eb1-8351-129954807e2c",
                    "device_key": 2000,
                    "is_vm_home": false,
                    "encrypted": false,
                    "capacity": 524288,
                    "source_disk_format": "THIN",
                    "source_path": {
                        "datastore_id": "Datastore:datastore-17:fa655d23-b8ac-4eb1-8351-129954807e2c",
                        "datastore_name": "local",
                        "path": "test-vm-1",
                        "filename": "test-vm-1.vmdk"
                    },
                    "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
                }
             },
             {
                //  You get this from Step 5.
                "destination_datastore_id": "Datastore:datastore-18:54d0e5ab-3e9d-4372-9f27-036cf1c24639",
                "destination_disk_format": "SAME_AS_SOURCE",
                "enabled_for_replication": true,
                "use_seeds": false,
                "destination_path": "target_folder/test-vm-1",
                //  You get this from Step 6.
                "destination_storage_policy_id": "4b97756b-3c50-481a-a105-d6a7b1507f9a",
                // You get this from Step 7.
                "vm_disk" : {
                    "vm_id": "VirtualMachine:vm-38:fa655d23-b8ac-4eb1-8351-129954807e2c",
                    "device_key": 0,
                    "is_vm_home": true,
                    "encrypted": false,
                    "capacity": 0,
                    "source_disk_format": null,
                    "source_path": {
                        "datastore_id": "Datastore:datastore-17:fa655d23-b8ac-4eb1-8351-129954807e2c",
                        "datastore_name": "local",
                        "path": "test-vm-1",
                        "filename": "test-vm-1.vmx"
                    },
                    "source_storage_policy_name": "Datastore Default",
                    "source_storage_policy_id": null,
                    "label": "VM home",
                    "controller_key": 0,
                    "controller_label": null,
                    "supported_for_replication": false
                }
             }
          ]
       }
    ]