Class: Kitchen::Driver::Openstack

Inherits:
SSHBase
  • Object
show all
Defined in:
lib/kitchen/driver/openstack.rb

Overview

Openstack driver for Kitchen.

Author:

Constant Summary collapse

@@ip_pool_lock =
Mutex.new

Instance Method Summary collapse

Instance Method Details

#create(state) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/kitchen/driver/openstack.rb', line 58

def create(state)
  config[:server_name] ||= default_name
  config[:disable_ssl_validation] && disable_ssl_validation
  server = create_server
  state[:server_id] = server.id
  info "OpenStack instance <#{state[:server_id]}> created."
  server.wait_for do
    print '.'
    ready?
  end
  info "\n(server ready)"
  if config[:floating_ip]
    attach_ip(server, config[:floating_ip])
  elsif config[:floating_ip_pool]
    attach_ip_from_pool(server, config[:floating_ip_pool])
  end
  state[:hostname] = get_ip(server)
  setup_ssh(server, state)
  add_ohai_hint(state)
rescue Fog::Errors::Error, Excon::Errors::Error => ex
  raise ActionFailed, ex.message
end

#destroy(state) ⇒ Object



81
82
83
84
85
86
87
88
89
90
# File 'lib/kitchen/driver/openstack.rb', line 81

def destroy(state)
  return if state[:server_id].nil?

  config[:disable_ssl_validation] && disable_ssl_validation
  server = compute.servers.get(state[:server_id])
  server.destroy unless server.nil?
  info "OpenStack instance <#{state[:server_id]}> destroyed."
  state.delete(:server_id)
  state.delete(:hostname)
end