novaclient.v2.volumes module

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, tag=None, delete_on_termination=False)

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

  • tag – The tag (optional).

  • delete_on_termination – Marked whether to delete the attached volume when the server is deleted (optional).

Return type

Volume

delete_server_volume(server_id, volume_id=None, attachment_id=None)

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

Parameters
  • server_id – The ID of the server

  • volume_id – The ID of the volume to attach

Returns

An instance of novaclient.base.TupleWithMeta

get_server_volume(server_id, volume_id=None, attachment_id=None)

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

Parameters
  • server_id – The ID of the server

  • volume_id – The ID of the volume to attach

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, delete_on_termination=None)

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

  • delete_on_termination – Marked whether to delete the attached volume when the server is deleted (optional).

Return type

Volume