Class: Beaker::Solaris
- Inherits:
-
Hypervisor
- Object
- Hypervisor
- Beaker::Solaris
- Defined in:
- lib/beaker/hypervisor/solaris.rb
Instance Method Summary collapse
- #cleanup ⇒ Object
-
#initialize(solaris_hosts, options, config) ⇒ Solaris
constructor
A new instance of Solaris.
Methods inherited from Hypervisor
Constructor Details
#initialize(solaris_hosts, options, config) ⇒ Solaris
Returns a new instance of Solaris.
4 5 6 7 8 9 10 11 12 13 14 15 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 53 54 55 56 57 58 |
# File 'lib/beaker/hypervisor/solaris.rb', line 4 def initialize(solaris_hosts, , config) = @config = config['CONFIG'].dup @logger = [:logger] @solaris_hosts = solaris_hosts fog_file = nil if File.exists?( File.join(ENV['HOME'], '.fog') ) fog_file = YAML.load_file( File.join(ENV['HOME'], '.fog') ) end raise "Cant load ~/.fog config" unless fog_file hypername = fog_file[:default][:solaris_hypervisor_server] vmpath = fog_file[:default][:solaris_hypervisor_vmpath] snappaths = fog_file[:default][:solaris_hypervisor_snappaths] hyperconf = { 'HOSTS' => { hypername => { 'platform' => 'solaris-11-sparc' } }, 'CONFIG' => { 'user' => fog_file[:default][:solaris_hypervisor_username] || ENV['USER'], 'ssh' => { :keys => fog_file[:default][:solaris_hypervisor_keyfile] || "#{ENV['HOME']}/.ssh/id_rsa" } } } hyperconfig = Beaker::TestConfig.new( hyperconf, ) @logger.notify "Connecting to hypervisor at #{hypername}" hypervisor = Beaker::Host.create( hypername, , hyperconfig ) @solaris_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 |
Instance Method Details
#cleanup ⇒ Object
60 61 62 |
# File 'lib/beaker/hypervisor/solaris.rb', line 60 def cleanup @logger.notify "No cleanup for solaris boxes" end |