Updated on 2024-07-08 GMT+08:00

Creating a Migration Task

Function

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

Calling Method

For details, see Calling APIs.

URI

POST /v3/tasks

Request

Table 1 Request header parameter

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

The user token. It can be obtained by calling the IAM API (value of X-Subject-Token in the response header).

Minimum length: 1 character

Maximum length: 16,384 characters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

name

Yes

String

The task name.

Minimum length: 0 characters

Maximum length: 255 characters

type

Yes

String

The task type.

The value can be:

  • MIGRATE_FILE

  • MIGRATE_BLOCK

start_target_server

No

Boolean

Whether to start the target server after the migration is complete.

Default value: true

os_type

Yes

String

The OS type.

Minimum length: 0 characters

Maximum length: 255 characters

source_server

Yes

SourceServerByTask object

The source server information.

target_server

Yes

TargetServerByTask object

The target server information.

migration_ip

No

String

The IP address used for migration. This parameter is not required if the target server is automatically created.

Minimum length: 0 characters

Maximum length: 255 characters

region_name

Yes

String

The region name.

Minimum length: 0 characters

Maximum length: 255 characters

region_id

Yes

String

The region ID.

Minimum length: 0 characters

Maximum length: 255 characters

project_name

Yes

String

The project name.

Minimum length: 0 characters

Maximum length: 255 characters

project_id

Yes

String

The project ID.

Minimum length: 0 characters

Maximum length: 255 characters

vm_template_id

No

String

The ID of the template used to create the target server automatically.

Minimum length: 0 characters

Maximum length: 255 characters

use_public_ip

No

Boolean

Specifies whether to use a public IP address for migration.

Default value: true

syncing

No

Boolean

Specifies whether to perform a continuous synchronization after the first replication. If this parameter is not specified, the default value false is used.

Default value: false

exist_server

No

Boolean

Checks whether the service exists. If it does, create the task.

start_network_check

No

Boolean

Whether to measure the network performance.

Table 3 SourceServerByTask field description

Parameter

Mandatory

Type

Description

id

Yes

String

The source server ID.

Minimum length: 0 characters

Maximum length: 255 characters

Table 4 TargetServerByTask field description

Parameter

Mandatory

Type

Description

btrfs_list

No

Array of BtrfsFileSystem objects

The Btrfs information, which is obtained from the source server.

Array length: 0 to 65,535 characters

disks

Yes

Array of TargetDisks objects

The disk information.

Array length: 0 to 65,535 characters

name

Yes

String

The name.

Minimum length: 0 characters

Maximum length: 255 characters

vm_id

Yes

String

The target server ID.

Minimum length: 0 characters

Maximum length: 255 characters

volume_groups

No

Array of VolumeGroups objects

The volume group information, which is obtained from the source server.

Array length: 0 to 65,535 characters

Table 5 BtrfsFileSystem field description

Parameter

Mandatory

Type

Description

name

Yes

String

The file system name.

Minimum length: 0 characters

Maximum length: 255 characters

label

Yes

String

The file system tag. If no tag exists, the value is an empty string.

Minimum length: 0 characters

Maximum length: 255 characters

The UUID.

Yes

String

The UUID of the file system.

Minimum length: 0 characters

Maximum length: 255 characters

device

Yes

String

The device name in the Btrfs.

Minimum length: 0 characters

Maximum length: 255 characters

size

Yes

Long

The space occupied by the file system.

Minimum value: 0

Maximum value: 9223372036854775807

nodesize

Yes

Long

The size of the Btrfs node.

Minimum value: 0

Maximum value: 9223372036854775807

sectorsize

Yes

Integer

The sector size.

Minimum value: 0

Maximum value: 2147483647

data_profile

Yes

String

The data profile (RAD).

Minimum length: 0 characters

Maximum length: 255 characters

system_profile

Yes

String

The file system profile (RAD).

Minimum length: 0 characters

Maximum length: 255 characters

metadata_profile

Yes

String

The metadata profile (RAD).

Minimum length: 0 characters

Maximum length: 255 characters

global_reserve1

Yes

String

The Btrfs file system information.

Minimum length: 0 characters

Maximum length: 255 characters

g_vol_used_size

Yes

Long

The used space of the Btrfs volume.

Minimum value: 0

Maximum value: 9223372036854775807

default_subvolid

Yes

String

The ID of the default subvolume.

Minimum length: 0 characters

Maximum length: 255 characters

default_subvol_name

Yes

String

The name of the default subvolume.

Minimum length: 0 characters

Maximum length: 255 characters

default_subvol_mountpath

Yes

String

The mount path of the default subvolume or Btrfs file system.

Minimum length: 0 characters

Maximum length: 255 characters

subvolume

Yes

Array of BtrfsSubvolumn objects

The subvolume information.

Array length: 0 to 65,535 characters

Table 6 BtrfsSubvolumn field description

Parameter

Mandatory

Type

Description

The UUID.

Yes

String

The UUID of the parent volume.

Minimum length: 0 characters

Maximum length: 255 characters

is_snapshot

Yes

String

Specifies whether the subvolume is a snapshot.

Minimum length: 0 characters

Maximum length: 255 characters

subvol_id

Yes

String

The subvolume ID.

Minimum length: 0 characters

Maximum length: 255 characters

parent_id

Yes

String

The parent volume ID.

Minimum length: 0 characters

Maximum length: 255 characters

subvol_name

Yes

String

The subvolume name.

Minimum length: 0 characters

Maximum length: 255 characters

subvol_mount_path

Yes

String

The mount path of the subvolume.

Minimum length: 0 characters

Maximum length: 255 characters

Table 7 TargetDisks field description

Parameter

Mandatory

Type

Description

device_use

No

String

The disk function.

Default value: NORMAL

The value can be:

  • NORMAL

  • OS

  • BOOT

disk_id

No

String

The disk ID. This parameter is not required if the target server is automatically created.

Minimum length: 0 characters

Maximum length: 255 characters

name

Yes

String

The disk name. Set this parameter to Disk X based on the disk sequence.

Minimum length: 0 characters

Maximum length: 255 characters

physical_volumes

Yes

Array of PhysicalVolumes objects

The physical volume information.

Array length: 0 to 65,535 characters

size

Yes

Long

The volume size.

Minimum value: 0

Maximum value: 9223372036854775807

used_size

Yes

Long

The used space.

Minimum value: 0

Maximum value: 9223372036854775807

Table 8 PhysicalVolumes field description

Parameter

Mandatory

Type

Description

device_use

No

String

The partition type. The value can be NORMAL, BOOT, or OS.

Minimum length: 0 characters

Maximum length: 255 characters

file_system

No

String

The file system type.

Minimum length: 0 characters

Maximum length: 255 characters

index

No

Integer

The serial number of the volume.

Minimum value: 0

Maximum value: 2147483647

mount_point

No

String

The mount point.

Minimum length: 0 characters

Maximum length: 255 characters

name

No

String

The volume name. In Windows, it indicates the drive letter, and in Linux, it indicates the device ID.

Minimum length: 0 characters

Maximum length: 255 characters

size

No

Long

The volume size.

Minimum value: 0

Maximum value: 9223372036854775807

inode_size

No

Long

The number of inodes.

Minimum value: 0

Maximum value: 9223372036854775807

used_size

No

Long

The used space.

Minimum value: 0

Maximum value: 9223372036854775807

The UUID.

No

String

The GUID of the volume, which can be obtained from the source server.

Minimum length: 0 characters

Maximum length: 255 characters

Table 9 VolumeGroups field description

Parameter

Mandatory

Type

Description

components

No

String

The physical volume information.

Minimum length: 0 characters

Maximum length: 255 characters

free_size

No

Long

The available space.

Minimum value: 0

Maximum value: 9223372036854775807

logical_volumes

No

Array of LogicalVolumes objects

The logical volume information.

Array length: 0 to 255 characters

name

No

String

The name.

Minimum length: 0 characters

Maximum length: 255 characters

size

No

Long

The volume size.

Minimum value: 0

Maximum value: 9223372036854775807

Table 10 LogicalVolumes field description

Parameter

Mandatory

Type

Description

block_count

No

Integer

The number of blocks.

Minimum value: 0

Maximum value: 4294967296

Default value: 0

block_size

No

Long

The block size.

Minimum value: 0

Maximum value: 1048576

Default value: 0

file_system

Yes

String

The file system.

Minimum length: 0 characters

Maximum length: 255 characters

inode_size

Yes

Integer

The number of inodes.

Minimum value: 0

Maximum value: 4294967296

device_use

No

String

The partition type. The value can be NORMAL, BOOT, or OS.

Minimum length: 0 characters

Maximum length: 255 characters

mount_point

Yes

String

The mount point.

Minimum length: 0 characters

Maximum length: 256 characters

name

Yes

String

The name.

Minimum length: 0 characters

Maximum length: 1,024 characters

size

Yes

Long

The volume size.

Minimum value: 0

Maximum value: 9223372036854775807

used_size

Yes

Long

The used space.

Minimum value: 0

Maximum value: 9223372036854775807

free_size

Yes

Long

The available space.

Minimum value: 0

Maximum value: 9223372036854775807

Response

Status code: 200

Table 11 Response body parameters

Parameter

Type

Description

id

String

The task ID returned when the task is created successfully.

Minimum length: 0 characters

Maximum length: 255 characters

Example Request

This example creates a migration task whose name is MigrationTask. The migration type is MIGRATE_FILE, the source server runs Linux, the migration uses the public network, the migration region name is region_name, and the migration region ID is region_id.

POST https://{endpoint}/v3/tasks

{
  "name" : "MigrationTask",
  "type" : "MIGRATE_FILE",
  "os_type" : "LINUX",
  "start_target_server" : true,
  "use_public_ip" : true,
  "migration_ip" : "192.168.0.1",
  "region_name" : "region_name",
  "region_id" : "region_id",
  "project_name" : "project_name",
  "project_id" : "b276e6fb38c74aa2ba4598f049745ce9",
  "source_server" : {
    "id" : "16c03428-ff9a-4f36-84aa-583e41499bb2"
  },
  "target_server" : {
    "vm_id" : "1900aab8-90c4-462c-b4c5-acdafc8fbeca",
    "name" : "Auto-tar-name",
    "disks" : [ {
      "name" : "/dev/vda",
      "disk_id" : "76a59f9f-5901-4913-a9a5-f6742baa308c",
      "size" : 42949672960,
      "used_size" : 429496,
      "device_use" : "BOOT",
      "physical_volumes" : [ {
        "uuid" : null,
        "index" : 0,
        "name" : "/dev/vda1",
        "device_use" : "OS",
        "file_system" : "ext4",
        "mount_point" : "/",
        "size" : 42947575808,
        "used_size" : 5346484224
      } ]
    } ],
    "volume_groups" : [ ]
  }
}

Example Response

Status code: 200

OK

{
  "id" : "8abda8635e09d185015e09d188dd0001xx"
}

Status Codes

Status Code

Description

200

Response returned.

Error Codes

For details, see Error Codes.