
This sucks in the git history for both projects, then moves their files in place. It should not introduce any behavior changes to any of the existing openstacksdk code, nor to openstack.config and openstack.cloud - other than the name change. TODO(shade) comments have been left indicating places where further integration work should be done. It should not be assumed that these are the final places for either to live. This is just about getting them in-tree so we can work with them. The enforcer code for reasons surpassing understanding does not work with python setup.py build_sphinx but it does work with sphinx-build (what?) For now turn it off. We can turn it back on once the build sphinx job is migrated to the new PTI. Change-Id: I9523e4e281285360c61e9e0456a8e07b7ac1243c
2.9 KiB
Using OpenStack Image
Before working with the Image service, you'll need to create a
connection to your OpenStack cloud by following the connect
user guide. This will
provide you with the conn
variable used in the examples
below.
The primary resource of the Image service is the image.
List Images
An image is a collection of files for a specific operating system that you use to create or rebuild a server. OpenStack provides pre-built images. You can also create custom images, or snapshots, from servers that you have launched. Images come in different formats and are sometimes called virtual machine images.
../examples/image/list.py
Full example: image resource list
Create Image
Create an image by uploading its data and setting its attributes.
../examples/image/create.py
Full example: image resource create
Downloading an Image with stream=True
As images are often very large pieces of data, storing their entire contents in the memory of your application can be less than desirable. A more efficient method may be to iterate over a stream of the response data.
By choosing to stream the response content, you determine the
chunk_size
that is appropriate for your needs, meaning only
that many bytes of data are read for each iteration of the loop until
all data has been consumed. See requests.Response.iter_content
for more
information.
When you choose to stream an image download, openstacksdk is no longer able to compute the checksum of the response data for you. This example shows how you might do that yourself, in a very similar manner to how the library calculates checksums for non-streamed responses.
../examples/image/download.py
Downloading an Image with stream=False
If you wish to download an image's contents all at once and to
memory, simply set stream=False
, which is the default.
../examples/image/download.py
Full example: image resource download
Delete Image
Delete an image.
../examples/image/delete.py
Full example: image resource delete