Starting a Migration Task
Scenarios
This section describes how to start a migration task by calling APIs. For details, see Calling APIs.
Before starting a migration task, you need to obtain a token. After starting the migration task, you need to query the task status. Only failed or paused tasks can be started.
Involved APIs
- Obtaining a User Token Through Password Authentication: This API is used to obtain a user token for authentication.
- Managing Migration Tasks (Start): This API is used to start a failed or paused migration task using a target AK/SK pair.
- Querying a Migration Task: This API is used to query the details of a migration task with a specified ID to check whether the migration task is successfully started.
Procedure
- Obtain an IAM user token.
- API
URI format: POST /v3/auth/tokens
For details, see Obtaining a User Token Through Password Authentication.
- Example request
POST: https://{iam_endpoint}/v3/auth/tokensObtain {endpoint} from Regions and Endpoints.
Body:{ "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "testname", "domain": { "name": "testname" }, "password": "Password" } } }, "scope": { "project": { "id": "0215ef11e49d4743be23dd97a1561xxx" } } } }
In the response header, the value of X-Subject-Token is the token.
X-Subject-Token: MIIDkgYJKoZIhvcNAQcCoIIDgzCCA38CAQExDTALBglghkgBZQMEAgEwgXXXXX...
- API
- Start the desired migration task.
- API
POST /v3/tasks/{task_id}/actionFor details, see Managing Migration Tasks (Start).
- Example request
POST https://sms.myhuaweicloud.eu/v3/tasks/8abda8635e09d185015e09d188dd0001xx/action
Header:
Content-Type: application/json X-Auth-Token: "Token"
Body:
{ "operation" : "start", }If the response code is 200, the API is successfully called.
- API
- View the migration task status.
- API
GET /v3/tasks/{task_id}For details, see Querying a Migration Task.
- Example request
GET https://sms.myhuaweicloud.eu/v3/tasks/8abda8635e09d185015e09d188dd0001xx
Header:
Content-Type: application/json X-Auth-Token: "Token"
- Example response
{ "id": "8abda8635e09d185015e09d188dd0001xx", "name": "MigrationTask", "type": "MIGRATE_FILE", "os_type": "LINUX", "state": "RUNNING", "estimate_complete_time": 1600391014000, "create_date": 1600159831000, "start_date": 1600159831000, "finish_date": 1600343128000, "priority": 1, "speed_limit": 0, "migrate_speed": 0, "start_target_server": true, "error_json": "", "total_time": 935000, "float_ip": "192.168.0.xxx", "migration_ip": "192.168.0.xxx", "vm_template_id": null, "region_name": "region_name", "region_id": "region_id", "project_name": "project_name", "project_id": "05825205120026802ff0c01721bc1xxx", "sub_tasks": [ { "id": 3514, "name": "SSL_CONFIG", "progress": 100, "start_date": 1600159847000, "end_date": 1600159851000, "user_op": "REPLICATE" }, { "id": 3515, "name": "ATTACH_AGENT_IMAGE", "progress": 100, "start_date": 1600159851000, "end_date": 1600160027000, "user_op": "REPLICATE" }, { "id": 3516, "name": "FORMAT_DISK_LINUX_FILE", "progress": 100, "start_date": 1600160027000, "end_date": 1600160030000, "user_op": "REPLICATE" }, { "id": 3517, "name": "MIGRATE_LINUX_FILE", "progress": 100, "start_date": 1600160080000, "end_date": 1600160088000, "user_op": "REPLICATE" }, { "id": 3582, "name": "CONFIGURE_LINUX_FILE", "progress": 100, "start_date": 1600333914000, "end_date": 1600334025000, "user_op": "CUTOVER0" }, { "id": 3583, "name": "DETTACH_AGENT_IMAGE", "progress": 100, "start_date": 1600334029000, "end_date": 1600334103000, "user_op": "CUTOVER0" }, { "id": 3584, "name": "SSL_CONFIG", "progress": 100, "start_date": 1600334185000, "end_date": 1600334188000, "user_op": "RESYNC0" }, { "id": 3585, "name": "ATTACH_AGENT_IMAGE", "progress": 100, "start_date": 1600334189000, "end_date": 1600334375000, "user_op": "RESYNC0" }, { "id": 3586, "name": "SYNC_LINUX_FILE", "progress": 100, "start_date": 1600334375000, "end_date": 1600334376000, "user_op": "RESYNC0" }, { "id": 3587, "name": "CONFIGURE_LINUX_FILE", "progress": 100, "start_date": 1600342952000, "end_date": 1600343052000, "user_op": "CUTOVER1" }, { "id": 3588, "name": "DETTACH_AGENT_IMAGE", "progress": 100, "start_date": 1600343056000, "end_date": 1600343128000, "user_op": "CUTOVER1" }, { "id": 3589, "name": "SSL_CONFIG", "progress": 100, "start_date": 1600390756000, "end_date": 1600390760000, "user_op": "RESYNC1" }, { "id": 3590, "name": "ATTACH_AGENT_IMAGE", "progress": 100, "start_date": 1600390760000, "end_date": 1600390953000, "user_op": "RESYNC1" }, { "id": 3591, "name": "SYNC_LINUX_FILE", "progress": 100, "start_date": 1600390954000, "end_date": 1600390954000, "user_op": "RESYNC1" } ], "source_server": { "id": "621f2cb5-ba4f-4819-b00d-ee48ca2c3xxx", "ip": "192.168.0.xxx", "name": "ecs-4bb4", "os_type": "LINUX", "os_version": "CENTOS_7_6_64BIT", "oem_system": false, "state": "syncing", "migration_cycle": "syncing" }, "target_server": { "id": "de35f45d-b6d5-4769-9148-984c8fab4xxx", "vm_id": "6d51477f-0a02-4917-8d7d-b13969f4axxx", "name": "ecs-4bb4", "ip": null, "os_type": "LINUX", "os_version": null, "system_dir": null, "disks": [ { "id": 86364, "name": "/dev/sda", "relation_name": "/dev/vda", "disk_id": "ed3c78d0-3166-48d1-bee0-d29e7d834xxx", "partition_style": "MBR", "size": 42949672960, "used_size": 42948624384, "device_use": "BOOT", "os_disk": false, "physical_volumes": [ { "id": 132594, "uuid": null, "index": 0, "name": "/dev/sda1", "relation_name": "/dev/vda1", "device_use": "OS", "file_system": "ext4", "mount_point": "/", "size": 42948624384, "used_size": 2467393536, "free_size": 40481230848 } ], "disk_index": "z" } ], "volume_groups": [], "image_disk_id": "9700f5ce-02ae-4a71-a057-deffe9b69xxx", "rollback_snapshot_ids": null }, "clone_server": null, "target_snapshot_id": null, "remain_seconds": 60000 }state indicates the task execution status. RUNNING indicates that the task is being executed, and MIGRATE_SUCCESS indicates that the task has been executed successfully.
- API
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.