Getting Started
Overview
This section uses an example to describe how to make calls to SMS APIs.
The procedure of creating a migration task is as follows:
- Call the Token-based Authentication API to obtain the user token, which will be put into the request header for authentication in a subsequent request.
- Install the migration agent on a prepared server that can access the Internet. For details, see How Can I Install the Migration Agent on Source Servers?
- Obtain the ID of the source server to be migrated from the queried source server list. For details about how to query source server list, see Querying the List of Source Servers.
- Select an ECS as the target server to obtain its ID.
- Make a call to the API for creating a migration task to create a migration task.
After creating the migration tasks, you can view it on the SMS console.
Prerequisites
- You have obtained the endpoint of IAM. For details, see Regions and Endpoints.
- You have obtained the endpoint of SMS. For details, see Regions and Endpoints.
- You have obtained the project ID. For details, see Obtaining a Project ID.
- You have obtained the ID of the region where the target ECS is located, which is also the default project name of the region where the target ECS is located.
Procedure
- Call the Token-based Authentication API to obtain a user token. Set the user token as an environment variable to call other APIs for authentication.
- Run the following command to obtain a user token:
curl -X POST https://{iam_endpoint}/v3/auth/tokens -H 'content-type: application/json' -d '{ "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "{user_name}", "domain": { "name": "{user_name}" }, "password": "{password}" } } }, "scope": { "project": { "id": "{project_id}" } } } }' -vkModify the command parameters as follows (for details, see the Identity and Access Management API Reference):
- {iam_endpoint}: Replace it with the obtained IAM endpoint.
- {project_id}: Replace it with the obtained project ID.
- {user_name} and {password}: Replace them respectively with the username and password of the IAM server.
In the response header, the value of X-Subject-Token is the token.
X-Subject-Token:MIIDkgYJKoZIhvcNAQcCoIIDgzCCA38CAQExDTALBglghkgBZQMEAgEwgXXXXX...
- Run the following command to set the token as an environment variable:
export Token={X-Subject-Token}
Replace value of X-Subject-Token with the token obtained in the previous step. An example command is as follows:
export Token=MIIDkgYJKoZIhvcNAQcCoIIDgzCCA38CAQExDTALBglghkgBZQMEAgEwgXXXXX...
- Run the following command to obtain a user token:
- Install the migration Agent of the Linux version. For details, see Installing the Linux Agent.
- Query the ID of the source server. For details, see Querying the List of Source Servers. Obtain the ID of the source server to be migrated from the queried source server list.
- Obtain the project ID based on the ID of the target ECS. For details, see Obtaining a Project ID.
- Make a call to Creating a Migration Task API to create a migration task.
The following uses the Linux OS as an example to describe how to create a migration task.
curl -X POST https://{sms_endpoint}/v1.0/tasks -H 'content-type: application/json' -H "x-auth-token: $Token" -d ' { "name": "Linux Migration", "type": "MIGRATE_FILE", "priority": "1", "speed_limit": "0", "start_target_server": "true", "os_type": "LINUX", "float_ip": "x.x.x.x", "region_name": "north-china", "region_id": "{region_id}", "project_name": "cn-north-1", "project_id": "{project_id}", "source_server": { "id": "{id}" }, "target_server": { "vm_id": "{vm_id}", "disks": [{ "name": "Disk 0", "disk_id": "e198f4cc-e51a-43df-1234-79bd41e00bed", "size": "85897247744", "physical_volumes": [{ "name": "xvda1", "size": "104857088" }, { "name": "xvda2", "size": "85792390656" } ] }, { "name": "Disk 1", "disk_id": "e198f4cc-1234-43df-1234-79bd41e00bed", "size": "214745218048", "physical_volumes": [{ "name": "xvdb1", "size": "109888667136" }, { "name": "xvdb2", "size": "104856550912" } ] } ] } } -vkModify the command parameters as follows (for details on how to set other parameters, see Creating a Migration Task):
- After the migration task is created, you can view the migration task on the Task Management page on the SMS console. Figure 1 Viewing the migration task
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.