glance.image_cache package¶
Subpackages¶
Submodules¶
glance.image_cache.cleaner module¶
Cleans up any invalid cache entries
glance.image_cache.client module¶
-
class
glance.image_cache.client.
CacheClient
(host, port=None, timeout=None, use_ssl=False, auth_token=None, creds=None, doc_root=None, key_file=None, cert_file=None, ca_file=None, insecure=False, configure_via_auth=True)[source]¶ Bases:
glance.common.client.BaseClient
-
DEFAULT_DOC_ROOT
= '/v1'¶
-
DEFAULT_PORT
= 9292¶
-
-
glance.image_cache.client.
get_client
(host, port=None, timeout=None, use_ssl=False, username=None, password=None, tenant=None, auth_url=None, auth_strategy=None, auth_token=None, region=None, is_silent_upload=False, insecure=False)[source]¶ Returns a new client Glance client object based on common kwargs. If an option isn’t specified falls back to common environment variable defaults.
glance.image_cache.prefetcher module¶
Prefetches images into the Image Cache
glance.image_cache.pruner module¶
Prunes the Image Cache
Module contents¶
LRU Cache for Image Data
-
class
glance.image_cache.
ImageCache
[source]¶ Bases:
object
Provides an LRU cache for image data.
-
cache_image_file
(image_id, image_file)[source]¶ Cache an image file.
Parameters: - image_id – Image ID
- image_file – Image file to cache
Returns: True if image file was cached, False otherwise
-
cache_image_iter
(image_id, image_iter, image_checksum=None)[source]¶ Cache an image with supplied iterator.
Parameters: - image_id – Image ID
- image_file – Iterator retrieving image chunks
- image_checksum – Checksum of image
Returns: True if image file was cached, False otherwise
-
clean
(stall_time=None)[source]¶ Cleans up any invalid or incomplete cached images. The cache driver decides what that means...
-
configure_driver
()[source]¶ Configure the driver for the cache and, if it fails to configure, fall back to using the SQLite driver which has no odd dependencies
-
delete_all_cached_images
()[source]¶ Removes all cached image files and any attributes about the images and returns the number of cached image files that were deleted.
-
delete_all_queued_images
()[source]¶ Removes all queued image files and any attributes about the images and returns the number of queued image files that were deleted.
-
delete_cached_image
(image_id)[source]¶ Removes a specific cached image file and any attributes about the image
Parameters: image_id – Image ID
-
delete_queued_image
(image_id)[source]¶ Removes a specific queued image file and any attributes about the image
Parameters: image_id – Image ID
-
get_caching_iter
(image_id, image_checksum, image_iter)[source]¶ Returns an iterator that caches the contents of an image while the image contents are read through the supplied iterator.
Parameters: - image_id – Image ID
- image_checksum – checksum expected to be generated while iterating over image data
- image_iter – Iterator that will read image contents
-
get_hit_count
(image_id)[source]¶ Return the number of hits that an image has
Parameters: image_id – Opaque image identifier
-
get_image_size
(image_id)[source]¶ Return the size of the image file for an image with supplied identifier.
Parameters: image_id – Image ID
-
get_queued_images
()[source]¶ Returns a list of image IDs that are in the queue. The list should be sorted by the time the image ID was inserted into the queue.
-
is_cached
(image_id)[source]¶ Returns True if the image with the supplied ID has its image file cached.
Parameters: image_id – Image ID
-
is_queued
(image_id)[source]¶ Returns True if the image identifier is in our cache queue.
Parameters: image_id – Image ID
-
open_for_read
(image_id)[source]¶ Open and yield file for reading the image file for an image with supplied identifier.
- :note Upon successful reading of the image file, the image’s
- hit count will be incremented.
Parameters: image_id – Image ID
-