Class: QemuToolkit::Backend::Illumos

Inherits:
Object
  • Object
show all
Defined in:
lib/qemu-toolkit/backend/illumos.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#verboseObject

Returns the value of attribute verbose.



3
4
5
# File 'lib/qemu-toolkit/backend/illumos.rb', line 3

def verbose
  @verbose
end

Instance Method Details

#disks(path) ⇒ Object



24
25
26
27
# File 'lib/qemu-toolkit/backend/illumos.rb', line 24

def disks(path)
  output = zfs :list, '-H -o name -t volume', '-r', path
  output.split("\n")
end

#dladm(*args) ⇒ Object



20
21
22
# File 'lib/qemu-toolkit/backend/illumos.rb', line 20

def dladm *args
  run_cmd :dladm, *args
end

#exec_with_arg0(command, name, *args) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/qemu-toolkit/backend/illumos.rb', line 38

def exec_with_arg0(command, name, *args)
  # exec in this form only wants to be given raw arguments that contain
  # no spaces. This is why we split and flatten args. 
  exec [command, name], *args.map { |a| a.split }.flatten
  
  fail "exec failed."
end

#iscsiadm(*args) ⇒ Object



17
18
19
# File 'lib/qemu-toolkit/backend/illumos.rb', line 17

def iscsiadm *args
  run_cmd :iscsiadm, *args
end

#itadm(*args) ⇒ Object



8
9
10
# File 'lib/qemu-toolkit/backend/illumos.rb', line 8

def itadm(*args)
  run_cmd :itadm, *args
end

#qemu(name, args) ⇒ Object



14
15
16
# File 'lib/qemu-toolkit/backend/illumos.rb', line 14

def qemu name, args
  exec_with_arg0 '/usr/bin/qemu-system-x86_64', name, *args
end

#run_cmd(*args) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/qemu-toolkit/backend/illumos.rb', line 29

def run_cmd(*args)
  cmd = args.join(' ')
  puts cmd if verbose
  ret = %x(#{cmd} 2>&1)

  raise "Execution error: #{cmd}." unless $?.success?

  ret
end

#stmfadm(*args) ⇒ Object



11
12
13
# File 'lib/qemu-toolkit/backend/illumos.rb', line 11

def stmfadm *args
  run_cmd :stmfadm, *args
end

#zfs(*args) ⇒ Object



5
6
7
# File 'lib/qemu-toolkit/backend/illumos.rb', line 5

def zfs *args
  run_cmd :zfs, *args
end