Module: Chef::Knife::Cloud::OvirtHelpers

Included in:
OvirtServerCreate, OvirtServerDelete, OvirtServerList, OvirtStorageList, OvirtVolumeCreate, OvirtVolumeList
Defined in:
lib/chef/knife/ovirt_helpers.rb

Instance Method Summary collapse

Instance Method Details

#create_service_instanceObject



13
14
15
# File 'lib/chef/knife/ovirt_helpers.rb', line 13

def create_service_instance
  OvirtService.new
end

#humanize(bytes) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/chef/knife/ovirt_helpers.rb', line 21

def humanize(bytes)
  b = bytes.to_i
  suf = %w(B KiB MiB GiB TiB EiB)
  c = suf[0]
  6.times do |count|
    if b < 1024
      c = suf[count]
      break
    end
    b /= 1024.0
  end
  format('%.2f ', b) + c
end

#validate!Object



17
18
19
# File 'lib/chef/knife/ovirt_helpers.rb', line 17

def validate!
  super(:ovirt_username, :ovirt_password, :ovirt_url)
end

#volume_ready(vm_id, vol_id) ⇒ Object



35
36
37
38
39
40
# File 'lib/chef/knife/ovirt_helpers.rb', line 35

def volume_ready(vm_id, vol_id)
  # find the volume and chaeck its status
  service.connection.list_vm_volumes(vm_id).select do |vol|
    vol[:id] == vol_id
  end[0][:status] == 'ok'
end