Querying BMSs (Native OpenStack API)
Function
This API is used to query BMSs.
Constraints
- The query result returned by this interface includes both ECSs and BMSs. You need to filter out the BMSs using the flavor used to create the BMSs or the tags added to the BMSs during BMS creation.
- If the image is used as the search criteria, other search criteria and pagination criteria are not supported. If both the image and other search criteria are used, the BMSs are filtered out by image. If the image is not used as the search criteria, this interface has no restrictions.
URI
GET /v2.1/{project_id}/servers{?changes-since={changes-since}&image={image}&flavor={flavor}&name={name}&status={status}&limit={limit}&marker={marker}&tags={tags}¬-tags={not-tags}&reservation_id={reservation_id}&sort_key={sort_key}&sort_dir={sort_dir}}
Table 1 lists the parameters.
Parameter |
Mandatory |
Description |
---|---|---|
project_id |
Yes |
Specifies the project ID. For details about how to obtain the project ID, see Obtaining a Project ID. |
Request
- Request parameters
Parameter
Mandatory
Type
Description
changes-since
No
String
Specifies the timestamp of the last BMS status update. The parameter is in ISO 8601 time format, for example, 2013-06-09T06:42:18Z.
image
No
String
Specifies the image ID.
NOTE:If the image is used as the search criteria, other search criteria and pagination criteria are not supported. If both the image and other search criteria are used, the BMS details are filtered out by image. If the image is not used as the search criteria, this interface has no restrictions.
flavor
No
String
Specifies the flavor ID.
You can obtain the flavor ID from the BMS console or using the Querying BMS Flavors (Native OpenStack API) API.
name
No
String
Specifies the BMS name. This parameter supports fuzzy matching.
For example, the regular expression ?name=bob will return both bob and bobb. To obtain only bob, you can use a regular expression matching the basic database syntax, such as MySQL or PostgreSQL (official website: https://www.postgresql.org/docs/9.2/static/functions-matching.html).
status
No
String
Specifies the BMS status.
Value range:
- ACTIVE: Running, Stopping, Deleting
- BUILD: Creating
- ERROR: Faulty
- HARD_REBOOT: Forcibly Restarting
- REBOOT: Restarting
- SHUTOFF: Stopped, Starting, Deleting, Rebuilding, Reinstalling OS, OS Reinstallation Failed
limit
No
Integer
Specifies the number of BMSs displayed on each page.
marker
No
String
Specifies the BMS ID to which the marker corresponds. The query will start from the next ID.
tags
No
String
Queries the BMSs with specified tags.
Added in micro version 2.26.
not-tags
No
String
Queries the BMSs with tags not containing the specified value. The value is a list of tag keys.
NOTE:If the tags added before the function upgrade are in the format of "Key.Value", query tags using "Key".
For example, an existing tag is a.b. After the tag function upgrade, query the tag using "not-tags=a".
Added in micro version 2.26.
reservation_id
No
String
Specifies the reserved ID, which can be used to query BMSs created in a batch.
Added in micro version 2.26.
sort_key
No
String
Specifies the BMS sorting attribute, which can be the BMS UUID (uuid), BMS status (vm_state), BMS name (display_name), BMS task status (task_state), power status (power_state), creation time (created_at), last time when the BMS is updated (updated_at), and AZ (availability_zone). You can specify multiple sort_key and sort_dir pairs.
The default sorting is the reverse order by created_at.
sort_dir
No
String
Specifies the sorting direction.
- asc: The query results are displayed in ascending order.
- desc (default value): The query results are displayed in descending order.
- Example request
- With no optional parameter
1
GET https://{ECS Endpoint}/v2.1/bbf1946d374b44a0a2a95533562ba954/servers
- With an optional parameter
1
GET https://{ECS Endpoint}/v2.1/bbf1946d374b44a0a2a95533562ba954/servers?tags=__type_baremetal
- With multiple optional parameters
1
GET https://{ECS Endpoint}/v2.1/bbf1946d374b44a0a2a95533562ba954/servers?tags=__type_baremetal&name=bms-test01
- With no optional parameter
Response Message
- Response parameters
Parameter
Type
Description
servers
Array of objects
Specifies the BMS list. For details, see Table 2.
Table 2 servers field data structure description Parameter
Type
Description
name
String
Specifies the BMS name.
id
String
Specifies the unique ID of the BMS.
links
Array of objects
Specifies shortcut links of the BMS. For details, see Table 3.
Table 3 links field data structure description Parameter
Type
Description
rel
String
Specifies the shortcut link marker name. The value can be:
- self: resource link that contains the version number. It is used when immediate tracing is required.
- bookmark: resource link that can be stored for a long time.
href
String
Specifies the corresponding shortcut link.
- Example response
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
{ "servers": [ { "name": "bms", "links": [ { "rel": "self", "href": "https://openstack.example.com/v2.1/c685484a8cc2416b97260938705deb65/servers/820abbd0-2d8b-4bc5-ae46-69cacfd4fbaa" }, { "rel": "bookmark", "href": "https://openstack.example.com/c685484a8cc2416b97260938705deb65/servers/820abbd0-2d8e-4bc5-ae46-69cacfd4fbaa" } ], "id": "820abbd0-2d8e-4bc5-ae46-69cacfd4fbaa" } ] }
Returned Values
Returned Values |
Description |
---|---|
200 |
The server has successfully processed the request. |
For details about other returned values, see Status Codes.
Error Codes
See Error Codes.
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