Volumes

Volume interface

class novaclient.v2.volumes.Volume(manager, info, loaded=False, resp=None)

Bases: novaclient.base.Resource

A volume is an extra block level storage to the OpenStack instances.

Populate and bind to a manager.

Parameters:
  • manager – BaseManager object
  • info – dictionary representing resource attributes
  • loaded – prevent lazy-loading if set to True
  • resp – Response or list of Response objects
NAME_ATTR = ‘display_name’
class novaclient.v2.volumes.VolumeManager(api)

Bases: novaclient.base.Manager

Manage Volume resources. This is really about volume attachments.

create_server_volume(server_id, volume_id, device=None)

Attach a volume identified by the volume ID to the given server ID

Parameters:
  • server_id – The ID of the server
  • volume_id – The ID of the volume to attach.
  • device – The device name (optional)
Return type:

Volume

delete_server_volume(server_id, attachment_id)

Detach a volume identified by the attachment ID from the given server

Parameters:
  • server_id – The ID of the server
  • attachment_id – The ID of the attachment
Returns:

An instance of novaclient.base.TupleWithMeta

get_server_volume(server_id, attachment_id)

Get the volume identified by the attachment ID, that is attached to the given server ID

Parameters:
  • server_id – The ID of the server
  • attachment_id – The ID of the attachment
Return type:

Volume

get_server_volumes(server_id)

Get a list of all the attached volumes for the given server ID

Parameters:server_id – The ID of the server
Return type:list of Volume
resource_class

alias of Volume

update_server_volume(server_id, src_volid, dest_volid)

Swaps the existing volume attachment to point to a new volume.

Takes a server, a source (attached) volume and a destination volume and performs a hypervisor assisted data migration from src to dest volume, detaches the original (source) volume and attaches the new destination volume. Note that not all backing hypervisor drivers support this operation and it may be disabled via policy.

Parameters:
  • server_id – The ID of the server
  • source_volume – The ID of the src volume
  • dest_volume – The ID of the destination volume
Return type:

Volume