Query Details About 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 /v1/{project_id}/cloudservers/detail
For details, see Querying Details About ECSs.
- Example request
GET https://{endpoint}/v1/743b4c0428d945316666666666666666/cloudservers/detail?offset=1&limit=100
Obtain {endpoint} from Regions and Endpoints.
The limit value can be adjusted based on ECS data.
- Example response
{ "count":2, "servers":[ { "fault":null, "id":"743b4c0428d945316666666666666666", "name":"ecs-5e70", "addresses":{ "140fd038-c4ae-4c32-ac07-34b525eb6b95":[ { "version":"4", "addr":"192.168.0.206", "OS-EXT-IPS-MAC:mac_addr":"fa:16:3e:95:88:3f", "OS-EXT-IPS:port_id":"7b5d615c-186d-4646-9cb8-444addfe9b92", "OS-EXT-IPS:type":"fixed" }, { "version":"4", "addr":"192.168.0.8", "OS-EXT-IPS-MAC:mac_addr":"fa:16:3e:1d:88:43", "OS-EXT-IPS:port_id":"dda2027b-2f03-497b-8d42-620da2baacc3", "OS-EXT-IPS:type":"fixed" } ] }, "flavor":{ "disk":"0", "vcpus":"2", "ram":"1024", "id":"c3.large.2", "name":"c3.large.2", "gpus": [], "asic_accelerators": [] }, "accessIPv4":"", "accessIPv6":"", "status":"SHUTOFF", "image":{ "id":"1ce5800a-e487-4c1b-b264-3353a39e2b4b" }, "hostId":"f92345b97fd291f67a29ed735a82a8983f370175d2ba3d18d66893f4", "updated":"2018-08-14T07:26:49Z", "created":"2018-08-13T13:46:09Z", "metadata":{ "metering.image_id":"af60e0d5-6952-4f3d-b0ed-31bb19d4a692", "metering.resourcespeccode":"c3.large.2.linux", "image_name":"HEC_Public_Cloudinit_CentOS_7.4_64bit", "metering.product_id":"00301-253164-0--0", "os_bit":"64", "lockSourceId":"", "lockScene":"", "metering.order_id":"CS1808132145NRVRE", "lockCheckEndpoint":"", "metering.imagetype":"gold", "lockSource":"", "metering.resourcetype":"1", "vpc_id":"164489f6-cbf7-45b4-b6d0-d407c48cf7fc", "os_type":"Linux", "charging_mode":"1" }, "tags":[ ], "description":"ecs-4cff", "locked":false, "config_drive":"", "tenant_id":"edcb94a885a84ed3a3fdf8ea4d2741da", "user_id":"bb7f23e27e7e46f3aaceb5f53a158bdc", "os-extended-volumes:volumes_attached":[ { "device":"/dev/sda", "bootIndex":"0", "id":"2edc879f-022e-4bd6-b079-95a27564d449", "delete_on_termination":"false" } ], "OS-EXT-STS:task_state":null, "OS-EXT-STS:power_state":4, "OS-EXT-STS:vm_state":"stopped", "OS-EXT-SRV-ATTR:host":"az1.dc1", "OS-EXT-SRV-ATTR:instance_name":"instance-00137941", "OS-EXT-SRV-ATTR:hypervisor_hostname":"nova001@248", "OS-DCF:diskConfig":"MANUAL", "OS-EXT-AZ:availability_zone":"az1-dc1", "os:scheduler_hints":{ }, "OS-EXT-SRV-ATTR:root_device_name":"/dev/sda", "OS-EXT-SRV-ATTR:ramdisk_id":"8999878c-4a62-4014-89be-1743ff3a5daf", "OS-EXT-SRV-ATTR:user_data":"IyEvYmluL2Jhc2gKZWNobyAncm9vdDokNiRKQ2FzUWQkbm5wVmhJUFZlNVMwc3pXbnJGLnZVZ1FCWk4xTEo5Vy8wd09WTmFZaWpBRXdtRnhuQmZaTllVZXhBWktVWFVTeVhEeERuSUMzV2JjZEJyQUVBZkZvLy8nIHwgY2hwYXNzd2QgLWU7", "OS-SRV-USG:launched_at":"2018-08-13T13:46:46.000000", "OS-EXT-SRV-ATTR:kernel_id":"", "OS-EXT-SRV-ATTR:launch_index":0, "host_status":"UP", "OS-EXT-SRV-ATTR:reservation_id":"r-a8mg9vwr", "OS-EXT-SRV-ATTR:hostname":"ecs-4cff", "sys_tags":[ { "key":"_sys_enterprise_project_id", "value":"441d5677-b76a-4dd4-a97a-ef7fd633c095" } ], "security_groups":[ { "id":"71846bf6-1cda-4515-8590-3707be295e76", "name":"Sys-FullAccess" }, { "id":"b1786350-da65-11e7-b312-0255ac101b03", "name":"default" } ] }, { "fault":null, "id":"e3d3f219-b445-4a7a-8f00-e31412481f8c", "name":"ecs-1f30", "addresses":{ "00159d7d-b3c3-4108-8bc4-6658814e6422":[ { "version":"4", "addr":"192.168.20.197", "OS-EXT-IPS-MAC:mac_addr":"fa:16:3e:41:5a:32", "OS-EXT-IPS:port_id":"cfa2e055-54fb-427a-bde4-128bda47ae5c", "OS-EXT-IPS:type":"fixed" } ] }, "flavor":{ "disk":"0", "vcpus":"2", "ram":"1024", "id":"c3.large.2", "name":"c3.large.2", "gpus": [], "asic_accelerators": [] }, "accessIPv4":"", "accessIPv6":"", "status":"ACTIVE", "image":{ "id":"1ce5800a-e487-4c1b-b264-3353a39e2b4b" }, "progress":0, "hostId":"f92345b97fd291f67a29ed735a82a8983f370175d2ba3d18d66893f4", "updated":"2018-08-15T08:16:01Z", "created":"2018-08-13T11:57:29Z", "metadata":{ "sadfasfasf":"sdffffd", "metering.order_id":"CS180813193577ORO", "metering.imagetype":"gold", "metering.resourcespeccode":"c3.large.2.win", "metering.image_id":"65cb40e6-f67e-4bef-a1e7-808166a5999d", "image_name":"HEC_Public_Windows2008R2_Ent_64bit40G_English", "aaaaaa":"0", "metering.resourcetype":"1", "aaaa":"0", "metering.product_id":"00301-146042-0--0", "os_bit":"64", "vpc_id":"00159d7d-b3c3-4108-8bc4-6658814e6422", "os_type":"Windows", "charging_mode":"1" }, "tags":[ "_sys_root_resource_id=4514d9b0-d611-4744-bdf9-60802fd5198a", "_sys_root_resource_type=xxx.resource.type.vm" ], "description":"ecs-1f30", "locked":false, "config_drive":"", "tenant_id":"edcb94a885a84ed3a3fdf8ea4d2741da", "user_id":"bb7f23e27e7e46f3aaceb5f53a158bdc", "key_name":"Autotest_Init_TC_OriginalAPI_Create_Keypairs_02_keypair", "os-extended-volumes:volumes_attached":[ { "device":"/dev/sda", "bootIndex":"0", "id":"5043f66b-a0d8-4eb2-8c48-49976bcdc253", "delete_on_termination":"false" } ], "OS-EXT-STS:task_state":null, "OS-EXT-STS:power_state":1, "OS-EXT-STS:vm_state":"active", "OS-EXT-SRV-ATTR:host":"az1.dc1", "OS-EXT-SRV-ATTR:instance_name":"instance-0013772d", "OS-EXT-SRV-ATTR:hypervisor_hostname":"nova001@248", "OS-DCF:diskConfig":"MANUAL", "OS-EXT-AZ:availability_zone":"az1-dc1", "os:scheduler_hints":{ }, "OS-EXT-SRV-ATTR:root_device_name":"/dev/sda", "OS-EXT-SRV-ATTR:ramdisk_id":"8999878c-4a62-4014-92be-1743ff3a5daf", "OS-SRV-USG:launched_at":"2018-08-13T11:57:53.576640", "OS-EXT-SRV-ATTR:kernel_id":"", "OS-EXT-SRV-ATTR:launch_index":0, "host_status":"UP", "OS-EXT-SRV-ATTR:reservation_id":"r-xmjj4pnm", "OS-EXT-SRV-ATTR:hostname":"ecs-1f30", "sys_tags":[ { "key":"_sys_enterprise_project_id", "value":"441d5677-b76a-4dd4-a97a-ef7fd633c095" } ], "security_groups":[ { "name":"default" } ] } ] }
- 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 /v1/{project_id}/cloudservers/detail
The used API is the same as that provided in 1.
- Example request
GET https://{endpoint}/v1/743b4c0428d945316666666666666666/cloudservers/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":[ ..... { "fault":null, "id":"743b4c0428d945316666666666666666", "name":"ecs-1f30", "addresses":{ "140fd038-c4ae-4c32-ac07-34b525eb6b95":[ { "version":"4", "addr":"192.168.20.197", "OS-EXT-IPS-MAC:mac_addr":"fa:16:3e:41:5a:32", "OS-EXT-IPS:port_id":"cfa2e055-54fb-427a-bde4-128bda47ae5c", "OS-EXT-IPS:type":"fixed" } ] }, "flavor":{ "disk":"0", "vcpus":"2", "ram":"1024", "id":"c3.large.2", "name":"c3.large.2", "gpus": [], "asic_accelerators": [] }, "accessIPv4":"", "accessIPv6":"", "status":"ACTIVE", "image":{ "id":"1ce5800a-e487-4c1b-b264-3353a39e2b4b" }, "progress":0, "hostId":"f92345b97fd291f67a29ed735a82a8983f370175d2ba3d18d66893f4", "updated":"2018-08-15T08:16:01Z", "created":"2018-08-13T11:57:29Z", "metadata":{ "sadfasfasf":"sdffffd", "metering.order_id":"CS180813193577ORO", "metering.imagetype":"gold", "metering.resourcespeccode":"c3.large.2.win", "metering.image_id":"65cb40e6-f67e-4bef-a1e7-808166a5999d", "image_name":"HEC_Public_Windows2008R2_Ent_64bit40G_English", "aaaaaa":"0", "metering.resourcetype":"1", "aaaa":"0", "metering.product_id":"00301-146042-0--0", "os_bit":"64", "vpc_id":"00159d7d-b3c3-4108-8bc4-6658814e6422", "os_type":"Windows", "charging_mode":"1" }, "tags":[ "_sys_root_resource_id=4514d9b0-d611-4744-bdf9-60802fd5198a", "_sys_root_resource_type=xxx.resource.type.vm" ], "description":"ecs-1f30", "locked":false, "config_drive":"", "tenant_id":"edcb94a885a84ed3a3fdf8ea4d2741da", "user_id":"bb7f23e27e7e46f3aaceb5f53a158bdc", "key_name":"Autotest_Init_TC_OriginalAPI_Create_Keypairs_02_keypair", "os-extended-volumes:volumes_attached":[ { "device":"/dev/sda", "bootIndex":"0", "id":"5043f66b-a0d8-4eb2-8c48-49976bcdc253", "delete_on_termination":"false" } ], "OS-EXT-STS:task_state":null, "OS-EXT-STS:power_state":1, "OS-EXT-STS:vm_state":"active", "OS-EXT-SRV-ATTR:host":"az1.dc1", "OS-EXT-SRV-ATTR:instance_name":"instance-0013772d", "OS-EXT-SRV-ATTR:hypervisor_hostname":"nova001@248", "OS-DCF:diskConfig":"MANUAL", "OS-EXT-AZ:availability_zone":"az1-dc1", "os:scheduler_hints":{ }, "OS-EXT-SRV-ATTR:root_device_name":"/dev/sda", "OS-EXT-SRV-ATTR:ramdisk_id":"8999878c-4a62-4014-92be-1743ff3a5daf", "OS-SRV-USG:launched_at":"2018-08-13T11:57:53.576640", "OS-EXT-SRV-ATTR:kernel_id":"", "OS-EXT-SRV-ATTR:launch_index":0, "host_status":"UP", "OS-EXT-SRV-ATTR:reservation_id":"r-xmjj4pnm", "OS-EXT-SRV-ATTR:hostname":"ecs-1f30", "sys_tags":[ { "key":"_sys_enterprise_project_id", "value":"441d5677-b76a-4dd4-a97a-ef7fd633c095" } ], "security_groups":[ { "name":"default" } ] } ] }
- API
- Collect query results.
Repeat 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.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot