glance.api.common module

glance.api.common.check_quota(context, image_size, db_api, image_id=None)[source]

Method called to see if the user is allowed to store an image.

Checks if it is allowed based on the given size in glance based on their quota and current usage.

Parameters
  • context

  • image_size – The size of the image we hope to store

  • db_api – The db_api in use for this configuration

  • image_id – The image that will be replaced with this new data size

Returns

glance.api.common.get_remaining_quota(context, db_api, image_id=None)[source]

Method called to see if the user is allowed to store an image.

Checks if it is allowed based on the given size in glance based on their quota and current usage.

Parameters
  • context

  • db_api – The db_api in use for this configuration

  • image_id – The image that will be replaced with this new data size

Returns

The number of bytes the user has remaining under their quota. None means infinity

glance.api.common.get_thread_pool(lock_name, size=1024)[source]

Initializes eventlet thread pool.

If thread pool is present in cache, then returns it from cache else create new pool, stores it in cache and return newly created pool.

@param lock_name: Name of the lock. @param size: Size of eventlet pool.

@return: eventlet pool

glance.api.common.image_send_notification(bytes_written, expected_size, image_meta, request, notifier)[source]

Send an image.send message to the notifier.

glance.api.common.memoize(lock_name)[source]
glance.api.common.size_checked_iter(response, image_meta, expected_size, image_iter, notifier)[source]