Module: XenAPI::Vdi

Included in:
Session
Defined in:
lib/xenapi/vdi.rb

Instance Method Summary collapse

Instance Method Details

#create_VDI_for(storage_ref, vm_object, vdi_number) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/xenapi/vdi.rb', line 4

def create_VDI_for(storage_ref, vm_object, vdi_number)
  vdi_ref = self.VDI.create({
    :name_label => "#{vm_object.name} DISK #{vdi_number}",
    :name_description => "#{vm_object.name} DISK #{vdi_number}",
    :SR => storage_ref,
    :virtual_size => (vm_object.hdd - vm_object.hdd_size).gigabytes.to_s,
    :type => "system",
    :sharable => false,
    :read_only => false,
    :other_config => {},
    :xenstore_data => {},
    :sm_config => {},
    :tags => []
  })

  self.VDI.get_record(vdi_ref)["uuid"]
end

#vdi_clone(ref) ⇒ Object



30
31
32
# File 'lib/xenapi/vdi.rb', line 30

def vdi_clone(ref)
  self.VDI.clone(vdi_ref)
end

#vdi_name_description=(ref, label) ⇒ Object



50
51
52
# File 'lib/xenapi/vdi.rb', line 50

def vdi_name_description=(ref, label)
  self.VDI.set_name_description(ref, label)
end

#vdi_name_label(label) ⇒ Object



46
47
48
# File 'lib/xenapi/vdi.rb', line 46

def vdi_name_label(label)
  self.VDI.get_by_name_label(label).first
end

#vdi_name_label=(ref, label) ⇒ Object



42
43
44
# File 'lib/xenapi/vdi.rb', line 42

def vdi_name_label=(ref, label)
  self.VDI.set_name_label(ref, label)
end

#vdi_record(ref) ⇒ Object



26
27
28
# File 'lib/xenapi/vdi.rb', line 26

def vdi_record(ref)
  self.VDI.get_record(ref)
end

#vdi_ref(uuid) ⇒ Object



22
23
24
# File 'lib/xenapi/vdi.rb', line 22

def vdi_ref(uuid)
  self.VDI.get_by_uuid(uuid)
end

#vdi_resize(ref, new_size) ⇒ Object



38
39
40
# File 'lib/xenapi/vdi.rb', line 38

def vdi_resize(ref, new_size)
  self.VDI.resize(ref, new_size.to_s)
end

#vdi_virtual_size(ref) ⇒ Object



34
35
36
# File 'lib/xenapi/vdi.rb', line 34

def vdi_virtual_size(ref)
  self.VDI.get_virtual_size(ref).to_i/(1024**3)
end