Class: Beaker::Fusion

Inherits:
Hypervisor show all
Defined in:
lib/beaker/hypervisor/fusion.rb

Instance Method Summary collapse

Methods inherited from Hypervisor

#configure, create

Constructor Details

#initialize(fusion_hosts, options) ⇒ Fusion

Returns a new instance of Fusion.



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/beaker/hypervisor/fusion.rb', line 4

def initialize(fusion_hosts, options)
  require 'rubygems' unless defined?(Gem)
  begin
    require 'fission'
  rescue LoadError
    raise "Unable to load fission, please ensure it is installed!"
  end
  @logger = options[:logger]
  @options = options
  @fusion_hosts = fusion_hosts
  @fission = Fission::VM
end

Instance Method Details

#cleanupObject

revert_fusion



52
53
54
# File 'lib/beaker/hypervisor/fusion.rb', line 52

def cleanup
  @logger.notify "No cleanup for fusion boxes"
end

#provisionObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/beaker/hypervisor/fusion.rb', line 17

def provision
available = @fission.all.data.collect{|vm| vm.name}.sort.join(", ")
@logger.notify "Available VM names: #{available}"

@fusion_hosts.each do |host|
  vm_name = host["vmname"] || host.name
  vm = @fission.new vm_name
  raise "Could not find VM '#{vm_name}' for #{host.name}!" unless vm.exists?

  available_snapshots = vm.snapshots.data.sort.join(", ")
  @logger.notify "Available snapshots for #{host.name}: #{available_snapshots}"
  snap_name = host["snapshot"] 
  raise "No snapshot specified for #{host.name}" unless snap_name
  raise "Could not find snapshot '#{snap_name}' for host #{host.name}!" unless vm.snapshots.data.include? snap_name

  @logger.notify "Reverting #{host.name} to snapshot '#{snap_name}'"
  start = Time.now
  vm.revert_to_snapshot snap_name
  while vm.running?.data
    sleep 1
  end
  time = Time.now - start
  @logger.notify "Spent %.2f seconds reverting" % time

  @logger.notify "Resuming #{host.name}"
  start = Time.now
  vm.start :headless => true
  until vm.running?.data
    sleep 1
  end
  time = Time.now - start
  @logger.notify "Spent %.2f seconds resuming VM" % time
end
end