Images refer to the images that VMs can run on. See Openstack Docs for more info
NOTE: ImageQuery will work with non-admin credentials.
**However, for specific projects, or to query for images on all projects you need to have admin credentials
- set in
clouds.yaml**
To Query for Images using the Query Library, you can import ImageQuery() like so:
from openstackquery import ImageQueryImageQuery() can then be used to setup and run queries - see API.md for details on API calls
An Image has the following properties:
| Return Type | Property Name(s) (case-insensitive) | Description |
|---|---|---|
string (x) |
"created_at" | The timestamp when this image was created. |
int |
"progress" | Image creation percentage, 0 to 100. 100 once Image is created |
string |
"id", "uuid" | ID of the image |
string (x) |
"updated_at" | The timestamp when this image was last updated |
int |
"min_ram", "ram" | The minimum disk size in GB that is required to boot the image. |
int |
"min_disk", "disk" | The minimum amount of RAM in MB that is required to boot the image. |
string |
"name" | Name of the Image |
int |
"size" | The size of the image data, in bytes. |
string |
"status" | Image status |
string |
"owner", "tenant" | ID of the project which owns the image. Might be None i.e. for public images, which outputs in results as 'Not Found'. |
string |
"metadata" | Full metadata dictionary (as JSON-formatted string) |
(x) - These are UTC timestamps in ISO 8601 format
Any of these properties can be used for any of the API methods that takes a property - like select, where, sort_by etc
This section details valid mappings you can use to chain onto other queries or from other queries to chain into a ImageQuery object.
This applies to API calls then and append_from - see API.md for details
The aliases that can be used for the query when chaining are listed below:
| Aliases (case-insensitive) |
|---|
| "image", "images", "image_query", "imagequery" |
A ImageQuery can be chained to other queries.
The following shared-common properties are listed below (as well as the Query object they map to):
| Prop 1 | Prop 2 | Type | Maps | Documentation |
|---|---|---|---|---|
| "id" | "image_id" | One-to-Many | ImageQuery to ServerQuery |
SERVERS.md |
| "owner" | "id" | Many-to-One | ImageQuery to ProjectQuery |
PROJECTS.md |
Chaining from other ImageQuery requires passing image_query or any of the aliases mentioned above as the query_type
| From | Prop 1 | Prop 2 | Type | Documentation |
|---|---|---|---|---|
ServerQuery |
"id" | "image_id" | Many-to-One | SERVERS.md |
ProjectQuery |
"id" | "owner" | One-to-Many | PROJECTS.md |
ImageQuery() has the following meta-parameters that can be used when calling run() to fine-tune the query.
| Parameter Definition | Optional? | Description |
|---|---|---|
from_projects: List[str] |
Yes | A list of project IDs or Names to limit search to Optional, if not given will run search in project given in clouds.yaml. Searching for specific projects in Openstack may not be possible without admin credentials - as_admin needs to be set to True ) |
all_projects: Bool |
Yes, default = False | If True, will run query on all available projects available to the current user - set in clouds.yaml. Searching for specific projects in Openstack not be possible without admin credentials - as_admin needs to be set to True ) |
as_admin: Bool |
Yes, default = False | If True, will run the query as an admin - this may be required to query outside of given project context set in clouds.yaml. Make sure that the clouds.yaml context user has admin privileges |
To query on all projects call run() like so:
ImageQuery.run(as_admin=True, all_projects=True)To query on specific projects (you may not have access to) call run() like so (with admin creds):
ImageQuery.run(as_admin=True, from_projects=["name-or-id1", "name-or-id2"])