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

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

Instance Attribute Summary

Attributes inherited from Fog::Collection

#service

Instance Method Summary collapse

Methods inherited from Collection

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

Methods inherited from Fog::Collection

#clear, #destroy, #initialize, #inspect, #load, model, #model, #new, #reload, #table, #to_json

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Fog::Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Collection

Instance Method Details

#create(size) ⇒ Object



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

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



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

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

#item_listObject



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

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