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, backend=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, backend_group=None)¶
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.
- static validate_schemas(uri, valid_schemas)¶
check if uri scheme is one of valid_schemas generate exception otherwise
- glance_store.location.get_location_from_uri(uri, conf=<oslo_config.cfg.ConfigOpts object>)¶
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://example.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 s3://accesskey:secretkey@s3.amazonaws.com/bucket/key-id s3+https://accesskey:secretkey@s3.amazonaws.com/bucket/key-id
- glance_store.location.get_location_from_uri_and_backend(uri, backend, conf=<oslo_config.cfg.ConfigOpts object>)¶
Extract backend location from a URI.
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.
backend – A backend name for the store.
conf – The global configuration.
- Example URIs:
https://user:pass@example.com:80/images/some-id http://example.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 s3://accesskey:secretkey@s3.amazonaws.com/bucket/key-id s3+https://accesskey:secretkey@s3.amazonaws.com/bucket/key-id
- glance_store.location.register_scheme_backend_map(scheme_map)¶
Registers a mapping between a scheme and a backend.
Given a mapping of ‘scheme’ to store_name, adds the mapping to the known list of schemes.
This function overrides existing stores.
- 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.