Module: DeltacloudVM::Client::Methods::StorageVolume

Included in:
Connection, StorageSnapshot, StorageVolume
Defined in:
lib/deltacloud_vm/client/methods/storage_volume.rb

Instance Method Summary collapse

Instance Method Details

#attach_storage_volume(volume_id, instance_id, device = nil) ⇒ Object

Attach the Storage Volume to the Instance The device parameter could be used if supported.

  • volume_id -> Volume ID (eg. ‘vol1’)

  • instance_id -> Target Instance ID (eg. ‘inst1’)

  • device -> Target device in Instance (eg. ‘/dev/sda2’)



70
71
72
73
74
75
76
77
78
# File 'lib/deltacloud_vm/client/methods/storage_volume.rb', line 70

def attach_storage_volume(volume_id, instance_id, device=nil)
  must_support! :storage_volumes
  result = connection.post(api_uri("/storage_volumes/#{volume_id}/attach")) do |r|
    r.params = { :instance_id => instance_id, :device => device }
  end
  if result.status.is_ok?
    from_resource(:storage_volume, result)
  end
end

#create_storage_volume(create_opts = {}) ⇒ Object

Create new storage volume

  • :snapshot_id -> Snapshot to use for creating a new volume

  • :capacity -> Initial Volume capacity

  • :realm_id -> Create volume in this realm

  • :name -> Volume name

  • :description -> Volume description

NOTE: Some create options might not be supported by backend cloud



50
51
52
# File 'lib/deltacloud_vm/client/methods/storage_volume.rb', line 50

def create_storage_volume(create_opts={})
  create_resource :storage_volume, create_opts
end

#destroy_storage_volume(volume_id) ⇒ Object

Destroy the current StorageVolume Returns ‘true’ if the response was 204 No Content

  • volume_id -> The ‘id’ of the volume to destroy



59
60
61
# File 'lib/deltacloud_vm/client/methods/storage_volume.rb', line 59

def destroy_storage_volume(volume_id)
  destroy_resource :storage_volume, volume_id
end

#detach_storage_volume(volume_id) ⇒ Object

Detach the Storage Volume from the Instance

-volume_id -> Volume to detach



84
85
86
87
88
89
90
# File 'lib/deltacloud_vm/client/methods/storage_volume.rb', line 84

def detach_storage_volume(volume_id)
  must_support! :storage_volumes
  result = connection.post(api_uri("/storage_volumes/#{volume_id}/detach"))
  if result.status.is_ok?
    from_resource(:storage_volume, result)
  end
end

#storage_volume(storage_volume_id) ⇒ Object

Retrieve the given storage_volume

  • storage_volume_id -> Instance to retrieve



35
36
37
38
# File 'lib/deltacloud_vm/client/methods/storage_volume.rb', line 35

def storage_volume(storage_volume_id)
  from_resource :storage_volume,
    connection.get(api_uri("storage_volumes/#{storage_volume_id}"))
end

#storage_volumes(filter_opts = {}) ⇒ Object

Retrieve list of all storage_volumes

  • filter_opts:

    • :id -> Filter storage_volumes using their ‘id’

    • :state -> Filter storage_volumes by their ‘state’



26
27
28
29
# File 'lib/deltacloud_vm/client/methods/storage_volume.rb', line 26

def storage_volumes(filter_opts={})
  from_collection :storage_volumes,
    connection.get(api_uri("storage_volumes"), filter_opts)
end