class VirtualMachineDevice::Disk
Disk
class
Attributes
Public Class Methods
Source
# File lib/vm_disk.rb, line 26 def self.one_disk(id, one_res) new(id, one_res, nil) end
Create the OpenNebula
disk representation Allow us to create the class without vCenter representation example: attached disks not synced with vCenter
Source
# File lib/vm_disk.rb, line 33 def self.vc_disk(vc_res) new(nil, nil, vc_res) end
Create the vCenter disk representation Allow us to create the class without OpenNebula
representation example: detached disks that not exists in OpenNebula
Public Instance Methods
Source
# File lib/vm_disk.rb, line 140 def boot_dev if cd? RbVmomi::VIM.VirtualMachineBootOptionsBootableCdromDevice() else RbVmomi::VIM.VirtualMachineBootOptionsBootableDiskDevice( :deviceKey => device.key ) end end
Source
# File lib/vm_disk.rb, line 86 def cd? raise_if_no_exists_in_vcenter @vc_res[:type] == 'CDROM' end
Source
# File lib/vm_disk.rb, line 150 def change_size(size) size = size.to_i if @one_res['ORIGINAL_SIZE'] && @one_res['ORIGINAL_SIZE'].to_i >= size raise "'disk-resize' cannot decrease the disk's size" end @size = size end
Source
# File lib/vm_disk.rb, line 130 def cloned? raise_if_no_exists_in_one @one_res['SOURCE'] != @vc_res[:path_wo_ds] end
Source
# File lib/vm_disk.rb, line 91 def config(action) raise_if_no_exists_in_vcenter config = {} case action when :delete if managed? key = "opennebula.mdisk.#{@id}" else key = "opennebula.disk.#{@id}" end config[:key] = key config[:value] = '' when :resize if new_size d = device d.capacityInKB = new_size config[:device] = d config[:operation] = :edit end when :attach puts 'not supported' end config end
Source
# File lib/vm_disk.rb, line 135 def connected? raise_if_no_exists_in_vcenter @vc_res[:device].connectable.connected end
Source
# File lib/vm_disk.rb, line 172 def destroy return if cd? raise_if_no_exists_in_vcenter ds = VCenterDriver::Datastore.new(self.ds) img_path = path begin img_dir = File.dirname(img_path) search_params = ds.get_search_params( ds['name'], img_dir, File.basename(img_path) ) search_task = ds['browser'] .SearchDatastoreSubFolders_Task(search_params) search_task.wait_for_completion ds.delete_virtual_disk(img_path) ds.rm_directory(img_dir) if ds.dir_empty?(img_dir) rescue StandardError => e if !e.message.start_with?('FileNotFound') # Ignore FileNotFound raise e.message end end end
Source
# File lib/vm_disk.rb, line 42 def device raise_if_no_exists_in_vcenter @vc_res[:device] end
Source
# File lib/vm_disk.rb, line 57 def ds raise_if_no_exists_in_vcenter @vc_res[:datastore] end
Source
# File lib/vm_disk.rb, line 62 def image_ds_ref raise_if_no_exists_in_one @one_res['VCENTER_DS_REF'] end
Source
# File lib/vm_disk.rb, line 67 def key raise_if_no_exists_in_vcenter @vc_res[:key] end
Source
# File lib/vm_disk.rb, line 162 def new_size return @size * 1024 if @size return unless @one_res['ORIGINAL_SIZE'] osize = @one_res['ORIGINAL_SIZE'].to_i nsize = @one_res['SIZE'].to_i nsize > osize ? nsize * 1024 : nil end
Shrink not supported (nil). Size is in KB
Source
# File lib/vm_disk.rb, line 47 def node raise_if_no_exists_in_vcenter @vc_res[:tag] end
Source
# File lib/vm_disk.rb, line 52 def path raise_if_no_exists_in_vcenter @vc_res[:path_wo_ds] end
Source
# File lib/vm_disk.rb, line 120 def persistent? raise_if_no_exists_in_one @one_res['PERSISTENT'] == 'YES' end
Source
# File lib/vm_disk.rb, line 72 def prefix raise_if_no_exists_in_vcenter @vc_res[:prefix] end
Source
# File lib/vm_disk.rb, line 37 def storpod? raise_if_no_exists_in_one @one_res['VCENTER_DS_REF'].start_with?('group-') end
Source
# File lib/vm_disk.rb, line 77 def type raise_if_no_exists_in_vcenter @vc_res[:type] end
Source
# File lib/vm_disk.rb, line 125 def volatile? raise_if_no_exists_in_one @one_res['TYPE'] && @one_res['TYPE'].downcase == 'fs' end