Creating a Migration Task
Scenarios
This section describes how to create a migration task by calling APIs. For details, see Calling APIs.
Involved APIs
- Obtaining a User Token Through Password Authentication: This API is used to obtain the user token for authentication.
- Registering a Source Server with SMS: This API is used to register a source server with SMS.
- Creating a Migration Task: This API is used to create a migration task using the source and destination AKs and SKs.
- Querying Details About a Migration Task: This API is used to query the details of a migration task based on the task ID to check whether the migration task is successfully started.
Prerequisites
- You have obtained the AK/SK for accessing the destination platform..
Procedure
- Obtain the token of the IAM user.
- 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/tokens
Obtain {endpoint} from Regions and Endpoints.
Body:{ "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "username", "domain": { "name": "domainname" }, "password": "******" } } }, "scope": { "project": { "id": "0215ef11e49d4743be23dd97a1561xxx" } } } }
In the response header, the value of X-Subject-Token is the token.
X-Subject-Token:MIIDkgYJKoZIhvcNAQcCoIIDgzCCA38CAQExDTALBglghkgBZQMEAgEwgXXXXX...
- API
- Report the source server information and register the source server.
- API
POST /v3/sources
For details, see Registering a Source Server with SMS.
- Example request
POST https://sms.myhuaweicloud.eu/v3/sources
Header:
Content-Type: application/json X-Auth-Token: "Token"
Body:
{ "os_type": "LINUX", "name": "bike-centos", "os_version": "CENTOS_7_4_64BIT", "linux_block_check": "{\"release_type\": \"CENTOS\", \"release_version\": \"7.4.1708\", \"kernel_simplification\": \"3.10.0\", \"architecture\": \"x86_64\", \"kernel_version\": \"3.10.0-1062.1.1.el7.x86_64\"}", "kernel_version": "3.10.0-1062.1.1.el7.x86_64", "virtualization_type": "HVM", "paravirtualization": true, "firmware": "BIOS", "has_rsync": true, "boot_loader": "GRUB", "disks": [{ "name": "/dev/vda", "size": 42949672960, "device_use": "BOOT", "partition_style": "MBR", "physical_volumes": [{ "name": "/dev/vda1", "size": 42948624384, "device_use": "OS", "used_size": 2854862848, "inode_size": "256", "file_system": "ext4", "mount_point": "/" }] }], "volume_groups": [], "cpu_quantity": 1, "memory": 1038716928, "networks": [{ "name": "eth0", "ip": "192.168.77.77", "mac": "ef05f3911eeccb12a0a8931dc198af84e848b0e9e3edd0812805429fc649xxxx" }], "ip": "192.168.77.77", "agent_version": "1.2.3-beta" }
- Example response
{ "id": "33b798a8-4f80-49ce-8b8a-18a85adfe13e" }
- API
- Create a migration task for the source server.
- API
POST /v3/tasks
For details, see Creating a Migration Task.
- Example request
POST https://sms.myhuaweicloud.eu/v3/tasks
Header:
Content-Type: application/json X-Auth-Token: "Token"
Body:
{ "auto_install_pvdriver" : true, "auto_start" : true, "syncing": false, "migration_ip" : "172.16.0.xxx", "name" : "MigrationTask", "os_type" : "WINDOWS", "project_id" : "05825205120026802xxxx01721bc1xxx", "project_name" : "project_name", "region_id" : "region_id", "region_name" : "region_name", "source_server" : { "id" : "9a01cb97-3eec-440e-xxxx-04016a8d7502" }, "start_target_server" : true, "target_server" : { "name" : "name", "vm_id" : "6dac09d8-5835-4888-xxxx-787453c4e1d4", "disks" : [{ "device_use" : "OS", "disk_id" : "354419d9-bd41-4b50-xxxx-e4f6f57c6xxx", "name" : "Disk 0", "physical_volumes" : [{ "device_use" : "BOOT", "file_system" : "NTFS", "index" : 1, "name" : "(Reserved)", "size" : 367001600, "used_size" : 31244288, "uuid" : "\\\\?\\Volume{b99b1c6f-75ef-xxxx-80b3-806e6f6e6963}\\" }, { "device_use" : "OS", "file_system" : "NTFS", "index" : 2, "name" : "C:\\", "size" : 42580574208, "used_size" : 16148279296, "uuid" : "\\\\?\\Volume{b99b1c70-75ef-xxxx-80b3-806e6f6e6963}\\" } ], "size" : 42949672960, "used_size" : 42949672960 }, { "device_use" : "NORMAL", "disk_id" : "ef409e5f-2321-49d1-xxxx-027fc93985ef", "name" : "Disk 1", "physical_volumes" : [{ "file_system" : "NTFS", "index" : 1, "name" : "D:\\", "size" : 53684994048, "used_size" : 3462647808, "uuid" : "\\\\?\\Volume{9f817be3-2cea-xxxx-816f-e995816380e2}\\" } ], "size" : 53687091200, "used_size" : 53687091200 } ], "btrfs_list" : null }, "type" : "MIGRATE_BLOCK", "use_public_ip" : false }
- Example response
{ "id": "8abda8635e09d185015e09d188dd0001xx" }
- API
- View the migration task status.
- API
GET /v3/tasks/{task_id}
For details, see "Querying a Migration Task by Task ID."
- 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": "READY", "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.176", "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. READY indicates that the task has been created.
- API
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.