ironic.common.glance_service.image_service module

class ironic.common.glance_service.image_service.GlanceImageService(client=None, context=None)[source]

Bases: object

call(method, *args, **kwargs)[source]

Call a glance client method.

If we get a connection error, retry the request according to CONF.num_retries.

Parameters
  • context – The request context, for access checks.

  • method – The method requested to be called.

  • args – A list of positional arguments for the method called

  • kwargs – A dict of keyword arguments for the method called

Raises

GlanceConnectionFailed

download(image_href, data=None)[source]

Calls out to Glance for data and writes data.

Parameters
  • image_href – The opaque image identifier.

  • data – (Optional) File object to write data to.

show(image_href)[source]

Returns a dict with image data for the given opaque image id.

Parameters

image_href – The opaque image identifier.

Returns

A dict containing image metadata.

Raises

ImageNotFound

Raises

ImageUnacceptable if the image status is not active

swift_temp_url(image_info)[source]

Generate a no-auth Swift temporary URL.

This function will generate (or return the cached one if temp URL cache is enabled) the temporary Swift URL using the image id from Glance and the config options: ‘swift_endpoint_url’, ‘swift_api_version’, ‘swift_account’ and ‘swift_container’. The temporary URL will be valid for ‘swift_temp_url_duration’ seconds. This allows Ironic to download a Glance image without passing around an auth_token.

Parameters

image_info – The return from a GET request to Glance for a certain image_id. Should be a dictionary, with keys like ‘name’ and ‘checksum’. See https://docs.openstack.org/glance/latest/user/glanceapi.html for examples.

Returns

A signed Swift URL from which an image can be downloaded, without authentication.

Raises

InvalidParameterValue if Swift config options are not set correctly.

Raises

MissingParameterValue if a required parameter is not set.

Raises

ImageUnacceptable if the image info from Glance does not have an image ID.

class ironic.common.glance_service.image_service.TempUrlCacheElement(url, url_expires_at)

Bases: tuple

property url

Alias for field number 0

property url_expires_at

Alias for field number 1

ironic.common.glance_service.image_service.check_image_service(func)[source]

Creates a glance client if doesn’t exists and calls the function.