Image API v2

Image API v2

For details on how to use image, see Using OpenStack Image

The Image v2 Class

The image high-level interface is available through the image member of a Connection object. The image member will only be added if the service is detected.

Image Operations

class openstack.image.v2._proxy.Proxy(session)
upload_image(container_format=None, disk_format=None, data=None, **attrs)

Upload a new image from attributes

Parameters:
  • container_format – Format of the container. A valid value is ami, ari, aki, bare, ovf, ova, or docker.
  • disk_format – The format of the disk. A valid value is ami, ari, aki, vhd, vmdk, raw, qcow2, vdi, or iso.
  • data – The data to be uploaded as an image.
  • attrs (dict) – Keyword arguments which will be used to create a Image, comprised of the properties on the Image class.
Returns:

The results of image creation

Return type:

Image

download_image(image, stream=False)

Download an image

This will download an image to memory when stream=False, or allow streaming downloads using an iterator when stream=True. For examples of working with streamed responses, see Downloading an Image with stream=True and the Requests documentation Body Content Workflow.

Parameters:
  • image – The value can be either the ID of an image or a Image instance.
  • stream (bool) –

    When True, return a requests.Response instance allowing you to iterate over the response data stream instead of storing its entire contents in memory. See requests.Response.iter_content() for more details. NOTE: If you do not consume the entirety of the response you must explicitly call requests.Response.close() or otherwise risk inefficiencies with the requests library’s handling of connections.

    When False, return the entire contents of the response.

Returns:

The bytes comprising the given Image when stream is False, otherwise a requests.Response instance.

update_image(image, **attrs)

Update a image

Parameters:image – Either the ID of a image or a Image instance.
Attrs kwargs:The attributes to update on the image represented by value.
Returns:The updated image
Return type:Image
delete_image(image, ignore_missing=True)

Delete an image

Parameters:
  • image – The value can be either the ID of an image or a Image instance.
  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the image does not exist. When set to True, no exception will be set when attempting to delete a nonexistent image.
Returns:

None

get_image(image)

Get a single image

Parameters:image – The value can be the ID of a image or a Image instance.
Returns:One Image
Raises:ResourceNotFound when no resource can be found.
find_image(name_or_id, ignore_missing=True)

Find a single image

Parameters:
  • name_or_id – The name or ID of a image.
  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the resource does not exist. When set to True, None will be returned when attempting to find a nonexistent resource.
Returns:

One Image or None

images(**query)

Return a generator of images

Parameters:**query (kwargs) – Optional query parameters to be sent to limit the resources being returned.
Returns:A generator of image objects
Return type:Image
deactivate_image(image)

Deactivate an image

Parameters:image – Either the ID of a image or a Image instance.
Returns:None
reactivate_image(image)

Deactivate an image

Parameters:image – Either the ID of a image or a Image instance.
Returns:None
add_tag(image, tag)

Add a tag to an image

Parameters:
  • image – The value can be the ID of a image or a Image instance that the member will be created for.
  • tag (str) – The tag to be added
Returns:

None

remove_tag(image, tag)

Remove a tag to an image

Parameters:
  • image – The value can be the ID of a image or a Image instance that the member will be created for.
  • tag (str) – The tag to be removed
Returns:

None

Member Operations

class openstack.image.v2._proxy.Proxy(session)
add_member(image, **attrs)

Create a new member from attributes

Parameters:
  • image – The value can be the ID of a image or a Image instance that the member will be created for.
  • attrs (dict) – Keyword arguments which will be used to create a Member, comprised of the properties on the Member class.
Returns:

The results of member creation

Return type:

Member

remove_member(member, image, ignore_missing=True)

Delete a member

Parameters:
  • member – The value can be either the ID of a member or a Member instance.
  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the member does not exist. When set to True, no exception will be set when attempting to delete a nonexistent member.
Returns:

None

update_member(member, image, **attrs)

Update the member of an image

Parameters:
  • member – Either the ID of a member or a Member instance.
  • image – This is the image that the member belongs to. The value can be the ID of a image or a Image instance.
Attrs kwargs:

The attributes to update on the member represented by value.

Returns:

The updated member

Return type:

Member

get_member(member, image)

Get a single member on an image

Parameters:
  • member – The value can be the ID of a member or a Member instance.
  • image – This is the image that the member belongs to. The value can be the ID of a image or a Image instance.
Returns:

One Member

Raises:

ResourceNotFound when no resource can be found.

find_member(name_or_id, image, ignore_missing=True)

Find a single member

Parameters:
  • name_or_id – The name or ID of a member.
  • image – This is the image that the member belongs to, the value can be the ID of a image or a Image instance.
  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the resource does not exist. When set to True, None will be returned when attempting to find a nonexistent resource.
Returns:

One Member or None

members(image)

Return a generator of members

Parameters:image – This is the image that the member belongs to, the value can be the ID of a image or a Image instance.
Returns:A generator of member objects
Return type:Member
Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.