Class: Fog::Compute::VcloudDirector::Disks

Inherits:
Collection
  • Object
show all
Defined in:
lib/fog/vcloud_director/models/compute/disks.rb

Instance Method Summary collapse

Methods inherited from Collection

#all, #get, #get_by_name, #get_everyone, #index

Instance Method Details

#create(size) ⇒ Object


12
13
14
15
16
17
18
# File 'lib/fog/vcloud_director/models/compute/disks.rb', line 12

def create(size)
  item_list unless @disks
  data = Fog::Generators::Compute::VcloudDirector::Disks.new(@disks)
  data.add_hard_disk(size)
  response = service.put_disks(vm.id, data.disks)
  service.process_task(response.body)
end

#get_by_id(item_id) ⇒ Object


20
21
22
23
24
# File 'lib/fog/vcloud_director/models/compute/disks.rb', line 20

def get_by_id(item_id)
  item = item_list.find{ |i| i[:id] == item_id}
  item.merge!(:all_disks => @disks, :vm => vm) if item
  item
end

#item_listObject


26
27
28
29
30
31
32
33
34
# File 'lib/fog/vcloud_director/models/compute/disks.rb', line 26

def item_list
  @disks = service.get_vm_disks(vm.id).body
  items = @disks[:disks]
  items.each do |disk|
    disk[:all_disks] = @disks
    disk[:vm] = vm
  end
  items
end