Querying ECSs
Scenarios
This section describes how to use the API for querying details about ECSs to obtain all ECSs of a tenant by page.
The operations described in this section include information query by page and data filtering and sorting. For details about the parameters, see Querying Details About ECSs.
Involved APIs
Querying ECSs involves the following APIs:
Procedure
- Query details about ECSs by specifying the maximum number of ECSs displayed on one page.
- API
URI format: GET /v2.1/{project_id}/servers/detail
For details, see Querying Details About ECSs.
- Example request
GET: https://{endpoint}/v2.1/743b4c0428d945316666666666666666/servers/detail?limit=100
Obtain {endpoint} from the administrator.
The limit value can be adjusted based on ECS data.
- Example response
{ "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" } ] }
- API
- Query details about ECSs by specifying the maximum number of ECSs displayed on one page and the ID of the last flavor on one page.
- API
URI format: GET /v2.1/{project_id}/servers/detail
The used API is the same as that provided in 1.
- Example request
GET: https://{endpoint}/v2.1/743b4c0428d945316666666666666666/servers/detail?limit=100&marker=f215afe8-b0c2-41cc-9191-585638166812
The URI of the next page is returned. For details, see the href field in servers_links of the returned body. If this field is unavailable, there is no more pages any more.
- Example response
{ "servers": [ ..... { "tenant_id": "743b4c0428d945316666666666666666", "metadata": { }, "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" } ] }
- API
- Collect query results.
Repeat step 1 until the returned query result is empty or the returned body does not contain the servers_links field. This indicates that all ECSs have been queried.
The collected ECSs are the desired query results.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.