Method: Beaker::Hypervisor.create

Defined in:
lib/beaker/hypervisor.rb

.create(type, hosts_to_provision, options) ⇒ Object

Hypervisor creator method. Creates the appropriate hypervisor class object based upon the provided hypervisor type selected, then provisions hosts with hypervisor.

Parameters:

  • type (String)

    The type of hypervisor to create - one of aix, solaris, vsphere, fusion, blimpy, vcloud or vagrant

  • hosts_to_provision (Array<Host>)

    The hosts to be provisioned with the selected hypervisor

  • options (Hash)

    options Options to alter execution

Options Hash (options):

  • :host_name_prefix (String) — default: nil

    Prefix host name if set



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/beaker/hypervisor.rb', line 20

def self.create(type, hosts_to_provision, options)
  @logger = options[:logger]
  @logger.notify("Beaker::Hypervisor, found some #{type} boxes to create")

  hyper_class = case type
    when /^noop$/
      Beaker::Noop
    when /^(default)|(none)$/
      Beaker::Hypervisor
    else
      # Custom hypervisor
      require "beaker/hypervisor/#{type}"
      Beaker.const_get(type.split('_').collect(&:capitalize).join)
    end

  hypervisor = hyper_class.new(hosts_to_provision, options)
  self.set_ssh_connection_preference(hosts_to_provision, hypervisor)
  hypervisor.provision if options[:provision]

  hypervisor
end