Class: Beaker::Fusion

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

Constant Summary

Constants inherited from Hypervisor

Hypervisor::CHARMAP

Constants included from HostPrebuiltSteps

HostPrebuiltSteps::APT_CFG, HostPrebuiltSteps::CUMULUS_PACKAGES, HostPrebuiltSteps::DEBIAN_PACKAGES, HostPrebuiltSteps::ETC_HOSTS_PATH, HostPrebuiltSteps::ETC_HOSTS_PATH_SOLARIS, HostPrebuiltSteps::FREEBSD_PACKAGES, HostPrebuiltSteps::IPS_PKG_REPO, HostPrebuiltSteps::NTPSERVER, HostPrebuiltSteps::OPENBSD_PACKAGES, HostPrebuiltSteps::PSWINDOWS_PACKAGES, HostPrebuiltSteps::ROOT_KEYS_SCRIPT, HostPrebuiltSteps::ROOT_KEYS_SYNC_CMD, HostPrebuiltSteps::ROOT_KEYS_SYNC_CMD_AIX, HostPrebuiltSteps::SLEEPWAIT, HostPrebuiltSteps::SLES10_PACKAGES, HostPrebuiltSteps::SLES_PACKAGES, HostPrebuiltSteps::SOLARIS10_PACKAGES, HostPrebuiltSteps::TRIES, HostPrebuiltSteps::UNIX_PACKAGES, HostPrebuiltSteps::WINDOWS_PACKAGES

Instance Method Summary collapse

Methods inherited from Hypervisor

#configure, create, #generate_host_name, #proxy_package_manager, #validate

Methods included from HostPrebuiltSteps

#add_el_extras, #additive_hash_merge, #apt_get_update, #check_and_install_packages_if_needed, #construct_env, #copy_file_to_remote, #copy_ssh_to_root, #disable_iptables, #disable_se_linux, #disable_updates, #enable_root_login, #epel_info_for, #get_domain_name, #get_ip, #hack_etc_hosts, #package_proxy, #proxy_config, #set_env, #set_etc_hosts, #sync_root_keys, #timesync, #validate_host

Methods included from DSL::Patterns

#block_on

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
16
17
18
19
# 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
  @hosts = fusion_hosts
  #check preconditions for fusion
  @hosts.each do |host|
    raise "You must specify a snapshot for Fusion instances, no snapshot defined for #{host.name}!" unless host["snapshot"]
  end
  @fission = Fission::VM
end

Instance Method Details

#cleanupObject

revert_fusion



60
61
62
# File 'lib/beaker/hypervisor/fusion.rb', line 60

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

#provisionObject



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
51
52
53
54
55
56
57
58
# File 'lib/beaker/hypervisor/fusion.rb', line 21

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"]
  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