Creating a Migration Task

Function

This API is used to create a migration task based on a source server.

URI

POST /v1/sms/tasks

Request

Request parameters

For details about the request parameters, see Table 1.

Table 1 Request parameters

Parameter

Mandatory

Type

Description

name

Yes

String

Specifies the task name (user-defined).

type

Yes

String

Specifies the task type.

  • MIGRATE_FILE: indicates the file-level migration.
  • MIGRATE_BLOCK: indicates the block-level migration.

os_type

Yes

String

Specifies the OS type. The value can be WINDOWS or LINUX.

priority

No

int

Specifies the process priority.

  • 0: Low
  • 1: Standard (default)
  • 2: High

speed_limit

No

int

Specifies the migration rate limit (in MB).

The default value is 0, indicating that the migration rate is not limited.

start_target_server

No

Boolean

Specifies whether to start the target ECS after the migration.

  • true: indicates that the target ECS will be started after the migration. The default value is true.
  • false: indicates that the target ECS will be stopped after the migration.

uninstall_agent

No

Boolean

Specifies whether to automatically uninstall the migration Agent on the source server.

  • true: indicates that the migration Agent will be uninstalled automatically from the source server after the migration.
  • false: indicates that the migration Agent will not be uninstalled automatically from the source server after the migration. The default value is false.

source_server

Yes

JSON

Specifies the source server information. For details, see Table 2.

target_server

Yes

JSON

Specifies the target ECS information. For details, see Table 3.

migration_ip

Yes

String

Specifies the target ECS IP address.

  • Enter the elastic IP address if the migration network type is Internet.
  • Enter a private IP address if the migration network type is a private line or VPN.

region_name

Yes

String

Specifies the region name of the target ECS.

region_id

Yes

String

Specifies the region ID of the target ECS.

project_name

Yes

String

Specifies the name of the project to which the target ECS belongs.

project_id

Yes

String

Specifies the ID of the project to which the target ECS belongs.

vm_template_id

No

String

Specifies the template ID.

smn_info

No

JSON

Specifies the SMN service information. For details, see Table 8.

Table 2 source_server information

Parameter

Mandatory

Type

Description

id

Yes

String

Specifies the source server ID.

Table 3 target_server information

Parameter

Mandatory

Type

Description

vm_id

Yes

String

Specifies the target ECS ID.

name

Yes

String

Specifies the name of the target ECS.

disks

Yes

JSON array

Specifies the Disk information. For details, see Table 6.

btrfs_list

Yes

JSON array

Specifies the Btrfs information. For details, see Table 4.

Table 4 btrfs_list data structure

Parameter

Type

Description

name

String

Specifies the file system name, for example, /dev/vdb1.

label

String

Specifies the file system label. If no label exists, the value is an empty string.

uuid

String

Specifies the UUID of the file system.

device

String

Specifies the device name in the Btrfs.

default_subvolid

String

Specifies the default subvolume ID.

default_subvol_name

String

Specifies the default subvolume name.

default_subvol_mountpath

String

Specifies the mount path of the default subvolume.

subvolumn

JSON array

Specifies the subvolume information. For details, see Table 5.

Table 5 subvolumn data structure

Parameter

Mandatory

Type

Description

uuid

Yes

String

Specifies the parent volume UUID of the subvolume.

is_snapshot

Yes

String

Specifies whether the subvolume is snapshot.

subvol_id

Yes

String

Specifies the subvolume ID.

parent_id

Yes

String

Specifies the parent volume ID of the subvolume.

subvol_name

Yes

String

Specifies the subvolume name.

subvol_mount_path

Yes

String

Specifies the mount path of the subvolume.

Table 6 disks information in target_server

Parameter

Mandatory

Type

Description

name

Yes

String

Specifies the disk name.

disk_id

Yes

String

Specifies the ID of the EVS volume corresponding to the disk.

size

Yes

long

Specifies the disk size.

physical_volumes

Yes

JSON array

Specifies the partition information after disks are migrated. For details, see Table 7.

Table 7 physical_volumes information

Parameter

Mandatory

Type

Description

name

Yes

String

Specifies the partition name.

  • C in the Windows OS
  • sd1 in the Linux OS

size

Yes

long

Specifies the partition size (byte).

Table 8 smn_info information

Parameter

Mandatory

Type

Description

topic_urn

Yes

String

Specifies the topic URN.

trigger_conditions

Yes

String

Specifies the triggering condition for sending SMN messages. The value can be SUCCESS,FAIL, SUCCESS, or FAIL.

language

Yes

String

Specifies the Language option. The value can be zh_CN or en_US.

topic_name

Yes

String

Specifies the topic name.

Response

Response parameters

For details about the response parameters, see Table 9.

Table 9 Response parameters

Parameter

Type

Description

id

String

Specifies the task ID.

Example

  • Example request
    • Creating a task to migrate a source server that runs a Windows OS
      {
          "name": "Windows Migration",
          "type": "MIGRATE_BLOCK",
          "priority": "1",	
          "speed_limit": "0",	
          "start_target_server": "true",	
          "os_type": "WINDOWS",
          "migration_ip":"x.x.x.x",
          "region_name":"north-china",
          "region_id":"cn-north-1",
          "project_name":"cn-north-1",
          "project_id":"12222222111111121212121",
          "vm_template_id":"aaaa-bbbbb",
          "source_server":{
              "id":"35ef9d7a-b8e4-4126-9588-116952749de4"
          },
          "target_server": {
              "vm_id": "e198f4cc-e51a-43df-83d8-79bd41e00bed",  
              "disks": [
                  {
                      "name": "Disk 0",
                      "disk_id":"e198f4cc-e51a-43df-1234-79bd41e00bed",
                      "size": "85897247744",			
                      "physical_volumes": [
                          {
                              "name": "(Reserved)",	
                              "size": "104857088"
                          },
                          {
                              "name": "C:\\",
                              "size": "85792390656"
                          }
                      ]
                  },
      			{
                      "name": "Disk 1",
                      "disk_id":"e198f4cc-1234-43df-1234-79bd41e00bed",
                      "size": "214745218048",			
                      "physical_volumes": [
                          {
                              "name": "D:\\",	
                              "size": "109888667136"
                          },
                          {
                              "name": "F:\\",
                              "size": "104856550912"
                          }
                      ]
                  }
              ]
          }
      }
    • Creating a Linux Migration Task
      {
         "name": "sms_task_l",
         "type": "MIGRATE_FILE",
         "priority": "1",
         "speed_limit": 0,
         "start_target_server": "true",
         "os_type": "LINUX",
         "source_server": {
                "id": "0c1b1ab3-37ab-49c5-a59f-ad7edec4ea9f"
         },
         "target_server": {
                "name": "sms-target-test",
                "vm_id": "62339ed3-6ec1-xxxx-aa80-c4d907978e5f",
                "flavor": "Si2.small.1",
                "disks": [{
                       "name": "/dev/vda",
                       "disk_id": "bec4d401-b136-xxxx-b365-50c8bc03bfac",
                       "size": 42949672960,
                       "device_use": "BOOT",
                       "physical_volumes": [{
                              "uuid": null,
                              "index": 0,
                              "name": "/dev/vda1",
                              "device_use": "OS",
                              "file_system": "ext3",
                              "mount_point": "/",
                              "size": 42948624384,
                              "used_size": 4851286016
                       }]
                }, {
                       "name": "/dev/vdb",
                       "disk_id": "624822f4-xxxx-4ab1-8a41-ae9fe141acd4",
                       "size": 10737418240,
                       "device_use": "BTRFS",
                       "physical_volumes": []
                }, {
                       "name": "/dev/vdc",
                       "disk_id": "7157722b-xxxx-463e-9a80-b69de5afc991",
                       "size": 10737418240,
                       "device_use": "BTRFS",
                       "physical_volumes": []
                }],
                "volume_groups": [],
                "btrfs_list": [{
                       "name": "/dev/vdb",
                       "label": "bcc",
                       "uuid": "abc8565e-b14b-xxxx-92b6-6c7fca983bc6",
                       "device": "/dev/vdb,/dev/vdc",
                       "default_subvolid": "258",
                       "default_subvol_name": "sub1",
                       "default_subvol_mountpath": "/mnt/btrfs/vdb1",
                       "subvolumn": [{
                              "uuid": "abc8565e-b14b-xxxx-92b6-6c7fca983bc6",
                              "is_snapshot": "false",
                              "subvol_id": "258",
                              "parent_id": "5",
                              "subvol_name": "sub1",
                              "subvol_mount_path": "/mnt/btrfs/vdb1"
                       }, {
                              "uuid": "abc8565e-b14b-xxxx-92b6-6c7fca983bc6",
                              "is_snapshot": "false",
                              "subvol_id": "259",
                              "parent_id": "5",
                              "subvol_name": "sub2",
                              "subvol_mount_path": "null"
                       }],
                       "$$hashKey": "object:2949"
                }]
         },
         "smn_info": null,
         "auto_install_pvdriver": true,
         "allow_sync": false,
         "final_sync": false,
         "allow_restart": true,
         "uninstall_agent": true,
         "migration_ip": "100.**.***.46",
         "region_name": "cn-1",
         "region_id": "cn-north-1",
         "project_name": "cn-north-1",
         "project_id": "b276e6********4598f049745ce9"
      }
  • Example response
    {
    "id": "170606111111"
    }

Status Code

For details about the status code, see Status Code.

Error Code

For details, see Error Code.