Class: Beaker::Solaris

Inherits:
Hypervisor show all
Defined in:
lib/beaker/hypervisor/solaris.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(solaris_hosts, options) ⇒ Solaris

Returns a new instance of Solaris.



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

def initialize(solaris_hosts, options)
  @options = options
  @logger = options[:logger]
  @hosts = solaris_hosts
  @fog_file = nil
  if File.exists?( @options[:dot_fog] )
    @fog_file = YAML.load_file( @options[:dot_fog] )
  end
  raise "Cant load #{@options[:dot_fog]} config" unless @fog_file

end

Instance Method Details

#cleanupObject



54
55
56
# File 'lib/beaker/hypervisor/solaris.rb', line 54

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

#provisionObject



16
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
51
52
# File 'lib/beaker/hypervisor/solaris.rb', line 16

def provision
  hypername = @fog_file[:default][:solaris_hypervisor_server]
  vmpath    = @fog_file[:default][:solaris_hypervisor_vmpath]
  snappaths = @fog_file[:default][:solaris_hypervisor_snappaths]

  hyperopts = @options.dup
  hyperopts['HOSTS']  = {
      hypername => { 'platform' => 'solaris-11-sparc' }
  }

  @logger.notify "Connecting to hypervisor at #{hypername}"
  hypervisor = Beaker::Host.create( hypername, hyperopts, @options )
  hypervisor[:user] = @fog_file[:default][:solaris_hypervisor_username] || hypervisor[:user]
  hypervisor[:ssh][:keys] = [@fog_file[:default][:solaris_hypervisor_keyfile]] || hypervisor[:ssh][:keys]

  @hosts.each do |host|
    vm_name = host['vmname'] || host.name
    #use the snapshot provided for this host
    snapshot = host['snapshot']

    @logger.notify "Reverting #{vm_name} to snapshot #{snapshot}"
    start = Time.now
    hypervisor.exec(Command.new("sudo /sbin/zfs rollback -Rf #{vmpath}/#{vm_name}@#{snapshot}"))
    snappaths.each do |spath|
      @logger.notify "Reverting #{vm_name}/#{spath} to snapshot #{snapshot}"
      hypervisor.exec(Command.new("sudo /sbin/zfs rollback -Rf #{vmpath}/#{vm_name}/#{spath}@#{snapshot}"))
    end
    time = Time.now - start
    @logger.notify "Spent %.2f seconds reverting" % time

    @logger.notify "Booting #{vm_name}"
    start = Time.now
    hypervisor.exec(Command.new("sudo /sbin/zoneadm -z #{vm_name} boot"))
    @logger.notify "Spent %.2f seconds booting #{vm_name}" % (Time.now - start)
  end
  hypervisor.close
end