Mastering Huawei Cloud Elastic Server Queries in 3 Simple Steps
After an intern’s suggestion to replace a VM with Huawei’s Elastic Cloud Server, the author shares a concise three‑step guide—complete with API request examples and response parsing—to efficiently query server details, limits, and pagination, illustrating practical cloud‑computing techniques.
When an intern recommended switching a virtual‑machine solution to Huawei’s Elastic Cloud Server, the author documented the experience and created a three‑step guide for querying server information via the Huawei Cloud API.
Step 1: Retrieve Server List with a Limit
API endpoint : GET /v2.1/{project_id}/servers/detail Request example :
GET https://{endpoint}/v2.1/743b4c0428d945316666666666666666/servers/detail?limit=100The limit parameter controls how many servers are returned per page. The response contains a servers array and, if more pages exist, a servers_links array with a next URI.
{
"servers": [
{
"tenant_id": "743b4c0428d945316666666666666666",
"metadata": {},
"addresses": {
"140fd038-c4ae-4c32-ac07-34b525eb6b95": [
{
"OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:e9:91:50",
"addr": "192.168.0.178",
"OS-EXT-IPS:type": "fixed",
"version": 4
}
]
},
"OS-EXT-STS:task_state": null,
"OS-DCF:diskConfig": "MANUAL",
"OS-EXT-AZ:availability_zone": "xxx",
"links": [
{"rel": "self", "href": "https://ecs.xxx/v2.1/743b4c0428d945316666666666666666/servers/f215afe8-b0c2-41cc-9191-585638166812"},
{"rel": "bookmark", "href": "https://ecs.xxx/743b4c0428d945316666666666666666/servers/f215afe8-b0c2-41cc-9191-585638166812"}
],
"OS-EXT-STS:power_state": 4,
"id": "f215afe8-b0c2-41cc-9191-585638166812",
"os-extended-volumes:volumes_attached": [{"id": "546cf622-b9e5-4784-b659-6881e711f283"}],
"OS-EXT-SRV-ATTR:host": "pod01.xxx",
"accessIPv4": "",
"image": {"links": [{"rel": "bookmark", "href": "https://ecs.xxx/743b4c0428d945316666666666666666/images/5c13381a-4a54-4ea5-a3b5-e7f7069f19a4"}], "id": "5c13381a-4a54-4ea5-a3b5-e7f7069f19a4"},
"OS-SRV-USG:terminated_at": null,
"accessIPv6": "",
"created": "2019-08-09T02:35:04Z",
"hostId": "31397656d6b318d01431f60c481d8425dc58eb421d237a385ceb80ee",
"OS-EXT-SRV-ATTR:hypervisor_hostname": "nova022@36",
"flavor": {"links": [{"rel": "bookmark", "href": "https://ecs.xxx/743b4c0428d945316666666666666666/flavors/s3.large.4"}], "id": "s3.large.4"},
"key_name": null,
"security_groups": [{"name": "sg-1e22"}],
"config_drive": "",
"OS-EXT-STS:vm_state": "stopped",
"user_id": "a8c20feabb5245e0bae4ef27618f932b",
"OS-EXT-SRV-ATTR:instance_name": "instance-004bf55f",
"name": "ecs-f090",
"OS-SRV-USG:launched_at": "2019-08-09T02:35:23.000000",
"updated": "2019-08-13T03:12:39Z",
"status": "SHUTOFF"
}
],
"servers_links": [{"rel": "next", "href": "https://ecs.xxx/v2.1/743b4c0428d945316666666666666666/servers/detail?limit=100&marker=f215afe8-b0c2-41cc-9191-585638166812"}]
}Step 2: Paginate with Limit and Marker
To retrieve subsequent pages, include both limit and the marker returned in the previous response’s
servers_links nextURI.
Request example :
GET https://{endpoint}/v2.1/743b4c0428d945316666666666666666/servers/detail?limit=100&marker=f215afe8-b0c2-41cc-9191-585638166812If the servers_links field is absent, no further pages exist. The response format mirrors Step 1, with a new marker for the next call.
{
"servers": [
{
"tenant_id": "743b4c0428d945316666666666666666",
"addresses": {"140fd038-c4ae-4c32-ac07-34b525eb6b95": [{"OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:a5:2b:f8", "addr": "192.168.0.169", "OS-EXT-IPS:type": "fixed", "version": 4}]},
"OS-EXT-STS:task_state": null,
"OS-DCF:diskConfig": "MANUAL",
"OS-EXT-AZ:availability_zone": "xxxc",
"links": [{"rel": "self", "href": "https://xxx/v2.1/743b4c0428d945316666666666666666/servers/62348919-0188-43ec-aae6-82c1e96c49eb"}, {"rel": "bookmark", "href": "https://ecs.xxx/743b4c0428d945316666666666666666/servers/62348919-0188-43ec-aae6-82c1e96c49eb"}],
"OS-EXT-STS:power_state": 4,
"id": "62348919-0188-43ec-aae6-82c1e96c49eb",
"os-extended-volumes:volumes_attached": [{"id": "f0bb068a-61c1-4dc8-8455-09857773c3ff"}],
"OS-EXT-SRV-ATTR:host": "pod01.xxx",
"accessIPv4": "",
"image": {"links": [{"rel": "bookmark", "href": "https://ecs.xxx/743b4c0428d945316666666666666666/images/3a64bd37-955e-40cd-ab9e-129db56bc05d"}], "id": "3a64bd37-955e-40cd-ab9e-129db56bc05d"},
"OS-SRV-USG:terminated_at": null,
"accessIPv6": "",
"created": "2019-07-27T03:06:48Z",
"hostId": "31397656d6b318d01431f60c481d8425dc58eb421d237a385ceb80ee",
"OS-EXT-SRV-ATTR:hypervisor_hostname": "nova022@36",
"flavor": {"links": [{"rel": "bookmark", "href": "https://ecs.xxx/743b4c0428d945316666666666666666/flavors/s3.medium.4"}], "id": "s3.medium.4"},
"key_name": null,
"security_groups": [{"name": "sg-1e22"}],
"config_drive": "",
"OS-EXT-STS:vm_state": "stopped",
"user_id": "f7e10ccf7abc4757b483895c3e06964a",
"OS-EXT-SRV-ATTR:instance_name": "instance-004a0eea",
"name": "test-dx",
"OS-SRV-USG:launched_at": "2019-07-27T03:07:05.000000",
"updated": "2019-08-13T03:12:38Z",
"status": "SHUTOFF"
}
],
"servers_links": [{"rel": "next", "href": "https://ecs.xxx/v2.1/743b4c0428d945316666666666666666/servers/detail?limit=100&marker=62348919-0188-43ec-aae6-82c1e96c49eb"}]
}Step 3: Aggregate All Results
Continue calling the API with the updated marker until the response contains no servers_links field or the servers array is empty. The combined servers arrays represent the complete set of Elastic Cloud Servers matching the query criteria.
This three‑step approach enables developers to programmatically list, paginate, and collect all Huawei Cloud Elastic Cloud Server instances, turning a seemingly complex API into a straightforward workflow.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Huawei Cloud Developer Alliance
The Huawei Cloud Developer Alliance creates a tech sharing platform for developers and partners, gathering Huawei Cloud product knowledge, event updates, expert talks, and more. Together we continuously innovate to build the cloud foundation of an intelligent world.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
