Updating a Migration Task
Function
This API is used to update a migration task with a specified ID.
Calling Method
For details, see Calling APIs.
Authorization
Each account has all of the permissions required to call all APIs, but IAM users must have the required permissions specifically assigned.
- If you are using role/policy-based authorization, see the required permissions in Permissions Policies and Supported Actions.
- If you are using identity policy-based authorization, the permission listed below is required.
Action
Access Level
Resource Type (*: required)
Condition Key
Alias
Dependencies
sms:server:updateTask
Write
server *
-
- sms:server:migrationServer
-
-
g:EnterpriseProjectId
URI
PUT /v3/tasks/{task_id}
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
task_id |
Yes |
String |
The migration task ID. |
Request
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
X-Auth-Token |
No |
String |
The user token. The token can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
name |
No |
String |
The task name, which is defined by the user. |
|
type |
No |
String |
The task type. This parameter is mandatory for creating a task and optional for updating a task. MIGRATE_FILE: file-level migration MIGRATE_BLOCK: block-level migration The value can be: |
|
os_type |
No |
String |
The OS type, which can be Windows or Linux. This parameter is mandatory for creating a task and optional for updating a task. The value can be: |
|
id |
No |
String |
The migration task ID. |
|
priority |
No |
Integer |
The migration process priority. 0: low 1: standard (default) 2: high Range 0 to 2 The value can be: |
|
region_id |
No |
String |
The ID of the region where the target server is located. |
|
start_target_server |
No |
Boolean |
Indicates whether the target server is started after the migration is complete. true: indicates that the target server will be launched after the migration is complete. false: indicates that the target server will be stopped after the migration is complete. Default Value true |
|
enterprise_project_id |
No |
String |
The enterprise project ID. |
|
exist_server |
No |
Boolean |
Indicates whether an existing server is used as the target server. true indicates that an existing server is used as the target server. false indicates that the target server is newly created. |
|
migration_ip |
No |
String |
The IP address of the target server. If you use a public network for migration, enter the EIP bound to the target server. If you use a private line for migration, enter the private IP address of the target server. |
|
region_name |
No |
String |
The name of the region where the target server is located. |
|
speed_limit |
No |
Integer |
The migration rate limit, in Mbit/s. Range 0 to 10000 |
|
project_name |
No |
String |
The name of the project to which the target server belongs. |
|
project_id |
No |
String |
The ID of the project to which the target server belongs. |
|
vm_template_id |
No |
String |
The template ID. |
|
source_server |
No |
PostSourceServerBody object |
The information about the source server in the migration task. |
|
target_server |
No |
TargetServer object |
The information about the target server in the migration task. |
|
state |
No |
String |
The task status. |
|
estimate_complete_time |
No |
Long |
The estimated completion time. Range 0 to 9223372036854775807 |
|
connected |
No |
Boolean |
The connection status. |
|
create_date |
No |
Long |
The task creation time. Range: 0 to 9223372036854775807 |
|
start_date |
No |
Long |
The task start time. Range: 0 to 9223372036854775807 |
|
finish_date |
No |
Long |
The task end time. Range: 0 to 9223372036854775807 |
|
migrate_speed |
No |
Double |
The migration rate, in Mbit/s. Range 0 to 10000 |
|
error_json |
No |
String |
The error message. |
|
total_time |
No |
Long |
The task duration. Range 0 to 9223372036854775807 |
|
float_ip |
No |
String |
Retain this parameter temporarily to ensure the compatibility with the SMS-Agent of the earlier version. |
|
remain_seconds |
No |
Long |
The remaining migration time, in seconds. Range: 0 to 9223372036854775807 |
|
target_snapshot_id |
No |
String |
The ID of the snapshot for the target server. |
|
clone_server |
No |
CloneServer object |
The information about the cloned server. |
|
sub_tasks |
No |
Array of SubTask objects |
The list of subtasks included in the migration task. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
id |
No |
String |
The ID of the source server in the SMS database. |
|
ip |
No |
String |
The IP address of the source server. This parameter is mandatory for registering the source server with SMS and optional for updating the information about the source server. |
|
name |
No |
String |
The source server name in SMS. |
|
hostname |
No |
String |
The hostname of the source server. This parameter is mandatory for registering the source server with SMS and optional for updating the information about the source server. |
|
os_type |
No |
String |
The OS type of the source server, which can be Windows or Linux. This parameter is mandatory for source server registration and optional for source server updates. The value can be: |
|
os_version |
No |
String |
The OS version. This parameter is mandatory for source server registration and optional for source server updates. |
|
virtualization_type |
No |
String |
The OS virtualization type. |
|
linux_block_check |
No |
String |
The Linux block check. |
|
firmware |
No |
String |
The boot mode of the source server, which can be BIOS or UEFI. The value can be: |
|
cpu_quantity |
No |
Integer |
The number of vCPUs. Range 0 to 65535 |
|
memory |
No |
Long |
The memory size, in MB. Range 0 to 9223372036854775807 |
|
disks |
No |
Array of ServerDisk objects |
The information about disks on the source server. |
|
btrfs_list |
No |
Array of BtrfsFileSystem objects |
The information about Btrfs file systems on the source server. This parameter is mandatory for Linux. If there are no Btrfs file systems on the source server, the value is an empty array []. |
|
networks |
No |
Array of NetWork objects |
The information about NICs on the source server. |
|
domain_id |
No |
String |
The tenant domain ID. |
|
has_rsync |
No |
Boolean |
Indicates whether rsync is installed. This parameter is mandatory for Linux. |
|
paravirtualization |
No |
Boolean |
Indicates whether the source server is paravirtualized. This parameter is mandatory for Linux. |
|
raw_devices |
No |
String |
The list of raw devices. This parameter is mandatory for Linux. |
|
driver_files |
No |
Boolean |
Indicates whether any driver files are missing. This parameter is mandatory for Windows. |
|
system_services |
No |
Boolean |
Indicates whether there are abnormal services. This parameter is mandatory for Windows. |
|
account_rights |
No |
Boolean |
Indicates whether the account has the required permissions. This parameter is mandatory for Windows. |
|
boot_loader |
No |
String |
The system bootloader, which can be GRUB or LILO. This parameter is mandatory for Linux. The value can be: |
|
system_dir |
No |
String |
The system directory. This parameter is mandatory for Windows. |
|
volume_groups |
No |
Array of VolumeGroups objects |
This parameter is mandatory for Linux. If there are no volume groups, the value is an empty array []. |
|
agent_version |
No |
String |
The Agent version. |
|
kernel_version |
No |
String |
The kernel version. |
|
migration_cycle |
No |
String |
The current migration stage of the source server. cutovering: The paired target server is being launched. cutovered: The paired target server is launched. checking: The check is in progress. setting: The configuration is in progress. replicating: The data is being replicated. syncing: The incremental data is being synchronized. The value can be: |
|
state |
No |
String |
The source server status. unavailable: The source server fails the environment check. waiting: The source server is waiting for migration. initialize: The migration of the source server is being initialized. replicate: The source server is being replicated. syncing: The source server is being synchronized. stopping: The migration of the source server is being stopped. stopped: The migration of the source server is stopped. skipping: The operation is being skipped. deleting: The source server record is being deleted. error: An error occurs during the migration of the source server. cloning: The paired target server is being cloned. cutovering: The paired target server is being launched. finished: The paired target server is launched. clearing: The snapshot resources are being cleared. cleared: The snapshot resources have been cleared. clearfailed: The snapshot resources fail to be cleared. premigready: The migration drill is ready. premiging: The migration drill is in progress. premiged: The migration drill has been completed. premigfailed: The migration drill fails. The value can be: |
|
oem_system |
No |
Boolean |
Indicates whether the OS is an OEM version (Windows). |
|
start_type |
No |
String |
The startup mode. The value can be MANUAL, MGC, or an empty string (""). The value can be: |
|
io_read_wait |
No |
Double |
The disk read latency (in ms). Range 0.0 to 10000.0 |
|
has_tc |
No |
Boolean |
Indicates whether TC is installed. This parameter is mandatory for Linux. |
|
platform |
No |
String |
The platform. hw: Huawei Cloud ali: Alibaba Cloud aws: AWS azure: Microsoft Azure gcp: Google Cloud tencent: Tencent Cloud vmware: VMware hyperv: Hyper-V other: other providers The value can be: |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
name |
Yes |
String |
The disk name. |
|
partition_style |
No |
String |
The disk partition type. This parameter is mandatory for source server registration. MBR: Master Boot Record (MBR) GPT: GUID Partition Table (GPT) The value can be: |
|
device_use |
Yes |
String |
The disk function. BOOT: boot device OS: system device The value can be: |
|
size |
Yes |
Long |
The disk size, in bytes. Range 0 to 9223372036854775807 |
|
used_size |
Yes |
Long |
The used disk space, in bytes. Range 0 to 9223372036854775807 |
|
physical_volumes |
Yes |
Array of PhysicalVolume objects |
The information about physical partitions on the disk. |
|
os_disk |
No |
Boolean |
Indicates whether the disk is the system disk. |
|
relation_name |
No |
String |
The name of the paired disk on the Linux target server. |
|
inode_size |
No |
Integer |
The inode size. Range 0 to 2147483647 |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
device_use |
No |
String |
The partition function. The partition can be a general, boot, or OS partition. |
|
file_system |
No |
String |
The file system type. |
|
index |
No |
Integer |
The serial number. Range 0 to 2147483647 |
|
mount_point |
No |
String |
The mount point. |
|
name |
No |
String |
The volume name. In Windows, it indicates the drive letter, and in Linux, it indicates the device ID. |
|
size |
No |
Long |
The size. Range 0 to 9223372036854775807 |
|
used_size |
No |
Long |
The used space. Range 0 to 9223372036854775807 |
|
inode_size |
No |
Integer |
The number of inodes. Range 0 to 2147483647 |
|
inode_nums |
No |
Long |
The number of inodes. Range 0 to 9223372036854775807 |
|
uuid |
No |
String |
The GUID, which can be obtained from the source server. |
|
size_per_cluster |
No |
Integer |
The size of each cluster. Range 0 to 2147483647 |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
id |
No |
String |
The ID of the server in the SMS database. |
|
ip |
Yes |
String |
The IP address of the server. This parameter is mandatory for registration and optional for updates. |
|
name |
Yes |
String |
The server name. |
|
hostname |
No |
String |
The hostname of the server. This parameter is mandatory for registration and optional for updates. |
|
os_type |
Yes |
String |
The OS type of the server, which can be Windows or Linux. This parameter is mandatory for source server registration and optional for source server updates. The value can be: |
|
os_version |
No |
String |
The OS version. This parameter is mandatory for source server registration and optional for source server updates. |
|
firmware |
No |
String |
The boot mode of the server, which can be BIOS or UEFI. The value can be: |
|
cpu_quantity |
No |
Integer |
The number of vCPUs. Range 0 to 65535 |
|
memory |
No |
Long |
The memory size, in MB. Range 0 to 9223372036854775807 |
|
btrfs_list |
No |
Array of BtrfsFileSystem objects |
The Btrfs information of the server, which is mandatory for Linux. If there are no Btrfs file systems on the server, the value is an empty array []. |
|
networks |
No |
Array of NetWork objects |
The information about NICs on the server. |
|
domain_id |
No |
String |
The tenant domain ID. |
|
has_rsync |
No |
Boolean |
Indicates whether rsync is installed. This parameter is mandatory for Linux. |
|
paravirtualization |
No |
Boolean |
Indicates whether the source server is paravirtualized. This parameter is mandatory for Linux. |
|
raw_devices |
No |
String |
The list of raw devices. This parameter is mandatory for Linux. |
|
driver_files |
No |
Boolean |
Indicates whether any driver files are missing. This parameter is mandatory for Windows. |
|
system_services |
No |
Boolean |
Indicates whether there are abnormal services. This parameter is mandatory for Windows. |
|
account_rights |
No |
Boolean |
Indicates whether the account has the required permissions. This parameter is mandatory for Windows. |
|
boot_loader |
No |
String |
The system bootloader, which can be GRUB or LILO. This parameter is mandatory for Linux. The value can be: |
|
system_dir |
No |
String |
The system directory. This parameter is mandatory for Windows. |
|
volume_groups |
No |
Array of VolumeGroups objects |
This parameter is mandatory for Linux. If there are no volume groups, the value is an empty array []. |
|
vm_id |
No |
String |
The ID of the target server. This parameter is not required for automatically created target servers. |
|
flavor |
No |
String |
The flavor of the target server. |
|
disks |
Yes |
Array of TargetDisk objects |
The disk information of the target server, which is generally the same as that of the source server. |
|
image_disk_id |
No |
String |
The ID of the disk that hosts the agent image on the target server. |
|
snapshot_ids |
No |
String |
The ID of the snapshot for the target server. |
|
cutovered_snapshot_ids |
No |
String |
The ID of the snapshot used for rollback on the target server. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
name |
Yes |
String |
The file system name. |
|
label |
Yes |
String |
The file system tags. If no tag exists, the value is an empty string. |
|
uuid |
Yes |
String |
The UUID of the file system. |
|
device |
Yes |
String |
The device names of the Btrfs file system. |
|
size |
Yes |
Long |
The space occupied by the file system data. Range 0 to 9223372036854775807 |
|
nodesize |
Yes |
Long |
The Btrfs node size. Range 0 to 9223372036854775807 |
|
sectorsize |
Yes |
Integer |
The sector size. Range 0 to 2147483647 |
|
data_profile |
Yes |
String |
The data profile (RAD). |
|
system_profile |
Yes |
String |
The file system profile (RAD). |
|
metadata_profile |
Yes |
String |
The metadata profile (RAD). |
|
global_reserve1 |
Yes |
String |
The Btrfs file system information. |
|
g_vol_used_size |
Yes |
Long |
The used space of the Btrfs volume. Range 0 to 9223372036854775807 |
|
default_subvolid |
Yes |
String |
The ID of the default subvolume. |
|
default_subvol_name |
Yes |
String |
The name of the default subvolume. |
|
default_subvol_mountpath |
Yes |
String |
The mount path of the default subvolume or Btrfs file system. |
|
subvolumn |
Yes |
Array of BtrfsSubvolumn objects |
The subvolume information. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
uuid |
Yes |
String |
The UUID of the parent volume. |
|
is_snapshot |
Yes |
String |
Indicates whether the subvolume is a snapshot. |
|
subvol_id |
Yes |
String |
The subvolume ID. |
|
parent_id |
Yes |
String |
The parent volume ID. |
|
subvol_name |
Yes |
String |
The subvolume name. |
|
subvol_mount_path |
Yes |
String |
The mount path of the subvolume. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
name |
Yes |
String |
The NIC name. |
|
ip |
Yes |
String |
The IP address bound to the NIC. |
|
ipv6 |
No |
String |
The IPv6 address. |
|
netmask |
Yes |
String |
The subnet mask. |
|
gateway |
Yes |
String |
The gateway. |
|
mtu |
No |
Integer |
The NIC MTU. This parameter is mandatory for Linux. Range 0 to 2147483647 |
|
mac |
Yes |
String |
The MAC address. |
|
id |
No |
String |
The database record ID. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
components |
No |
String |
The physical volume information. |
|
free_size |
No |
Long |
The available space. Range 0 to 9223372036854775807 |
|
logical_volumes |
No |
Array of LogicalVolumes objects |
The logical volume information. |
|
name |
No |
String |
The name. |
|
size |
No |
Long |
The size. Range 0 to 9223372036854775807 |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
block_count |
No |
Integer |
The number of blocks. Range 0 to 2147483647 Default Value 0 |
|
block_size |
No |
Long |
The block size. Range 0 to 1048576 Default Value 0 |
|
file_system |
Yes |
String |
The file system. |
|
inode_size |
Yes |
Integer |
The number of inodes. Range 0 to 2147483647 |
|
inode_nums |
No |
Long |
The number of inodes. Range 0 to 9223372036854775807 |
|
device_use |
No |
String |
The partition function. The partition can be a general, boot, or OS partition. |
|
mount_point |
Yes |
String |
The mount point. |
|
name |
Yes |
String |
The name. |
|
size |
Yes |
Long |
The size. Range 0 to 9223372036854775807 |
|
used_size |
Yes |
Long |
The used space. Range 0 to 9223372036854775807 |
|
free_size |
Yes |
Long |
The available space. Range 0 to 9223372036854775807 |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
id |
No |
Long |
The disk ID. Range 0 to 9223372036854775807 |
|
device_use |
No |
String |
The partition function. The partition can be a general, boot, or OS partition. BOOT: boot device OS: system device NORMAL: general device Default Value NORMAL The value can be: |
|
disk_id |
No |
String |
The disk ID. |
|
name |
No |
String |
The disk name. |
|
physical_volumes |
No |
Array of TargetPhysicalVolumes objects |
The logical volume information. |
|
size |
No |
Long |
The size. Range 0 to 9223372036854775807 |
|
used_size |
No |
Long |
The used space. Range 0 to 9223372036854775807 |
|
disk_index |
No |
String |
The disk index. |
|
os_disk |
No |
Boolean |
Indicates whether the disk is the system disk. |
|
partition_style |
No |
String |
The disk partition type. This parameter is mandatory for source server registration. MBR: Master Boot Record (MBR) GPT: GUID Partition Table (GPT) The value can be: |
|
relation_name |
No |
String |
The name of the paired disk on the Linux target server. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
id |
No |
Long |
The logical volume ID. Range 0 to 9223372036854775807 |
|
device_use |
No |
String |
The partition function. NORMAL: general device OS: system device BOOT: boot device Default Value NORMAL The value can be: |
|
file_system |
No |
String |
The file system. |
|
index |
No |
Integer |
The serial number. Range 0 to 2147483647 |
|
mount_point |
No |
String |
The mount point. |
|
name |
No |
String |
The name. |
|
size |
No |
Long |
The size. Range 0 to 9223372036854775807 |
|
used_size |
No |
Long |
The used space. Range 0 to 9223372036854775807 |
|
uuid |
No |
String |
The UUID. |
|
relation_name |
No |
String |
The name of the paired disk on the Linux target server. |
|
free_size |
No |
Long |
The idle partition space. Range: 0 to 9223372036854775807 |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
vm_id |
No |
String |
The ID of the cloned server. |
|
name |
No |
String |
The name of the cloned server. |
|
clone_error |
No |
String |
The error returned for a clone failure. |
|
clone_state |
No |
String |
The clone status. |
|
error_msg |
No |
String |
The error message returned for a clone failure. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
id |
No |
Long |
The subtask ID. Range 0 to 9223372036854775807 |
|
name |
No |
String |
The subtask name. |
|
progress |
Yes |
Integer |
The progress of the subtask. The value is an integer ranging from 0 to 100. Range 0 to 100 |
|
start_date |
No |
Long |
The start time of the subtask. Range 0 to 9223372036854775807 |
|
end_date |
No |
Long |
The end time of the subtask. If the subtask is not complete, this parameter is left blank. Range 0 to 9223372036854775807 |
|
migrate_speed |
No |
Double |
The migration rate, in Mbit/s. Range 0 to 10000 |
|
user_op |
No |
String |
The user operation that triggers the subtask. |
|
process_trace |
No |
String |
The detailed progress of the migration or synchronization. |
Response
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
id |
String |
The task ID. |
Status code: 403
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
The error code. |
|
error_msg |
String |
The error message. |
|
encoded_authorization_message |
String |
The encrypted authorization information. |
|
error_param |
Array of strings |
Invalid parameters. |
|
details |
Array of details objects |
The error details. |
Example Request
This example updates the migration task whose ID is ef3b9722-07a0-40ae-89b0-889ee96dxxxx.
put https://{endpoint}/v3/tasks/ef3b9722-07a0-40ae-89b0-889ee96dxxxx
{
"name" : "MigrationTask",
"type" : "MIGRATE_BLOCK",
"os_type" : "WINDOWS",
"state" : "RUNNING",
"estimate_complete_time" : null,
"create_date" : 1598435778000,
"start_date" : 1598435784000,
"finish_date" : null,
"priority" : 1,
"speed_limit" : 0,
"migrate_speed" : 0.0,
"start_target_server" : true,
"error_json" : "",
"total_time" : 115,
"float_ip" : null,
"migration_ip" : null,
"vm_template_id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
"region_name" : "region name",
"region_id" : "region id",
"project_name" : "project name",
"project_id" : "xxxxxxxxxxxxxxxxxxxxxxxx00000001",
"sub_tasks" : [ {
"id" : 7278,
"name" : "CREATE_CLOUD_SERVER",
"progress" : 0,
"start_date" : 1598435802000,
"end_date" : null,
"user_op" : "REPLICATE"
}, {
"id" : 7279,
"name" : "SSL_CONFIG",
"progress" : 0,
"start_date" : null,
"end_date" : null,
"user_op" : "REPLICATE"
}, {
"id" : 7280,
"name" : "ATTACH_AGENT_IMAGE",
"progress" : 0,
"start_date" : null,
"end_date" : null,
"user_op" : "REPLICATE"
}, {
"id" : 7281,
"name" : "FORMAT_DISK_WINDOWS",
"progress" : 0,
"start_date" : null,
"end_date" : null,
"user_op" : "REPLICATE"
}, {
"id" : 7282,
"name" : "MIGRATE_WINDOWS_BLOCK",
"progress" : 0,
"start_date" : null,
"end_date" : null,
"user_op" : "REPLICATE"
} ],
"source_server" : {
"id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
"ip" : "192.168.0.154",
"name" : "name-win16",
"os_type" : "WINDOWS",
"os_version" : "WINDOWS2016_64BIT",
"agent_version" : "1.2.0",
"oem_system" : false,
"state" : "initialize",
"migration_cycle" : "replicating"
},
"target_server" : {
"id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001",
"vm_id" : "",
"name" : "",
"ip" : null,
"os_type" : "WINDOWS",
"os_version" : "WINDOWS2016_64BIT",
"system_dir" : "Y:\\Windows\\System32",
"disks" : [ {
"id" : 88008,
"name" : "Disk 1",
"relation_name" : null,
"disk_id" : "0",
"partition_style" : "MBR",
"size" : 42949672960,
"used_size" : 42947575808,
"device_use" : "OS",
"os_disk" : true,
"physical_volumes" : [ {
"id" : 135055,
"uuid" : "\\\\?\\Volume{586b7157-0000-0000-0000-100000000000}\\",
"index" : 1,
"name" : "Z:",
"relation_name" : null,
"device_use" : "BOOT",
"file_system" : "NTFS",
"mount_point" : null,
"size" : 524288000,
"used_size" : 410275840,
"free_size" : 114012160
}, {
"id" : 135056,
"uuid" : "\\\\?\\Volume{586b7157-0000-0000-0000-501f00000000}\\",
"index" : 2,
"name" : "Y:",
"relation_name" : null,
"device_use" : "OS",
"file_system" : "NTFS",
"mount_point" : null,
"size" : 42423287808,
"used_size" : 23170301952,
"free_size" : 19252985856
} ],
"disk_index" : "0"
} ],
"volume_groups" : [ ],
"image_disk_id" : null,
"cutovered_snapshot_ids" : null
},
"clone_server" : null
}
Example Response
Status code: 200
The migration task with a specified ID was updated.
{
"id" : "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001"
}
Status code: 403
Authentication failed.
{
"error_code" : "SMS.9004",
"error_msg" : "The current account does not have the permission to execute policy. You do not have permission to perform action XXX on resource XXX.",
"encoded_authorization_message" : "XXXXXX",
"error_param" : [ "You do not have permission to perform action XXX on resource XXX." ],
"details" : [ {
"error_code" : "SMS.9004",
"error_msg" : "You do not have permission to perform action XXX on resource XXX."
} ]
}
SDK Sample Code
The sample code is as follows.
This example updates the migration task whose ID is ef3b9722-07a0-40ae-89b0-889ee96dxxxx.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.GlobalCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.sms.v3.region.SmsRegion; import com.huaweicloud.sdk.sms.v3.*; import com.huaweicloud.sdk.sms.v3.model.*; import java.util.List; import java.util.ArrayList; public class UpdateTaskSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); ICredential auth = new GlobalCredentials() .withAk(ak) .withSk(sk); SmsClient client = SmsClient.newBuilder() .withCredential(auth) .withRegion(SmsRegion.valueOf("<YOUR REGION>")) .build(); UpdateTaskRequest request = new UpdateTaskRequest(); request.withTaskId("{task_id}"); PutTaskReq body = new PutTaskReq(); List<SubTask> listbodySubTasks = new ArrayList<>(); listbodySubTasks.add( new SubTask() .withId(7278L) .withName("CREATE_CLOUD_SERVER") .withProgress(0) .withStartDate(1598435802000L) .withUserOp("REPLICATE") ); listbodySubTasks.add( new SubTask() .withId(7279L) .withName("SSL_CONFIG") .withProgress(0) .withUserOp("REPLICATE") ); listbodySubTasks.add( new SubTask() .withId(7280L) .withName("ATTACH_AGENT_IMAGE") .withProgress(0) .withUserOp("REPLICATE") ); listbodySubTasks.add( new SubTask() .withId(7281L) .withName("FORMAT_DISK_WINDOWS") .withProgress(0) .withUserOp("REPLICATE") ); listbodySubTasks.add( new SubTask() .withId(7282L) .withName("MIGRATE_WINDOWS_BLOCK") .withProgress(0) .withUserOp("REPLICATE") ); List<TargetPhysicalVolumes> listDisksPhysicalVolumes = new ArrayList<>(); listDisksPhysicalVolumes.add( new TargetPhysicalVolumes() .withId(135055L) .withDeviceUse(TargetPhysicalVolumes.DeviceUseEnum.fromValue("BOOT")) .withFileSystem("NTFS") .withIndex(1) .withName("Z:") .withSize(524288000L) .withUsedSize(410275840L) .withUuid("\\?\Volume{586b7157-0000-0000-0000-100000000000}\") .withFreeSize(114012160L) ); listDisksPhysicalVolumes.add( new TargetPhysicalVolumes() .withId(135056L) .withDeviceUse(TargetPhysicalVolumes.DeviceUseEnum.fromValue("OS")) .withFileSystem("NTFS") .withIndex(2) .withName("Y:") .withSize(42423287808L) .withUsedSize(23170301952L) .withUuid("\\?\Volume{586b7157-0000-0000-0000-501f00000000}\") .withFreeSize(19252985856L) ); List<TargetDisk> listTargetServerDisks = new ArrayList<>(); listTargetServerDisks.add( new TargetDisk() .withId(88008L) .withDeviceUse(TargetDisk.DeviceUseEnum.fromValue("OS")) .withDiskId("0") .withName("Disk 1") .withPhysicalVolumes(listDisksPhysicalVolumes) .withSize(42949672960L) .withUsedSize(42947575808L) .withDiskIndex("0") .withOsDisk(true) .withPartitionStyle(TargetDisk.PartitionStyleEnum.fromValue("MBR")) ); TargetServer targetServerbody = new TargetServer(); targetServerbody.withDisks(listTargetServerDisks) .withVolumeGroups() .withVmId("") .withId("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001") .withOsVersion("WINDOWS2016_64BIT") .withSystemDir("Y:\Windows\System32") .withOsType(TargetServer.OsTypeEnum.fromValue("WINDOWS")) .withName(""); PostSourceServerBody sourceServerbody = new PostSourceServerBody(); sourceServerbody.withId("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001") .withIp("192.168.0.154") .withName("name-win16") .withOsType(PostSourceServerBody.OsTypeEnum.fromValue("WINDOWS")) .withOsVersion("WINDOWS2016_64BIT") .withAgentVersion("1.2.0") .withMigrationCycle(PostSourceServerBody.MigrationCycleEnum.fromValue("replicating")) .withState(PostSourceServerBody.StateEnum.fromValue("initialize")) .withOemSystem(false); body.withSubTasks(listbodySubTasks); body.withTotalTime(115L); body.withErrorJson(""); body.withMigrateSpeed((double)0.0); body.withStartDate(1598435784000L); body.withCreateDate(1598435778000L); body.withState("RUNNING"); body.withTargetServer(targetServerbody); body.withSourceServer(sourceServerbody); body.withVmTemplateId("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001"); body.withProjectId("xxxxxxxxxxxxxxxxxxxxxxxx00000001"); body.withProjectName("project name"); body.withSpeedLimit(0); body.withRegionName("region name"); body.withStartTargetServer(true); body.withRegionId("region id"); body.withPriority(PutTaskReq.PriorityEnum.NUMBER_1); body.withOsType(PutTaskReq.OsTypeEnum.fromValue("WINDOWS")); body.withType(PutTaskReq.TypeEnum.fromValue("MIGRATE_BLOCK")); body.withName("MigrationTask"); request.withBody(body); try { UpdateTaskResponse response = client.updateTask(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
This example updates the migration task whose ID is ef3b9722-07a0-40ae-89b0-889ee96dxxxx.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import GlobalCredentials from huaweicloudsdksms.v3.region.sms_region import SmsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdksms.v3 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] credentials = GlobalCredentials(ak, sk) client = SmsClient.new_builder() \ .with_credentials(credentials) \ .with_region(SmsRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateTaskRequest() request.task_id = "{task_id}" listSubTasksbody = [ SubTask( id=7278, name="CREATE_CLOUD_SERVER", progress=0, start_date=1598435802000, user_op="REPLICATE" ), SubTask( id=7279, name="SSL_CONFIG", progress=0, user_op="REPLICATE" ), SubTask( id=7280, name="ATTACH_AGENT_IMAGE", progress=0, user_op="REPLICATE" ), SubTask( id=7281, name="FORMAT_DISK_WINDOWS", progress=0, user_op="REPLICATE" ), SubTask( id=7282, name="MIGRATE_WINDOWS_BLOCK", progress=0, user_op="REPLICATE" ) ] listPhysicalVolumesDisks = [ TargetPhysicalVolumes( id=135055, device_use="BOOT", file_system="NTFS", index=1, name="Z:", size=524288000, used_size=410275840, uuid="\\?\Volume{586b7157-0000-0000-0000-100000000000}\", free_size=114012160 ), TargetPhysicalVolumes( id=135056, device_use="OS", file_system="NTFS", index=2, name="Y:", size=42423287808, used_size=23170301952, uuid="\\?\Volume{586b7157-0000-0000-0000-501f00000000}\", free_size=19252985856 ) ] listDisksTargetServer = [ TargetDisk( id=88008, device_use="OS", disk_id="0", name="Disk 1", physical_volumes=listPhysicalVolumesDisks, size=42949672960, used_size=42947575808, disk_index="0", os_disk=True, partition_style="MBR" ) ] targetServerbody = TargetServer( disks=listDisksTargetServer, vm_id="", id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001", os_version="WINDOWS2016_64BIT", system_dir="Y:\Windows\System32", os_type="WINDOWS", name="" ) sourceServerbody = PostSourceServerBody( id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001", ip="192.168.0.154", name="name-win16", os_type="WINDOWS", os_version="WINDOWS2016_64BIT", agent_version="1.2.0", migration_cycle="replicating", state="initialize", oem_system=False ) request.body = PutTaskReq( sub_tasks=listSubTasksbody, total_time=115, error_json="", migrate_speed=0.0, start_date=1598435784000, create_date=1598435778000, state="RUNNING", target_server=targetServerbody, source_server=sourceServerbody, vm_template_id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001", project_id="xxxxxxxxxxxxxxxxxxxxxxxx00000001", project_name="project name", speed_limit=0, region_name="region name", start_target_server=True, region_id="region id", priority=1, os_type="WINDOWS", type="MIGRATE_BLOCK", name="MigrationTask" ) response = client.update_task(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
This example updates the migration task whose ID is ef3b9722-07a0-40ae-89b0-889ee96dxxxx.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/global" sms "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/sms/v3" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/sms/v3/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/sms/v3/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") auth := global.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := sms.NewSmsClient( sms.SmsClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.UpdateTaskRequest{} request.TaskId = "{task_id}" idSubTasks:= int64(7278) nameSubTasks:= "CREATE_CLOUD_SERVER" startDateSubTasks:= int64(1598435802000) userOpSubTasks:= "REPLICATE" idSubTasks1:= int64(7279) nameSubTasks1:= "SSL_CONFIG" userOpSubTasks1:= "REPLICATE" idSubTasks2:= int64(7280) nameSubTasks2:= "ATTACH_AGENT_IMAGE" userOpSubTasks2:= "REPLICATE" idSubTasks3:= int64(7281) nameSubTasks3:= "FORMAT_DISK_WINDOWS" userOpSubTasks3:= "REPLICATE" idSubTasks4:= int64(7282) nameSubTasks4:= "MIGRATE_WINDOWS_BLOCK" userOpSubTasks4:= "REPLICATE" var listSubTasksbody = []model.SubTask{ { Id: &idSubTasks, Name: &nameSubTasks, Progress: int32(0), StartDate: &startDateSubTasks, UserOp: &userOpSubTasks, }, { Id: &idSubTasks1, Name: &nameSubTasks1, Progress: int32(0), UserOp: &userOpSubTasks1, }, { Id: &idSubTasks2, Name: &nameSubTasks2, Progress: int32(0), UserOp: &userOpSubTasks2, }, { Id: &idSubTasks3, Name: &nameSubTasks3, Progress: int32(0), UserOp: &userOpSubTasks3, }, { Id: &idSubTasks4, Name: &nameSubTasks4, Progress: int32(0), UserOp: &userOpSubTasks4, }, } idPhysicalVolumes:= int64(135055) deviceUsePhysicalVolumes:= model.GetTargetPhysicalVolumesDeviceUseEnum().BOOT fileSystemPhysicalVolumes:= "NTFS" indexPhysicalVolumes:= int32(1) namePhysicalVolumes:= "Z:" sizePhysicalVolumes:= int64(524288000) usedSizePhysicalVolumes:= int64(410275840) uuidPhysicalVolumes:= "\\?\Volume{586b7157-0000-0000-0000-100000000000}\" freeSizePhysicalVolumes:= int64(114012160) idPhysicalVolumes1:= int64(135056) deviceUsePhysicalVolumes1:= model.GetTargetPhysicalVolumesDeviceUseEnum().OS fileSystemPhysicalVolumes1:= "NTFS" indexPhysicalVolumes1:= int32(2) namePhysicalVolumes1:= "Y:" sizePhysicalVolumes1:= int64(42423287808) usedSizePhysicalVolumes1:= int64(23170301952) uuidPhysicalVolumes1:= "\\?\Volume{586b7157-0000-0000-0000-501f00000000}\" freeSizePhysicalVolumes1:= int64(19252985856) var listPhysicalVolumesDisks = []model.TargetPhysicalVolumes{ { Id: &idPhysicalVolumes, DeviceUse: &deviceUsePhysicalVolumes, FileSystem: &fileSystemPhysicalVolumes, Index: &indexPhysicalVolumes, Name: &namePhysicalVolumes, Size: &sizePhysicalVolumes, UsedSize: &usedSizePhysicalVolumes, Uuid: &uuidPhysicalVolumes, FreeSize: &freeSizePhysicalVolumes, }, { Id: &idPhysicalVolumes1, DeviceUse: &deviceUsePhysicalVolumes1, FileSystem: &fileSystemPhysicalVolumes1, Index: &indexPhysicalVolumes1, Name: &namePhysicalVolumes1, Size: &sizePhysicalVolumes1, UsedSize: &usedSizePhysicalVolumes1, Uuid: &uuidPhysicalVolumes1, FreeSize: &freeSizePhysicalVolumes1, }, } idDisks:= int64(88008) deviceUseDisks:= model.GetTargetDiskDeviceUseEnum().OS diskIdDisks:= "0" nameDisks:= "Disk 1" sizeDisks:= int64(42949672960) usedSizeDisks:= int64(42947575808) diskIndexDisks:= "0" osDiskDisks:= true partitionStyleDisks:= model.GetTargetDiskPartitionStyleEnum().MBR var listDisksTargetServer = []model.TargetDisk{ { Id: &idDisks, DeviceUse: &deviceUseDisks, DiskId: &diskIdDisks, Name: &nameDisks, PhysicalVolumes: &listPhysicalVolumesDisks, Size: &sizeDisks, UsedSize: &usedSizeDisks, DiskIndex: &diskIndexDisks, OsDisk: &osDiskDisks, PartitionStyle: &partitionStyleDisks, }, } vmIdTargetServer:= "" idTargetServer:= "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001" osVersionTargetServer:= "WINDOWS2016_64BIT" systemDirTargetServer:= "Y:\Windows\System32" targetServerbody := &model.TargetServer{ Disks: listDisksTargetServer, VmId: &vmIdTargetServer, Id: &idTargetServer, OsVersion: &osVersionTargetServer, SystemDir: &systemDirTargetServer, OsType: model.GetTargetServerOsTypeEnum().WINDOWS, Name: "", } idSourceServer:= "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001" ipSourceServer:= "192.168.0.154" nameSourceServer:= "name-win16" osTypeSourceServer:= model.GetPostSourceServerBodyOsTypeEnum().WINDOWS osVersionSourceServer:= "WINDOWS2016_64BIT" agentVersionSourceServer:= "1.2.0" migrationCycleSourceServer:= model.GetPostSourceServerBodyMigrationCycleEnum().REPLICATING stateSourceServer:= model.GetPostSourceServerBodyStateEnum().INITIALIZE oemSystemSourceServer:= false sourceServerbody := &model.PostSourceServerBody{ Id: &idSourceServer, Ip: &ipSourceServer, Name: &nameSourceServer, OsType: &osTypeSourceServer, OsVersion: &osVersionSourceServer, AgentVersion: &agentVersionSourceServer, MigrationCycle: &migrationCycleSourceServer, State: &stateSourceServer, OemSystem: &oemSystemSourceServer, } totalTimePutTaskReq:= int64(115) errorJsonPutTaskReq:= "" migrateSpeedPutTaskReq:= float64(0.0) startDatePutTaskReq:= int64(1598435784000) createDatePutTaskReq:= int64(1598435778000) statePutTaskReq:= "RUNNING" vmTemplateIdPutTaskReq:= "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx0001" projectIdPutTaskReq:= "xxxxxxxxxxxxxxxxxxxxxxxx00000001" projectNamePutTaskReq:= "project name" speedLimitPutTaskReq:= int32(0) regionNamePutTaskReq:= "region name" startTargetServerPutTaskReq:= true regionIdPutTaskReq:= "region id" priorityPutTaskReq:= model.GetPutTaskReqPriorityEnum().E_1 osTypePutTaskReq:= model.GetPutTaskReqOsTypeEnum().WINDOWS typePutTaskReq:= model.GetPutTaskReqTypeEnum().MIGRATE_BLOCK namePutTaskReq:= "MigrationTask" request.Body = &model.PutTaskReq{ SubTasks: &listSubTasksbody, TotalTime: &totalTimePutTaskReq, ErrorJson: &errorJsonPutTaskReq, MigrateSpeed: &migrateSpeedPutTaskReq, StartDate: &startDatePutTaskReq, CreateDate: &createDatePutTaskReq, State: &statePutTaskReq, TargetServer: targetServerbody, SourceServer: sourceServerbody, VmTemplateId: &vmTemplateIdPutTaskReq, ProjectId: &projectIdPutTaskReq, ProjectName: &projectNamePutTaskReq, SpeedLimit: &speedLimitPutTaskReq, RegionName: ®ionNamePutTaskReq, StartTargetServer: &startTargetServerPutTaskReq, RegionId: ®ionIdPutTaskReq, Priority: &priorityPutTaskReq, OsType: &osTypePutTaskReq, Type: &typePutTaskReq, Name: &namePutTaskReq, } response, err := client.UpdateTask(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
For SDK code examples in more programming languages, visit API Explorer and click the Sample Code tab. Example code can be automatically generated.
Status Codes
|
Status Code |
Description |
|---|---|
|
200 |
The migration task with a specified ID was updated. |
|
403 |
Authentication failed. |
Error Codes
For details, see Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot