Advanced
Тема интерфейса

Getting Started

Overview

This section describes how to make calls to SMS APIs to create a migration task.

The procedure is as follows:

  1. Call the Token-based Authentication API to obtain the user token, which will be put into the request header for authentication in a subsequent request.
  2. Install the migration Agent on a prepared server that can access the Internet. For details, see section "Installing the Linux Agent" in the Server Migration Service User Guide.
  3. Obtain the ID of the source server to be migrated from the queried source server list. For details about how to query source server list, see Listing Source Servers.
  4. Select an ECS as the target server to obtain its ID.
  5. Make a call to the API for creating a migration task to create a migration task.

    After creating the migration task, you can view it on the SMS console.

Prerequisites

  • You have obtained the endpoints of IAM. For details, see Regions and Endpoints.
  • You have obtained the endpoints of SMS. For details, see Regions and Endpoints.
  • You have obtained the project ID. For details, see Obtaining a Project ID.
  • You have obtained the ID of the region where the target ECS is located, which is also the default project name of the region where the target ECS is located.

Procedure

  1. Call the Token-based Authentication API to obtain a user token. Set the user token as an environment variable to call other APIs for authentication.
    1. Run the following command to obtain a user token:
      curl -X POST https://{iam_endpoint}/v3/auth/tokens -H 'content-type: application/json' -d '{
      "auth": {
      "identity": {
      "methods": [
      "password"
      ],
      "password": {
      "user": {
      "name": "{user_name}",
      "domain": {
      "name": "{user_name}"
      },
      "password": "{password}"
      }
      }
      },
      "scope": {
      "project": {
      "id": "{project_id}"
      }
      }
      }
      }

      Modify the command parameters as follows (for details, see the Identity and Access Management API Reference):

      • {iam_endpoint}: Replace it with the obtained IAM endpoint.
      • {project_id}: Replace it with the obtained project ID.
      • {user_name} and {password}: Replace them respectively with the username and password of the IAM server.

      In the response header, the value of X-Subject-Token is the token.

      X-Subject-Token:MIIDkgYJKoZIhvcNAQcCoIIDgzCCA38CAQExDTALBglghkgBZQMEAgEwgXXXXX...
    2. Run the following command to set the token as an environment variable:

      export Token={X-Subject-Token}

      Replace value of X-Subject-Token with the token obtained in the previous step. An example command is as follows:

      export Token=MIIDkgYJKoZIhvcNAQcCoIIDgzCCA38CAQExDTALBglghkgBZQMEAgEwgXXXXX...
  2. Install the Linux Agent. For details, see section "Installing the Linux Agent" in the Server Migration Service User Guide.
  3. Query the ID of the source server. For details, see Listing Source Servers. Obtain the ID of the source server to be migrated from the queried source server list.
  4. Make a call to the API described in Creating a Migration Task to create a migration task.

    The following uses the Linux OS as an example to describe how to create a migration task.

    curl -X POST https://{sms_endpoint}/v1.0/tasks -H 'content-type: application/json' -H "x-auth-token: $Token" -d '
    {
    "name": "Linux Migration",
    "type": "MIGRATE_FILE",
    "priority": "1",
    "speed_limit": "0",
    "start_target_server": "true",
    "os_type": "LINUX",
    "float_ip": "x.x.x.x",
    "region_name": "RU-Moscow",
    "region_id": "{region_id}",
    "project_name": "ru-moscow-1",
    "project_id": "{project_id}",
    "source_server": {
    "id": "{id}"
    },
    "target_server": {
    "vm_id": "{vm_id}",
    "disks": [{
    "name": "Disk 0",
    "disk_id": "e198f4cc-e51a-43df-1234-79bd41e00bed",
    "size": "85897247744",
    "physical_volumes": [{
    "name": "xvda1",
    "size": "104857088"
    }, {
    "name": "xvda2",
    "size": "85792390656"
    }
    ]
    }, {
    "name": "Disk 1",
    "disk_id": "e198f4cc-1234-43df-1234-79bd41e00bed",
    "size": "214745218048",
    "physical_volumes": [{
    "name": "xvdb1",
    "size": "109888667136"
    }, {
    "name": "xvdb2",
    "size": "104856550912"
    }
    ]
    }
    ]
    }
    }

    Modify the command parameters as follows. For details on how to set other parameters, see Creating a Migration Task.

    • {region_id}: Replace it with the default project name of the region where the target ECS is located.
    • {project_id}: Replace it with the project ID obtained in Obtaining a Project ID.
    • {id}: Replace it with the ID of the source server to be migrated queried in 3.
    • {vm_id}: Replace it with the ID of the target ECS.
  5. After the migration task is created, you can view it on the Task Management page on the SMS console.