Class: Beaker::Fusion
- Inherits:
-
Hypervisor
- Object
- Hypervisor
- Beaker::Fusion
- Defined in:
- lib/beaker/hypervisor/fusion.rb
Instance Method Summary collapse
-
#cleanup ⇒ Object
revert_fusion.
-
#initialize(fusion_hosts, options) ⇒ Fusion
constructor
A new instance of Fusion.
- #provision ⇒ Object
Constructor Details
#initialize(fusion_hosts, options) ⇒ Fusion
Returns a new instance of Fusion.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/beaker/hypervisor/fusion.rb', line 3 def initialize(fusion_hosts, ) require 'rubygems' unless defined?(Gem) begin require 'fission' rescue LoadError raise 'Unable to load fission, please ensure it is installed!' end @logger = [:logger] @options = @hosts = fusion_hosts # check preconditions for fusion @hosts.each do |host| unless host['snapshot'] raise "You must specify a snapshot for Fusion instances, no snapshot defined for #{host.name}!" end end @fission = Fission::VM end |
Instance Method Details
#cleanup ⇒ Object
revert_fusion
59 60 61 |
# File 'lib/beaker/hypervisor/fusion.rb', line 59 def cleanup @logger.notify 'No cleanup for fusion boxes' end |
#provision ⇒ Object
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 51 52 53 54 55 56 57 |
# File 'lib/beaker/hypervisor/fusion.rb', line 22 def provision available = @fission.all.data.collect { |vm| vm.name }.sort.join(', ') @logger.notify "Available VM names: #{available}" @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? vm_snapshots = vm.snapshots.data if vm_snapshots.nil? or vm_snapshots.empty? raise "No snapshots available for VM #{host.name} (vmname: '#{vm_name}')" end available_snapshots = vm_snapshots.sort.join(', ') @logger.notify "Available snapshots for #{host.name}: #{available_snapshots}" snap_name = host['snapshot'] unless vm.snapshots.data.include? snap_name raise "Could not find snapshot '#{snap_name}' for host #{host.name}!" end @logger.notify "Reverting #{host.name} to snapshot '#{snap_name}'" start = Time.now vm.revert_to_snapshot snap_name sleep 1 while vm.running?.data time = Time.now - start @logger.notify 'Spent %.2f seconds reverting' % time @logger.notify "Resuming #{host.name}" start = Time.now vm.start headless: true sleep 1 until vm.running?.data time = Time.now - start @logger.notify 'Spent %.2f seconds resuming VM' % time end end |