openstack.image.v2.image

The Image Class

The Image class inherits from Resource.

class openstack.image.v2.image.Image(_synchronized=False, connection=None, **attrs)

The base resource

Parameters:
  • _synchronized (bool) – This is not intended to be used directly. See new() and existing().

  • connection (openstack.connection.Connection) – Reference to the Connection being used. Defaults to None to allow Resource objects to be used without an active Connection, such as in unit tests. Use of self._connection in Resource code should protect itself with a check for None.

resources_key = 'images'

Plural form of key for resource.

base_path = '/images'

The base part of the URI for this resource.

allow_create = True

Allow create operation for this resource.

allow_fetch = True

Allow get operation for this resource.

allow_commit = True

Allow update operation for this resource.

allow_delete = True

Allow delete operation for this resource.

allow_list = True

Allow list operation for this resource.

commit_method = 'PATCH'

Method for committing a resource (PUT, PATCH, POST)

commit_jsonpatch = True

Whether commit uses JSON patch format.

checksum

Hash of the image data used. The Image service uses this value for verification.

container_format

The container format refers to whether the VM image is in a file format that also contains metadata about the actual VM. Container formats include OVF and Amazon AMI. In addition, a VM image might not have a container format - instead, the image is just a blob of unstructured data.

created_at

The date and time when the image was created.

disk_format

Valid values are: aki, ari, ami, raw, iso, vhd, vdi, qcow2, or vmdk. The disk format of a VM image is the format of the underlying disk image. Virtual appliance vendors have different formats for laying out the information contained in a VM disk image.

is_hidden

This field controls whether an image is displayed in the default image-list response

is_protected

Defines whether the image can be deleted. Type: bool

hash_algo

The algorithm used to compute a secure hash of the image data for this image

hash_value

The hexdigest of the secure hash of the image data computed using the algorithm whose name is the value of the os_hash_algo property.

min_disk

The minimum disk size in GB that is required to boot the image.

min_ram

The minimum amount of RAM in MB that is required to boot the image.

name

The name of the image.

owner

The ID of the owner, or project, of the image.

owner_id

The ID of the owner, or project, of the image. (backwards compat)

properties

Properties, if any, that are associated with the image.

size

The size of the image data, in bytes.

store

When present, Glance will attempt to store the disk image data in the backing store indicated by the value of the header. When not present, Glance will store the disk image data in the backing store that is marked default. Valid values are: file, s3, rbd, swift, cinder, gridfs, sheepdog, or vsphere.

status

The image status.

updated_at

The date and time when the image was updated.

virtual_size

The virtual size of the image.

visibility

The image visibility.

file

The URL for the virtual machine image file.

locations

A list of URLs to access the image file in external store. This list appears if the show_multiple_locations option is set to true in the Image service’s configuration file.

direct_url

The URL to access the image file kept in external store. It appears when you set the show_image_direct_url option to true in the Image service’s configuration file.

url

The URL to access the image file kept in external store.

metadata

The location metadata.

architecture

The CPU architecture that must be supported by the hypervisor.

hypervisor_type

The hypervisor type. Note that qemu is used for both QEMU and KVM hypervisor types.

instance_type_rxtx_factor

Optional property allows created servers to have a different bandwidth cap than that defined in the network they are attached to.

instance_uuid

create this image.

needs_config_drive

Specifies whether the image needs a config drive. mandatory or optional (default if property is not used).

kernel_id

The ID of an image stored in the Image service that should be used as the kernel when booting an AMI-style image.

os_distro

The common name of the operating system distribution in lowercase

os_version

The operating system version as specified by the distributor.

needs_secure_boot

Secure Boot is a security standard. When the instance starts, Secure Boot first examines software such as firmware and OS by their signature and only allows them to run if the signatures are valid.

os_shutdown_timeout

Time for graceful shutdown

ramdisk_id

The ID of image stored in the Image service that should be used as the ramdisk when booting an AMI-style image.

vm_mode

The virtual machine mode. This represents the host/guest ABI (application binary interface) used for the virtual machine.

hw_cpu_sockets

The preferred number of sockets to expose to the guest.

hw_cpu_cores

The preferred number of cores to expose to the guest.

hw_cpu_threads

The preferred number of threads to expose to the guest.

hw_disk_bus

Specifies the type of disk controller to attach disk devices to. One of scsi, virtio, uml, xen, ide, or usb.

hw_cpu_policy

Used to pin the virtual CPUs (vCPUs) of instances to the host’s physical CPU cores (pCPUs).

hw_cpu_thread_policy

Defines how hardware CPU threads in a simultaneous multithreading-based (SMT) architecture be used.

hw_rng_model

Adds a random-number generator device to the image’s instances.

hw_machine_type

For libvirt: Enables booting an ARM system using the specified machine type. For Hyper-V: Specifies whether the Hyper-V instance will be a generation 1 or generation 2 VM.

hw_scsi_model

Enables the use of VirtIO SCSI (virtio-scsi) to provide block device access for compute instances; by default, instances use VirtIO Block (virtio-blk).

hw_serial_port_count

Specifies the count of serial ports that should be provided.

hw_video_model

The video image driver used.

hw_video_ram

Maximum RAM for the video image.

hw_watchdog_action

Enables a virtual hardware watchdog device that carries out the specified action if the server hangs.

os_command_line

The kernel command line to be used by the libvirt driver, instead of the default.

hw_vif_model

Specifies the model of virtual network interface device to use.

is_hw_vif_multiqueue_enabled

If true, this enables the virtio-net multiqueue feature. In this case, the driver sets the number of queues equal to the number of guest vCPUs. This makes the network performance scale across a number of vCPUs.

is_hw_boot_menu_enabled

If true, enables the BIOS bootmenu.

vmware_adaptertype

The virtual SCSI or IDE controller used by the hypervisor.

vmware_ostype

A VMware GuestID which describes the operating system installed in the image.

has_auto_disk_config

If true, the root partition on the disk is automatically resized before the instance boots.

os_type

The operating system installed on the image.

os_admin_user

The operating system admin username.

hw_qemu_guest_agent

A string boolean, which if “true”, QEMU guest agent will be exposed to the instance.

os_require_quiesce

If true, require quiesce on snapshot via QEMU guest agent.

schema

The URL for the schema describing a virtual machine image.

deactivate(session)

Deactivate an image

Note: Only administrative users can view image locations for deactivated images.

reactivate(session)

Reactivate an image

Note: The image must exist in order to be reactivated.

upload(session, *, data=None)

Upload data into an existing image

Parameters:
  • session – The session to use for making this request

  • data – Optional data to be uploaded. If not provided, the ~Image.data attribute will be used

Returns:

The server response

stage(session, *, data=None)

Stage binary image data into an existing image

Parameters:
  • session – The session to use for making this request

  • data – Optional data to be uploaded. If not provided, the ~Image.data attribute will be used

Returns:

The server response

import_image(session, method='glance-direct', *, uri=None, remote_region=None, remote_image_id=None, remote_service_interface=None, store=None, stores=None, all_stores=None, all_stores_must_succeed=None)

Import Image via interoperable image import process

classmethod find(session, name_or_id, ignore_missing=True, **params)

Find a resource by its name or id.

Parameters:
  • session (Adapter) – The session to use for making this request.

  • name_or_id – This resource’s identifier, if needed by the request. The default is None.

  • 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.

  • list_base_path (str) – base_path to be used when need listing resources.

  • microversion (str) – API version to override the negotiated one.

  • params (dict) – Any additional parameters to be passed into underlying methods, such as to existing() in order to pass on URI parameters.

Returns:

The Resource object matching the given name or id or None if nothing matches.

Raises:

openstack.exceptions.DuplicateResource if more than one resource is found for this request.

Raises:

openstack.exceptions.ResourceNotFound if nothing is found and ignore_missing is False.