Class: Kitchen::Driver::Fog

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

Overview

Fog driver for Kitchen.

Author:

Instance Method Summary collapse

Instance Method Details

#create(state) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/kitchen/driver/fog.rb', line 40

def create(state)
  config[:name] ||= generate_name(instance.name)
  config[:disable_ssl_validation] and disable_ssl_validation
  server = create_server(state)
  unless config[:floating_ip_create].nil?
    create_floating_ip(server, state)
  else
    state[:hostname] = get_ip(server)
  end
  wait_for_sshd(state[:hostname]) ; puts '(ssh ready)'
  if config[:upload_public_ssh_key]
    upload_public_ssh_key(state, config, server)
  end
rescue ::Fog::Errors::Error, Excon::Errors::Error => ex
  raise ActionFailed, ex.message
end

#destroy(state) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/kitchen/driver/fog.rb', line 57

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

  config[:disable_ssl_validation] and disable_ssl_validation
  server = compute.servers.get(state[:server_id])
  server.destroy unless server.nil?
  info "Fog instance <#{state[:server_id]}> destroyed."
  unless config[:floating_ip_create].nil?
    network.floating_ips.destroy(state[:floating_ip_id])
    info "Fog floating ip #{state[:hostname]} " +
      "<#{state[:floating_ip_id]}> released."
    state.delete(:floating_ip_id)
  end
  state.delete(:server_id)
  state.delete(:hostname)
end