Updated on 2022-08-05 GMT+08:00

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).

The parameter value consists of 4 to 64 characters, including letters, digits, underscores (_), hyphens (-), periods (.).

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 only 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 (default): indicates that the target ECS will be started after the migration.
  • 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 (default): indicates that the migration Agent will not be uninstalled automatically from the source server after the migration.

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 IP address of the target ECS.

  • 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 which the target ECS belongs to.

project_id

Yes

String

Specifies the ID of the project which the target ECS belongs to. For details, see Obtaining a Project ID.

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

Mandatory under certain conditions

String

Specifies the name of the target ECS.

NOTE:
  • This parameter is mandatory when an existing VM is selected.
  • This parameter is optional when you select to create an ECS during migration.

disks

Mandatory under certain conditions

JSON array

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

NOTE:
  • This parameter is mandatory when an existing VM is selected.
  • This parameter is optional when you select to create an ECS during migration.

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 tag. If no tag 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 ID of the subvolume.

default_subvol_name

String

Specifies the default name of the subvolume.

default_subvol_mountpath

String

Specifies the default mount path of the 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 UUID of the parent volume of the subvolume.

is_snapshot

Yes

String

Specifies whether the subvolume is a snapshot.

subvol_id

Yes

String

Specifies the subvolume ID.

parent_id

Yes

String

Specifies the ID of the parent volume 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 the disk is 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.

topic_name

Yes

String

Specifies the topic name.

Response

Response parameters

For details about the response parameter, see Table 9.

Table 9 Response parameter

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":"UAE-Abu Dhabi",
          "region_id":"ae-ad-1",
         "region_name":""UAE-Abu Dhabi",
          "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 task to migrate a source server that runs a Linux OS

  • Example response
    {
    "id": "170606111111"
    }

Status Codes

See Status Codes.

Error Codes

See Out-of-Date Error Codes.