Method: Beaker::OpenStack#initialize

Defined in:
lib/beaker/hypervisor/openstack.rb

#initialize(openstack_hosts, options) ⇒ OpenStack

Create a new instance of the OpenStack hypervisor object

Parameters:

  • openstack_hosts (<Host>)

    The array of OpenStack hosts to provision

  • options (Hash{Symbol=>String})

    The options hash containing configuration values

Options Hash (options):

  • :openstack_api_key (String)

    The key to access the OpenStack instance with (required)

  • :openstack_username (String)

    The username to access the OpenStack instance with (required)

  • :openstack_auth_url (String)

    The URL to access the OpenStack instance with (required)

  • :openstack_tenant (String)

    The tenant to access the OpenStack instance with (required)

  • :openstack_network (String)

    The network that each OpenStack instance should be contacted through (required)

  • :openstack_keyname (String)

    The name of an existing key pair that should be auto-loaded onto each OpenStack instance (optional)

  • :jenkins_build_url (String)

    Added as metadata to each OpenStack instance

  • :department (String)

    Added as metadata to each OpenStack instance

  • :project (String)

    Added as metadata to each OpenStack instance

  • :timeout (Integer)

    The amount of time to attempt execution before quiting and exiting with failure



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/openstack.rb', line 23

def initialize(openstack_hosts, options)
  require 'fog'
  @options = options
  @logger = options[:logger]
  @hosts = openstack_hosts
  @vms = []

  raise 'You must specify an Openstack API key (:oopenstack_api_key) for OpenStack instances!' unless @options[:openstack_api_key]
  raise 'You must specify an Openstack username (:openstack_username) for OpenStack instances!' unless @options[:openstack_username]
  raise 'You must specify an Openstack auth URL (:openstack_auth_url) for OpenStack instances!' unless @options[:openstack_auth_url]
  raise 'You must specify an Openstack tenant (:openstack_tenant) for OpenStack instances!' unless @options[:openstack_tenant]
  raise 'You must specify an Openstack network (:openstack_network) for OpenStack instances!' unless @options[:openstack_network]
  @compute_client ||= Fog::Compute.new(:provider => :openstack,
                                       :openstack_api_key => @options[:openstack_api_key],
                                       :openstack_username => @options[:openstack_username],
                                       :openstack_auth_url => @options[:openstack_auth_url],
                                       :openstack_tenant => @options[:openstack_tenant])
  if not @compute_client
    raise "Unable to create OpenStack Compute instance (api key: #{@options[:openstack_api_key]}, username: #{@options[:openstack_username]}, auth_url: #{@options[:openstack_auth_url]}, tenant: #{@options[:openstack_tenant]})"
  end
  @network_client ||= Fog::Network.new(
    :provider => :openstack,
    :openstack_api_key => @options[:openstack_api_key],
    :openstack_username => @options[:openstack_username],
    :openstack_auth_url => @options[:openstack_auth_url])
  if not @network_client

    raise "Unable to create OpenStack Network instance (api_key: #{@options[:openstack_api_key]}, username: #{@options[:openstack_username]}, auth_url: #{@options[:openstack_auth_url]}, tenant: #{@options[:openstack_tenant]})"
                                                                                                                                  end
end