glance_store package

Submodules

glance_store.backend module

class glance_store.backend.Indexable(wrapped, size)

Bases: object

Indexable for file-like objs iterators

Wrapper that allows an iterator or filelike be treated as an indexable data structure. This is required in the case where the return value from Store.get() is passed to Store.add() when adding a Copy-From image to a Store where the client library relies on eventlet GreenSockets, in which case the data to be written is indexed over.

another()

Implemented by subclasses to return the next element.

getvalue()

Return entire string value... used in testing

glance_store.backend.add_to_backend(conf, image_id, data, size, scheme=None, context=None, verifier=None)
glance_store.backend.check_location_metadata(val, key='')
glance_store.backend.create_stores(conf=<oslo_config.cfg.ConfigOpts object at 0x7f30f339b950>)

Registers all store modules and all schemes from the given config. Duplicates are not re-registered.

glance_store.backend.delete_from_backend(uri, context=None)

Removes chunks of data from backend specified by uri.

glance_store.backend.get_from_backend(uri, offset=0, chunk_size=None, context=None)

Yields chunks of data from backend specified by uri.

glance_store.backend.get_known_schemes()

Returns list of known schemes.

glance_store.backend.get_size_from_backend(uri, context=None)

Retrieves image size from backend specified by uri.

glance_store.backend.get_store_from_location(uri)

Given a location (assumed to be a URL), attempt to determine the store from the location. We use here a simple guess that the scheme of the parsed URL is the store...

Parameters:uri – Location to check for the store
glance_store.backend.get_store_from_scheme(scheme)

Given a scheme, return the appropriate store object for handling that scheme.

glance_store.backend.get_store_from_uri(uri)

Given a URI, return the store object that would handle operations on the URI.

Parameters:uri – URI to analyze
glance_store.backend.register_opts(conf)
glance_store.backend.set_acls(location_uri, public=False, read_tenants=[], write_tenants=None, context=None)
glance_store.backend.store_add_to_backend(image_id, data, size, store, context=None, verifier=None)

A wrapper around a call to each stores add() method. This gives glance a common place to check the output

Parameters:
  • image_id – The image add to which data is added
  • data – The data to be stored
  • size – The length of the data in bytes
  • store – The store to which the data is being added
  • context – The request context
  • verifier – An object used to verify signatures for images
Returns:

The url location of the file, the size amount of data, the checksum of the data the storage systems metadata dictionary for the location

glance_store.backend.verify_default_store()

glance_store.capabilities module

Glance Store capability

class glance_store.capabilities.BitMasks

Bases: enum.IntEnum

ALL = <BitMasks.ALL: 255>
DRIVER_REUSABLE = <BitMasks.DRIVER_REUSABLE: 64>
NONE = <BitMasks.NONE: 0>
READ_ACCESS = <BitMasks.READ_ACCESS: 1>
READ_CHUNK = <BitMasks.READ_CHUNK: 5>
READ_OFFSET = <BitMasks.READ_OFFSET: 3>
READ_RANDOM = <BitMasks.READ_RANDOM: 7>
RW_ACCESS = <BitMasks.RW_ACCESS: 9>
RW_CHUNK = <BitMasks.RW_CHUNK: 45>
RW_OFFSET = <BitMasks.RW_OFFSET: 27>
RW_RANDOM = <BitMasks.RW_RANDOM: 63>
WRITE_ACCESS = <BitMasks.WRITE_ACCESS: 8>
WRITE_CHUNK = <BitMasks.WRITE_CHUNK: 40>
WRITE_OFFSET = <BitMasks.WRITE_OFFSET: 24>
WRITE_RANDOM = <BitMasks.WRITE_RANDOM: 56>
class glance_store.capabilities.StoreCapability

Bases: object

capabilities
static contains(x, y)
is_capable(*capabilities)

Check if requested capability(s) are supported by current driver instance.

Parameters:capabilities – required capability(s).
set_capabilities(*dynamic_capabilites)

Set dynamic storage capabilities based on current driver configuration and backend status.

Parameters:dynamic_capabilites – dynamic storage capability(s).
unset_capabilities(*dynamic_capabilites)

Unset dynamic storage capabilities.

Parameters:dynamic_capabilites – dynamic storage capability(s).
update_capabilities()

Update dynamic storage capabilities based on current driver configuration and backend status when needed.

As a hook, the function will be triggered in two cases: calling once after store driver get configured, it was used to update dynamic storage capabilities based on current driver configuration, or calling when the capabilities checking of an operation failed every time, this was used to refresh dynamic storage capabilities based on backend status then.

This function shouldn’t raise any exception out.

glance_store.capabilities.check(store_op_fun)

glance_store.driver module

Base class for all storage backends

class glance_store.driver.Store(conf)

Bases: glance_store.capabilities.StoreCapability

OPTIONS = None
READ_CHUNKSIZE = 4194304
WRITE_CHUNKSIZE = 4194304
add(store, *args, **kwargs)
configure(re_raise_bsc=False)

Configure the store to use the stored configuration options and initialize capabilities based on current configuration.

Any store that needs special configuration should implement this method.

configure_add()

This is like configure except that it’s specifically for configuring the store to accept objects.

If the store was not able to successfully configure itself, it should raise exceptions.BadStoreConfiguration.

delete(store, *args, **kwargs)
get(store, *args, **kwargs)
get_schemes()

Returns a tuple of schemes which this store can handle.

get_size(location, context=None)

Takes a glance_store.location.Location object that indicates where to find the image file, and returns the size

Parameters:locationglance_store.location.Location object, supplied from glance_store.location.get_location_from_uri()
Raises:glance_store.exceptions.NotFound if image does not exist
get_store_location_class()

Returns the store location class that is used by this store.

set_acls(location, public=False, read_tenants=None, write_tenants=None, context=None)

Sets the read and write access control list for an image in the backend store.

Parameters:
  • locationglance_store.location.Location object, supplied from glance_store.location.get_location_from_uri()
  • public – A boolean indicating whether the image should be public.
  • read_tenants – A list of tenant strings which should be granted read access for an image.
  • write_tenants – A list of tenant strings which should be granted write access for an image.

glance_store.exceptions module

Glance Store exception subclasses

exception glance_store.exceptions.AuthBadRequest(message=None, **kwargs)

Bases: glance_store.exceptions.GlanceStoreException

message = u'Connect error/bad request to Auth service at URL %(url)s.'
exception glance_store.exceptions.AuthUrlNotFound(message=None, **kwargs)

Bases: glance_store.exceptions.GlanceStoreException

message = u'Auth service at URL %(url)s not found.'
exception glance_store.exceptions.AuthorizationFailure(message=None, **kwargs)

Bases: glance_store.exceptions.GlanceStoreException

message = u'Authorization failed.'
exception glance_store.exceptions.AuthorizationRedirect(message=None, **kwargs)

Bases: glance_store.exceptions.GlanceStoreException

message = u'Redirecting to %(uri)s for authorization.'
exception glance_store.exceptions.BackendException

Bases: exceptions.Exception

exception glance_store.exceptions.BadAuthStrategy(message=None, **kwargs)

Bases: glance_store.exceptions.GlanceStoreException

message = u'Incorrect auth strategy, expected "%(expected)s" but received "%(received)s"'
exception glance_store.exceptions.BadStoreConfiguration(message=None, **kwargs)

Bases: glance_store.exceptions.GlanceStoreException

message = u'Store %(store_name)s could not be configured correctly. Reason: %(reason)s'
exception glance_store.exceptions.BadStoreUri(message=None, **kwargs)

Bases: glance_store.exceptions.GlanceStoreException

message = u'The Store URI was malformed: %(uri)s'
exception glance_store.exceptions.DriverLoadFailure(message=None, **kwargs)

Bases: glance_store.exceptions.GlanceStoreException

message = u'Driver %(driver_name)s could not be loaded.'
exception glance_store.exceptions.Duplicate(message=None, **kwargs)

Bases: glance_store.exceptions.GlanceStoreException

message = u'Image %(image)s already exists'
exception glance_store.exceptions.Forbidden(message=None, **kwargs)

Bases: glance_store.exceptions.GlanceStoreException

message = u'You are not authorized to complete this action.'
exception glance_store.exceptions.GlanceStoreException(message=None, **kwargs)

Bases: exceptions.Exception

Base Glance Store Exception

To correctly use this class, inherit from it and define a ‘message’ property. That message will get printf’d with the keyword arguments provided to the constructor.

message = u'An unknown exception occurred'
exception glance_store.exceptions.HasSnapshot(message=None, **kwargs)

Bases: glance_store.exceptions.GlanceStoreException

message = u'The image cannot be deleted because it has snapshot(s).'
exception glance_store.exceptions.InUseByStore(message=None, **kwargs)

Bases: glance_store.exceptions.GlanceStoreException

message = u'The image cannot be deleted because it is in use through the backend store outside of Glance.'
exception glance_store.exceptions.Invalid(message=None, **kwargs)

Bases: glance_store.exceptions.GlanceStoreException

message = u'Data supplied was not valid.'
exception glance_store.exceptions.MaxRedirectsExceeded(message=None, **kwargs)

Bases: glance_store.exceptions.GlanceStoreException

message = u'Maximum redirects (%(redirects)s) was exceeded.'
exception glance_store.exceptions.MissingCredentialError(message=None, **kwargs)

Bases: glance_store.exceptions.GlanceStoreException

message = u'Missing required credential: %(required)s'
exception glance_store.exceptions.NoServiceEndpoint(message=None, **kwargs)

Bases: glance_store.exceptions.GlanceStoreException

message = u'Response from Keystone does not contain a Glance endpoint.'
exception glance_store.exceptions.NotAuthenticated(message=None, **kwargs)

Bases: glance_store.exceptions.GlanceStoreException

message = u'You are not authenticated.'
exception glance_store.exceptions.NotFound(message=None, **kwargs)

Bases: glance_store.exceptions.GlanceStoreException

message = u'Image %(image)s not found'
exception glance_store.exceptions.RedirectException(url)

Bases: exceptions.Exception

exception glance_store.exceptions.RegionAmbiguity(message=None, **kwargs)

Bases: glance_store.exceptions.GlanceStoreException

message = u"Multiple 'image' service matches for region %(region)s. This generally means that a region is required and you have not supplied one."
exception glance_store.exceptions.RemoteServiceUnavailable(message=None, **kwargs)

Bases: glance_store.exceptions.GlanceStoreException

message = u'Remote server where the image is present is unavailable.'
exception glance_store.exceptions.StorageFull(message=None, **kwargs)

Bases: glance_store.exceptions.GlanceStoreException

message = u'There is not enough disk space on the image storage media.'
exception glance_store.exceptions.StorageWriteDenied(message=None, **kwargs)

Bases: glance_store.exceptions.GlanceStoreException

message = u'Permission to write image storage media denied.'
exception glance_store.exceptions.StoreAddDisabled(message=None, **kwargs)

Bases: glance_store.exceptions.GlanceStoreException

message = u'Configuration for store failed. Adding images to this store is disabled.'
exception glance_store.exceptions.StoreDeleteNotSupported(message=None, **kwargs)

Bases: glance_store.exceptions.GlanceStoreException

message = u'Deleting images from this store is not supported.'
exception glance_store.exceptions.StoreGetNotSupported(message=None, **kwargs)

Bases: glance_store.exceptions.GlanceStoreException

message = u'Getting images from this store is not supported.'
exception glance_store.exceptions.StoreRandomGetNotSupported(message=None, **kwargs)

Bases: glance_store.exceptions.StoreGetNotSupported

message = u'Getting images randomly from this store is not supported. Offset: %(offset)s, length: %(chunk_size)s'
exception glance_store.exceptions.UnknownScheme(message=None, **kwargs)

Bases: glance_store.exceptions.GlanceStoreException

message = u"Unknown scheme '%(scheme)s' found in URI"
exception glance_store.exceptions.UnsupportedBackend

Bases: glance_store.exceptions.BackendException

glance_store.i18n module

glance_store.location module

A class that describes the location of an image in Glance.

In Glance, an image can either be stored in Glance, or it can be registered in Glance but actually be stored somewhere else.

We needed a class that could support the various ways that Glance describes where exactly an image is stored.

An image in Glance has two location properties: the image URI and the image storage URI.

The image URI is essentially the permalink identifier for the image. It is displayed in the output of various Glance API calls and, while read-only, is entirely user-facing. It shall not contain any security credential information at all. The Glance image URI shall be the host:port of that Glance API server along with /images/<IMAGE_ID>.

The Glance storage URI is an internal URI structure that Glance uses to maintain critical information about how to access the images that it stores in its storage backends. It may contain security credentials and is not user-facing.

class glance_store.location.Location(store_name, store_location_class, conf, uri=None, image_id=None, store_specs=None)

Bases: object

Class describing the location of an image that Glance knows about

get_store_uri()

Returns the Glance image URI, which is the host:port of the API server along with /images/<IMAGE_ID>

get_uri()
class glance_store.location.StoreLocation(store_specs, conf)

Bases: object

Base class that must be implemented by each store

get_uri()

Subclasses should implement a method that returns an internal URI that, when supplied to the StoreLocation instance, can be interpreted by the StoreLocation’s parse_uri() method. The URI returned from this method shall never be public and only used internally within Glance, so it is fine to encode credentials in this URI.

parse_uri(uri)

Subclasses should implement a method that accepts a string URI and sets appropriate internal fields such that a call to get_uri() will return a proper internal URI

process_specs()

Subclasses should implement any processing of the self.specs collection such as storing credentials and possibly establishing connections.

glance_store.location.get_location_from_uri(uri, conf=<oslo_config.cfg.ConfigOpts object at 0x7f30f339b950>)

Given a URI, return a Location object that has had an appropriate store parse the URI.

Parameters:
  • uri – A URI that could come from the end-user in the Location attribute/header.
  • conf – The global configuration.
Example URIs:
https://user:pass@example.com:80/images/some-id http://images.oracle.com/123456 swift://example.com/container/obj-id swift://user:account:pass@authurl.com/container/obj-id swift+http://user:account:pass@authurl.com/container/obj-id file:///var/lib/glance/images/1 cinder://volume-id
glance_store.location.register_scheme_map(scheme_map)

Given a mapping of ‘scheme’ to store_name, adds the mapping to the known list of schemes.

This function overrides existing stores.

Module contents